Jump to content
minth

Help me with my script.

Recommended Posts

Good evening, that's my first time writing a script, then i don't know advanced scripts.

That is my script:

 

class Window_TitleCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Create Command List --> ADD
  #--------------------------------------------------------------------------
  alias new_make_command_list make_command_list
  def make_command_list
    add_command(Vocab::new_game, :new_game)
    add_command(Vocab::continue, :continue, continue_enabled)
    add_command("Credits",       :credits)
    add_command(Vocab::shutdown, :shutdown)
  end
end

class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing --> CALL
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_TitleCommand.new
    @command_window.set_handler(:new_game, method(:command_new_game))
    @command_window.set_handler(:continue, method(:command_continue))
    @command_window.set_handler(:credits,  method(:command_credits))    
    @command_window.set_handler(:shutdown, method(:command_shutdown))
  end
    
  #--------------------------------------------------------------------------
  # * Create Background --> creation
  #--------------------------------------------------------------------------
  def create_story_contents
    super
    @background_text = Sprite.new
  end
  
  #-------------------------------------------------------------------
  # * [Credits] Command
  #--------------------------------------------------------------------------
  def command_credits
    close_command_window
    SceneManager.call(Scene_Credits)
  end
end

class Scene_Credits < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing --> START* VERY IMPORTANT
  #--------------------------------------------------------------------------
  def start
    super
    create_command_window
  end
  
  #--------------------------------------------------------------------------
  # * Pre-Termination Processing --> COMMAND CLOSE
  #--------------------------------------------------------------------------
  def pre_terminate
    super
    @command_window.close
  end
  
  def make_command_list
    add_command(Vocab::to_title, :to_title)
  end
  
  #--------------------------------------------------------------------------
  # * Create Background --> call
  #--------------------------------------------------------------------------
  def create_background
    super
    @background_sprite.bitmap = Cache.picture("video-credits-hero")
  end
  
  #--------------------------------------------------------------------------
  # * Create Command Window in the Credits --> CALL
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_GameEnd.new
    @command_window.set_handler(:to_title, method(:command_to_title))
  end
  
  #--------------------------------------------------------------------------
  # * [Go to Title] Command in the Credits
  #--------------------------------------------------------------------------
  def command_to_title
    @command_window.close
    fadeout_all
    SceneManager.goto(Scene_Title)
  end
end


class Window_GameEnd < Window_Command
  #--------------------------------------------------------------------------
  # * GO BACK TO THE TITLE --> ADD
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::to_title, :to_title)
  end
end

I did a script to add a Credits Option. I made its option in the menu and its destination. When i play the game,

it works like that:

 

image.png.966e87b0cde8e64f0b4fc13803b9e9ac.png

 

image.png.e663dd01b7b13f2571d223109003d573.png

 

The script is working smoothly, but i would want a scrolling image and change the window position.

Can you guys help me with my script?

 

Thanks for hearing me.

Share this post


Link to post
Share on other sites

It's interesting you did that much without knowing about x & y.

 

Under create command window you just add in the position adjustments.

@command_window.x = 0 # whatever number you want

 

@command_window.y = 0 # whatever number you want

That should adjust to the position you want.

 

Can't help you with the scrolling image. The best thing I know if move picture. You can google for a script call command if that's what  you want.

  • Thanks 1

Share this post


Link to post
Share on other sites
Posted (edited)
11 hours ago, roninator2 said:

It's interesting you did that much without knowing about x & y.

 

Under create command window you just add in the position adjustments.


@command_window.x = 0 # whatever number you want

 


@command_window.y = 0 # whatever number you want

That should adjust to the position you want.

 

Can't help you with the scrolling image. The best thing I know if move picture. You can google for a script call command if that's what  you want.

 

Thank you! It's working!

I will search about the mentioned script.

 

 

Edited by minth

Share this post


Link to post
Share on other sites
4 hours ago, minth said:

 

