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.

RMXP Shop Item Count [SOLVED]

Alright, I have a pretty simple question here...

Question: How can I use a variable in-game to count how many of a certain item was bought.
Example:
@What would you like to buy?
@[Glass Shard]
[Key]
[Potion]
(Player buys 10 potions, 1 Key, and 3 Glass Shards)
@Variable:10(Potions Bought) += {Number of potions bought}
@Variable:11(Keys Bought) += {Number of keys bought}
@Variable:12(Glass Shards Bought) += {Number of glass shards bought}
@End

I would like to know if there is something I can add into a script, or something...I can work with scripts, I am just not sure how I would go about this. :D I would appreciate the help, thanks!

~RadethDart
 
This will modify scene_shop to store the number bought of each item in the variable 50+@item.id (item 1 stored in variable 51)
Weapons & Armors stored in their own range.

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

# ** Modify Scene_Shop

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

#  Modify Scene_Shop to store number bought of each item in game variables

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

 

class Scene_Shop

  

  alias shop_mod_update_number update_number

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

  # * Frame Update (when quantity input window is active)

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

  def update_number

    shop_mod_update_number

    # If C button was pressed

    if Input.trigger?(Input::C)

      case @command_window.index

      when 0  # buy

        case @item

        when RPG::Item

          $game_variables[50 + @item.id] += @number_window.number        

        when RPG::Weapon

          $game_variables[100 + @item.id] += @number_window.number        

        when RPG::Armor

          $game_variables[150 + @item.id] += @number_window.number        

        end

        # Buy process

      end

      return

    end

  end

end

 

Whether or not this is the "right" way to do what you ask depends on what you intend to do with the data once you've collected it.

Be Well
 
Perfect, all I need is to use these variables to check and add to another variable for achievements. Thank you tons! You are a life-saver! ;)

EDIT: I didn't even think to look under shop....silly me! I was just in a panic! :) Thanks again!
 

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