Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
VerticalSunsetIX

Decreasing variables when selling items.

Question

Basically, how would one go about decreasing a certain variable when a certain item is sold? I've worked with modifying parts of scripts in the past, but I am not sure as to how to set this up. I'm guessing that it would involve editing and adding to this part of the "Scene_Shop" script.

 

# Sell process

$game_party.gain_gold(@number_window.number * (@item.price / 2))

case @item

when RPG::Item

$game_party.lose_item(@item.id, @number_window.number)

when RPG::Weapon

$game_party.lose_weapon(@item.id, @number_window.number)

when RPG::Armor

$game_party.lose_armor(@item.id, @number_window.number)

end

 

Anyone care to offer any help? Thanks.

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

class Scene_Shop

 ITEM_ID = 1
 ITEM_TYPE = RPG::Item
 VARIABLE_ID = 1

 alias zer0_update_number update_number
 def update_number
   if Input.trigger?(Input::C) && @command_window.index == 1
  if @item.is_a?(ITEM_TYPE) && @item.id == ITEM_ID
    $game_variables[VARIABLE_ID] -= @number_window.number
  end
   end
   zer0_update_number
 end
end

 

This will make it so that it only decreases when it is SOLD, not just when you lose an item. The variable will decrease by the number of items sold, but if you want it to decrease only by one no matter how many are sold, replace the "@number_window.number" with simply "1".

Share this post


Link to post
Share on other sites
  • 0

Ah, I see. I've been working on this ABS game for three years now and hit this stumbling block while testing some quest lines that use items. Never even thought about the bug that would occur if one sold the items until now. With this, I'll be able to work that out. Thanks a million.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...