Thank you! It's working!

I will search about the mentioned script.

 

 

 

Ok, now, i change my script. I remove desnecessary things and change some positions. 

Instead a scrolling image, i made a scrolling text. But, now, i don't know how to add text.

I tried already put the script:  $gameMessage.add("Blah blah blah."), but it isn't working.

 

My code:

class Window_TitleCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  alias new_make_command_list make_command_list
  def make_command_list
    add_command(Vocab::new_game, :new_game)
    add_command(Vocab::continue, :continue, continue_enabled)
    add_command("Credits",       :credits)
    add_command(Vocab::shutdown, :shutdown)
  end
end



class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_TitleCommand.new
    @command_window.set_handler(:new_game, method(:command_new_game))
    @command_window.set_handler(:continue, method(:command_continue))
    @command_window.set_handler(:credits,  method(:command_credits))    
    @command_window.set_handler(:shutdown, method(:command_shutdown))
  end
  
  #-------------------------------------------------------------------
  # * [Credits] Command
  #--------------------------------------------------------------------------
  def command_credits
    close_command_window
    SceneManager.call(Scene_Credits)
  end
end



class Scene_Credits < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing --> Start windows
  #--------------------------------------------------------------------------
  def start
    super
    create_all_windows
  end
  
  #--------------------------------------------------------------------------
  # * Pre-Termination Processing --> close windows
  #--------------------------------------------------------------------------
  def pre_terminate
    Graphics.fadeout(10)
  end
  
  #--------------------------------------------------------------------------
  # * Create All Windows
  #--------------------------------------------------------------------------
  def create_all_windows
    create_scroll_text_window
    create_command_window
  end
  
  #--------------------------------------------------------------------------
  # * Create Background
  #--------------------------------------------------------------------------
  def create_background
    super
    @background_text = Sprite.new
    @background_sprite.bitmap = Cache.picture("1280x720-pastel-blue-solid-color-background")
  end
  
  #--------------------------------------------------------------------------
  # * Free Background
  #--------------------------------------------------------------------------
  def dispose_background
    @background_sprite.bitmap.dispose
    @background_sprite.dispose
  end
  
  #--------------------------------------------------------------------------
  # * Create Scrolling Message
  #--------------------------------------------------------------------------
  def create_scroll_text_window
    @scroll_text_window = Window_ScrollText.new
    @scroll_text_window.x = 240 # whatever number you want
    @scroll_text_window.y = 240 # whatever number you want
    @scroll_text_window = $gameMessage.add("Blah blah blah.")
    wait_for_message
  end
  
  #--------------------------------------------------------------------------
  # * Call Command Window in the Credits
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_GameEnd.new
    @command_window.set_handler(:to_title, method(:command_to_title))
    @command_window.x = 240 # whatever number you want
    @command_window.y = 360 # whatever number you want
  end
  
  #--------------------------------------------------------------------------
  # * [Go to Title] Command in the Credits
  #--------------------------------------------------------------------------
  def command_to_title
    fadeout_all
    SceneManager.goto(Scene_Title)
  end
end

Did i do something wrong? Help.

Share this post


Link to post
Share on other sites
On 7/7/2021 at 11:10 PM, minth said:

i would want a scrolling image

If you'd like your credits to be an image with text that is scrolled, then all you need is to just update the y position.

 

For that approach you'd need to create an another Sprite and assign the image to its bitmap (like you did with the background) and then add an update method, that will keep adjusting the Y position of that image, making it go up.

 

For example, in the Scene_Credits, you'd first add the Sprite (credits image)

  #--------------------------------------------------------------------------
  # * Create Scrolling Text
  #--------------------------------------------------------------------------
  def create_text
    @scrolling_text = Sprite.new
    @scrolling_text.bitmap = Cache.picture("CREDITS_IMAGE")
  end

and then add an update method, that is run every frame (60/sec)

  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super
    @scrolling_text.y -= 1 # to move it 1 pixel UPWARDS per frame
  end

 

