The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Yin on March 31, 2012, 04:18:02 PM

Title: Cancel movie with a button RMVXA
Post by: Yin on March 31, 2012, 04:18:02 PM
Writing a script to make the a movie play before the title screen, but I don't know how to make is so that when you press a button, the movie stops. Is there a way to cancel the movie at the press of a button? The movie plays all the way through.
Title: Re: Cancel movie with a button RMVXA
Post by: Yin on April 21, 2012, 05:50:17 PM
bump
Title: Re: Cancel movie with a button RMVXA
Post by: DoctorTodd on April 21, 2012, 06:49:48 PM
Use this  :)
if Input.press?(:C)
SceneManager.call(Scene_Title)
end

Check help file for other buttons, C means you hit enter or Z.
Title: Re: Cancel movie with a button RMVXA
Post by: Yin on April 21, 2012, 06:56:06 PM
That works during movies? I don't think this does  ???
Title: Re: Cancel movie with a button RMVXA
Post by: DoctorTodd on April 21, 2012, 07:17:22 PM
I think it might, why not give it a shot?
Title: Re: Cancel movie with a button RMVXA
Post by: Yin on April 21, 2012, 07:19:30 PM
I did :x It would not skip the movie. Maybe i am doing it wrong though.

def before_title_play_movie(movie)
    movie = Movie_To_Play
    Graphics.play_movie('Movies/' + movie) unless movie.empty?
    if Input.press?(:C)
      goto_title
    end
  end


I've also tried trigger instead of press.
Title: Re: Cancel movie with a button RMVXA
Post by: DoctorTodd on April 21, 2012, 07:24:29 PM
This may work, I think it wouldn't work because the option of cancelling isn't constant.
def update
  super
  cancel_options
end

def cancel_options
      if Input.press?(:C)
      goto_title
    end
Title: Re: Cancel movie with a button RMVXA
Post by: Yin on April 21, 2012, 07:29:09 PM
Thanks. I did that before too, but it did not work. I think the update method is not called while a movie is running. I could be wrong though. But that's not working either.

# Name of movie to play
Movie_To_Play = "Movie"

class Scene_Movie
  def main
    movie=nil
    before_title_play_movie(movie)
    goto_title
  end
 
  def before_title_play_movie(movie)
    movie = Movie_To_Play
    Graphics.play_movie('Movies/' + movie) unless movie.empty?
  end
 
  def goto_title
    SceneManager.call(Scene_Title)
  end
 
  def update
  super
    cancel_options
  end

  def cancel_options
    if Input.press?(:C)
      goto_title
    end
  end
end


That's my full code. The movie keeps playing no matter what I press.
Title: Re: Cancel movie with a button RMVXA
Post by: DoctorTodd on April 21, 2012, 07:40:23 PM
In that case I'm not sure. I highly doubt that this has any thing to do with it but wouldn't you add super after main?
Title: Re: Cancel movie with a button RMVXA
Post by: Yin on April 21, 2012, 07:42:25 PM
No, there's no super class for main. (At least that's what rmvxa told me when I tried it :p)

Thanks for trying to help though. Maybe it's just a stupid limitation of rmvxa.
Title: Re: Cancel movie with a button RMVXA
Post by: pacdiggity on April 21, 2012, 10:53:02 PM
The update method is not being called, mainly because Scene_Movie should have Scene_Base as its' superclass. Also you are overwriting 'main'. The update method is not being called, therefore the Input is not being checked, so it won't go to the title until the movie is over.
Title: Re: Cancel movie with a button RMVXA
Post by: Yin on April 21, 2012, 11:01:06 PM
Don't think I can overwrite main if it never existed in the class. I just added Scene_Base as the superclass and added the update call (That was a total facepalm moment for me)

My code now reads like this

# Name of movie to play
Movie_To_Play = "Movie"

class Scene_Movie < Scene_Base
  def main
    movie=nil
    before_title_play_movie(movie)
    goto_title
    update
  end
 
  def before_title_play_movie(movie)
    movie = Movie_To_Play
    Graphics.play_movie('Movies/' + movie) unless movie.empty?
    update
  end
 
  def goto_title
    SceneManager.call(Scene_Title)
  end
 
  def update
  super
    cancel_options
  end

  def cancel_options
    if Input.press?(:C)
      goto_title
    end
  end
end

#if Input.press?(:C)
# SceneManager.call(Scene_Title)
#end


Still doesn't work.
Title: Re: Cancel movie with a button RMVXA
Post by: pacdiggity on April 21, 2012, 11:06:45 PM
main DOES exist. It's there. In the editor. In Scene_Base. Which is now the superclass of Scene_Movie. Which means it's in Scene_Movie.
There's a problem with this; while Graphics#play_movie is happening, the scene is not being updated. This might be fixed with this controversial method I just invented.
class << Graphics
  alias skip_plmovie play_movie
  def play_movie(*args)
    skip_plmovie(*args)
    SceneManager.scene.update if SceneManager.scene.exist?
  end
end

That might work. Not exactly sure how the play_movie method works.

EDIT:: No, that won't work. It'll only call update once the movie has finished.
Hrm...
Title: Re: Cancel movie with a button RMVXA
Post by: Yin on April 21, 2012, 11:20:34 PM
When I aliased main, it froze everything. I added a print in there and it was constantly printing (which means it was indeed updating I think) But it just wasn't playing the movie or recognizing my input.

Oh didn't see you edit the post  :P