[RESOLVED][RGSS] Shorting code

Started by bigace, January 01, 2013, 08:00:55 pm

Previous topic - Next topic

bigace

January 01, 2013, 08:00:55 pm Last Edit: January 01, 2013, 09:59:22 pm by bigace
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


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

KK20

January 01, 2013, 08:34:59 pm #1 Last Edit: January 01, 2013, 08:59:29 pm by KK20

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

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

Yup :haha: works from my end as well, thank you very much as this has been killing me for long time.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.