Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Press Button for Inventory

Wassup.

I'm trying to make a horror game in RMXP, and the only menu I want availible Inventory, so I created a common event that ran parallel and was like such:

Conditional Branch- Button 'B' is pressed:
>Call Script "$call Window_Item"
end

As you can tell I have absolutely no scripting knowledge and just winged it to see if by some miracle that's actually how it's done. Surprisingly, it is not.

So how could I do this, or what should my Call Script say? Also, if I do this and the player hits back to exit the inventory, will it take him to the menu or back to the game? I don't want the regular menu to be accessible, only the inventory screen.

Thanks in advance.
 
Use Call Script: $scene = Scene_Item.new

To make sure you don't go back to the original menu when you try to exit the item menu, in the Scene_Item script, find:
Code:
  def update_item

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to menu screen

      $scene = Scene_Menu.new(0)

      return

    end

 

and change it to:

Code:
  def update_item

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Return to map

      $scene = Scene_Map.new

      return

    end

 

That should THEORETICALLY work
 

Ares

Member

You can also eliminate the need of using a parallel process, and edit the following lines in Scene_Map (line 215):
[rgss]# Switch to menu screen
$scene = Scene_Menu.new
[/rgss]
to
[rgss]#Switch to item screen
$scene = Scene_Item.new
[/rgss]
 
Ares":1oi1hy2x said:
You can also eliminate the need of using a parallel process, and edit the following lines in Scene_Map (line 215):
[rgss]# Switch to menu screen
$scene = Scene_Menu.new
[/rgss]
to
[rgss]#Switch to item screen
$scene = Scene_Item.new
[/rgss]
Thanks to you as well! I need to learn basic scripting.

Also, just a newbie scripting question, but what does .new after the scenes do? Is it just mandatory or what?
 
Well, I was browsing around and I though I might as well answer this! In the help file, it says "Creates a class instance and returns it." Basically what it does in simple terms is make an object of a class.

Example:

$scene = Scene_Menu.new

$scene is simply a global variable so that you can access this wherever. Scene_Menu.new allows a new object of the Scene_Menu class (Look in your script editor for scene_menu) to be initiated. It uses all the functions and variables defined in that class.

Also, if you just want one script for this script request it would look like this:

Code:
#==============================================================================

# ** Scene_Map

#------------------------------------------------------------------------------

#  This class performs map screen processing.

#==============================================================================

 

class Scene_Map

  #--------------------------------------------------------------------------

  # * Menu Call

  #--------------------------------------------------------------------------

  def call_menu

    # Clear menu call flag

    $game_temp.menu_calling = false

    # If menu beep flag is set

    if $game_temp.menu_beep

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # Clear menu beep flag

      $game_temp.menu_beep = false

    end

    # Straighten player position

    $game_player.straighten

    # Switch to menu screen

    $scene = Scene_Item.new

  end

end

 

#==============================================================================

# ** Scene_Item

#------------------------------------------------------------------------------

#  This class performs item screen processing.

#==============================================================================

 

class Scene_Item

  #--------------------------------------------------------------------------

  # * Alias Listing

  #--------------------------------------------------------------------------

  alias scripter_item_update_item update_item

  #--------------------------------------------------------------------------

  # * Frame Update (when item window is active)

  #--------------------------------------------------------------------------

  def update_item

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to menu screen

      $scene = Scene_Map.new

      return

    end

    scripter_item_update_item

  end

end


(Its plug-n-play)

Regardless, in this script, there's stuff that says Scene_Map.new, Scene_Item.new, it all ties in with the explanation I gave. Do you get it or did I ramble on too much lol
 

Ares

Member

Well, if you use that script and press F12 to restart the game you get a SystemStack Error, because it tries to alias an already aliased method, causing the game to crash. So if you want to be safe, change:
[rgss]alias scripter_item_update_item update_item
[/rgss]
to:
[rgss]alias scripter_item_update_item update_item unless Scene_Map.private_methods.include?("scripter_item_update_item")
[/rgss]

Which prevents the interpreter to alias a method if it is already aliased.
 

Atoa

Member

aliasese aren't removed only if you alias a method that don't exist on the class, but exist in the parent class.

Like Game_Player and Game_Character
Game_Character have 'def initialize' but Game_Player don't.
If you do something like

Code:
class Game_Player < Game_Character

  alias initialize_old initialize

  def initialize

    initialize_old

    # changes

  end

end
It will work, but you will get an stack error when press F12, because the initialize belongs originally to the parent class, so the corret way to do this would be using an super.

This may also happen with some of the hidden methods, like Bitmap.draw_text, since we don't know how it was originally written we can't say for sure how they behave.

Otherwise, there's no risk of getting an stack error by pressing F12 when using alias and adding these conditions for alias would be redundant.
 
Ah, okay, thanks for clearing that up Atoa, I didn't know about that, lots of helpful information you got there! So basically it's completely safe to use aliases without getting the System Stack Error, as long as its on a preexisting method within the class and not on the parent class or a method that's not even there. Thanks!
 

Atoa

Member

@Pokémaniac
There's many ways to solve that, but like i said, it's redundant. From my experieces, the only method i know that really needs this fix is the Bitmap.draw_text.
Most of the scripts that returns stack errors when press F12 is becaus of what i said.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top