That should get the job done for what it's worth. You may want to adjust the Y position in the create method, so that it starts with a blank screen while the text is just about to show up. For that set the Y position of that sprite to the HEIGHT of your game window like this:

  #--------------------------------------------------------------------------
  # * Create Scrolling Text
  #--------------------------------------------------------------------------
  def create_text
    @scrolling_text = Sprite.new
    @scrolling_text.bitmap = Cache.picture("CREDITS_IMAGE")
    @scrolling_text.y = Graphics.height
  end

 

As I was going to mention to remember to dispose the sprite, I noticed that your existing dispose method isn't run either, as it lacks its own terminate method that would point to sprite disposal, so you may want to fix that. To the Scene_Credits, also add this:

  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_background # now your dispose method will be run
    dispose_scrolling_text # for the scrolling sprite
  end

and then of course the dispose method for the scrolling text.

  #--------------------------------------------------------------------------
  # * Dispose Scrolling Text
  #--------------------------------------------------------------------------
  def dispose_scrolling_text
    @scrolling_text.bitmap.dispose
    @scrolling_text.dispose
  end

You could also just plug the two dispose lines to the existing method you have instead,  that would work too.

 

Disclaimer: My Ruby got really rusty, so I might have overlooked something or derp'd somewhere.

  • Thanks 1

Share this post


Link to post
Share on other sites
10 hours ago, Rikifive said:

If you'd like your credits to be an image with text that is scrolled, then all you need is to just update the y position.

 

For that approach you'd need to create an another Sprite and assign the image to its bitmap (like you did with the background) and then add an update method, that will keep adjusting the Y position of that image, making it go up.

 

For example, in the Scene_Credits, you'd first add the Sprite (credits image)


  #--------------------------------------------------------------------------
  # * Create Scrolling Text
  #--------------------------------------------------------------------------
  def create_text
    @scrolling_text = Sprite.new
    @scrolling_text.bitmap = Cache.picture("CREDITS_IMAGE")
  end

and then add an update method, that is run every frame (60/sec)


  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    super
    @scrolling_text.y -= 1 # to move it 1 pixel UPWARDS per frame
  end

 

That should get the job done for what it's worth. You may want to adjust the Y position in the create method, so that it starts with a blank screen while the text is just about to show up. For that set the Y position of that sprite to the HEIGHT of your game window like this:


  #--------------------------------------------------------------------------
  # * Create Scrolling Text
  #--------------------------------------------------------------------------
  def create_text
    @scrolling_text = Sprite.new
    @scrolling_text.bitmap = Cache.picture("CREDITS_IMAGE")
    @scrolling_text.y = Graphics.height
  end

 

As I was going to mention to remember to dispose the sprite, I noticed that your existing dispose method isn't run either, as it lacks its own terminate method that would point to sprite disposal, so you may want to fix that. To the Scene_Credits, also add this:


  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_background # now your dispose method will be run
    dispose_scrolling_text # for the scrolling sprite
  end

and then of course the dispose method for the scrolling text.


  #--------------------------------------------------------------------------
  # * Dispose Scrolling Text
  #--------------------------------------------------------------------------
  def dispose_scrolling_text
    @scrolling_text.bitmap.dispose
    @scrolling_text.dispose
  end

You could also just plug the two dispose lines to the existing method you have instead,  that would work too.

 

Disclaimer: My Ruby got really rusty, so I might have overlooked something or derp'd somewhere.

 

It's working! Thank you very much! I will give credits to you guys that help me!

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)

For the people that want the full script:

 

#=========================================================================
# Credits option with scrolling image.
# Made by: minth.
# Credits to: Rikifive and roninator2 for helping me.
# ---------------------------------------------------
# When you use the script, use the background with the same resolution
# of the Rpg Maker Vx Ace (544x416) or the resized Rpg Maker Vx Ace (640x480).
#=========================================================================

