Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: bigace on January 01, 2013, 08:00:55 pm

Title: [RESOLVED][RGSS] Shorting code
Post by: bigace on January 01, 2013, 08:00:55 pm
Okay so I was writing my script to day, which I've finish except for this part, and then I got stuck so I left it until the end. Well it's the end and now I need help and this is the question. While I was writing my shop base script I've notice that this appears multiple times:

		case item
when RPG::Item then number = $game_party.item_number(item.id)
when RPG::Weapon then number = $game_party.weapon_number(item.id)
when RPG::Armor then number = $game_party.armor_number(item.id)
end


I tried simplifing it by applying it to Game_Party like in VX but I ran into several issues. In the buy part, number in possesion # doesn't increase. In the sell part, it doesn't display of items you have. When selling the item, you can't increase amount of items to be sold. Besides this set back the script is pretty much done.

Here an example of what I'm talking about.

Simple Script (http://db.tt/BjkM9rCQ)
Title: Re: [RGSS] Shorting code
Post by: KK20 on January 01, 2013, 08:34:59 pm

alias :ace_shopbase_item_number :item_number unless $@
def item_number(*args)
 item = *args
 case item
 when RPG::Item then number = ace_shopbase_item_number(item.id)
 when RPG::Weapon then number = weapon_number(item.id)
 when RPG::Armor then number = armor_number(item.id)
 end
 return ace_shopbase_item_number(*args)
end

This needs to be fixed.

EDIT: This worked fine for me.
alias ace_shopbase_item_number item_number
def item_number(item)
    if item.is_a?(Integer)
      return ace_shopbase_item_number(item)
    else
      case item
      when RPG::Item then number = ace_shopbase_item_number(item.id)
      when RPG::Weapon then number = weapon_number(item.id)
      when RPG::Armor then number = armor_number(item.id)
      end
      return number
    end
end
Title: Re: [RGSS] Shorting code
Post by: bigace on January 01, 2013, 09:58:45 pm
Yup :haha: works from my end as well, thank you very much as this has been killing me for long time.