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.

Real Simple Script Edit (I Hope)

Hey everyone! I Have been working for an hour and a half now to figure out how to do this....  I Created a script for an Item Menu but for some reason It only opens with "ESC" But I want it to open by pressing "I" Can any of you gifted scripters figure this out?

Code:
class Scene_Map
  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
class Scene_Item
  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
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @item_window.item
      # If not a use item
      unless @item.is_a?(RPG::Item)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If it can't be used
      unless $game_party.item_can_use?(@item.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # If effect scope is an ally
      if @item.scope >= 3
        # Activate target window
        @item_window.active = false
        @target_window.x = (@item_window.index + 1) % 2 * 304
        @target_window.visible = true
        @target_window.active = true
        # Set cursor position to effect scope (single / all)
        if @item.scope == 4 || @item.scope == 6
          @target_window.index = -1
        else
          @target_window.index = 0
        end
      # If effect scope is other than an ally
      else
        # If command event ID is valid
        if @item.common_event_id > 0
          # Command event call reservation
          $game_temp.common_event_id = @item.common_event_id
          # Play item use SE
          $game_system.se_play(@item.menu_se)
          # If consumable
          if @item.consumable
            # Decrease used items by 1
            $game_party.lose_item(@item.id, 1)
            # Draw item window item
            @item_window.draw_item(@item_window.index)
          end
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
  end
end
 
Well...I kinda figured it out...

Create a common event make it parallel process with whatever switch you want...then add this code,

Code:
if Input.repeat?(Input::I)
$scene = Scene_Item.new
end

Replace the I with whatever will work. I wasn't sure what to set as the input to make the I key work, but I'm pretty sure you can figure it out. If not you'll have to find out from someone else...Sorry for not being able to help out there....

Hope this helps!

~xgamexfreakx
 
I'm not sure if the button I will work, but, to assign a menu call to a different button (when on the map) you'll have to edit Scene_Map's update method to include an if statement like so
Code:
if Input.trigger?(Input::BUTTON)
  $scene = Scene_Item.new
end
you'll have to replace BUTTON with something that works, choices are DOWN, LEFT, RIGHT, UP, A, B, C, X, Y, Z, L, R, see the manual for what keys each represents.
Or, change
if Input.trigger?(Input::B) (line 123 in the Scene_Map script
to Input.trigger?(Input::BUTTON) though that would disable calling the normal menu.
OR (best option IMO)
copy lines 123-131 and paste the copy directly underneath line 131. THEN change Input::B in the second instance to Input::BUTTON. Hope this helps. Though it might be somewhat vague
 

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