class Window_TitleCommand < Window_Command
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  alias new_make_command_list make_command_list
  def make_command_list
    add_command(Vocab::new_game, :new_game)
    add_command(Vocab::continue, :continue, continue_enabled)
    add_command("Credits",       :credits)
    add_command(Vocab::shutdown, :shutdown)
  end
end



class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def create_command_window
    @command_window = Window_TitleCommand.new
    @command_window.set_handler(:new_game, method(:command_new_game))
    @command_window.set_handler(:continue, method(:command_continue))
    @command_window.set_handler(:credits,  method(:command_credits))    
    @command_window.set_handler(:shutdown, method(:command_shutdown))
  end
  
  #-------------------------------------------------------------------
  # * [Credits] Command
  #--------------------------------------------------------------------------
  def command_credits
    close_command_window
    SceneManager.call(Scene_Credits)
  end
end



class Scene_Credits < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing -> Start Windows
  #--------------------------------------------------------------------------
  def start
    super
    create_all_windows
  end
  
  #--------------------------------------------------------------------------
  # * Pre-Termination Processing -> Close Windows
  #--------------------------------------------------------------------------
  def pre_terminate
    Graphics.fadeout(5) # whatever number you want
  end
  
  #--------------------------------------------------------------------------
  # * Termination Processing -> Close Scrolling Text
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_background # now your dispose method will be run
    dispose_scrolling_text # for the scrolling sprite
  end
  
  #--------------------------------------------------------------------------
  # * Dispose Scrolling Text
  #--------------------------------------------------------------------------
  def dispose_scrolling_text
    @scrolling_text.bitmap.dispose
    @scrolling_text.dispose
  end
  
  #--------------------------------------------------------------------------
  # * Create All Windows
  #--------------------------------------------------------------------------
  def create_all_windows
    create_text
    create_command_window_credits
  end
  
  #--------------------------------------------------------------------------
  # * Create Background
  #--------------------------------------------------------------------------
  def create_background
    super
    @background_text = Sprite.new
    @background_sprite.bitmap = Cache.picture("") # don't put background
  end
  
  #--------------------------------------------------------------------------
  # * Create Scrolling Text
  #--------------------------------------------------------------------------
  def create_text
    @scrolling_text = Sprite.new
    @scrolling_text.bitmap = Cache.picture("Credits_Image") # Put your Credits picture
    @scrolling_text.y = Graphics.height
  end
  
  #--------------------------------------------------------------------------
  # * Update Scrolling Text
  #--------------------------------------------------------------------------
  def update
    super
    @scrolling_text.y -= 1 # to move it 1 pixel UPWARDS per frame
    # you can change the number to change the velocity
  end
  
   #--------------------------------------------------------------------------
  # * Call Command Window in the Credits
  #--------------------------------------------------------------------------
  def create_command_window_credits
    @command_window_credits = Window_Title.new
    @command_window_credits.set_handler(:to_title, method(:command_to_title))
  end
  
  #--------------------------------------------------------------------------
  # * [Go to Title] Command in the Credits
  #--------------------------------------------------------------------------
  def command_to_title
    fadeout_all
    SceneManager.goto(Scene_Title)
  end
end


#--------------------------------------------------------------------------
# Create a window for the credits
#--------------------------------------------------------------------------
class Window_Title < Window_Command
  #--------------------------------------------------------------------------
  # * ADD "GO BACK TO THE TITLE"
  #--------------------------------------------------------------------------
  def make_command_list
    add_command(Vocab::to_title, :to_title)
  end
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    update_placement
    self.openness = 0
    open
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # * Update Window Position
  #--------------------------------------------------------------------------
  def update_placement
    self.x = (Graphics.width - width) / 2 
    self.y = (Graphics.height * 1.4 - height) / 2
  end
end

image.png.ac4f94980463d3af7bb348b8f185fcd6.png

Edited by minth

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted