Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.80 KB | None | 0 0
  1.       cmdUse=-1
  2.       cmdRegister=-1
  3.       cmdGive=-1
  4.       cmdToss=-1
  5.       cmdRead=-1
  6.       commands=[]
  7.       # Generate command list
  8.       commands[cmdRead=commands.length]=_INTL("Read") if pbIsMail?(item)
  9.       commands[cmdUse=commands.length]=_INTL("Use") if ItemHandlers.hasOutHandler(item) || (pbIsMachine?(item) && $Trainer.party.length>0)
  10.       commands[cmdGive=commands.length]=_INTL("Give") if $Trainer.party.length>0 && !pbIsImportantItem?(item)
  11.       commands[cmdToss=commands.length]=_INTL("Toss") if !pbIsImportantItem?(item) || $DEBUG
  12.       if @bag.registeredItem==item
  13.         commands[cmdRegister=commands.length]=_INTL("Deselect")
  14.       elsif pbIsKeyItem?(item) && ItemHandlers.hasKeyItemHandler(item)
  15.         commands[cmdRegister=commands.length]=_INTL("Register")
  16.       end
  17.       commands[cmdMysteryGift=commands.length]=_INTL("Make Mystery Gift") if $DEBUG
  18.       commands[commands.length]=_INTL("Cancel")
  19.       # Show commands generated above
  20.       itemname=PBItems.getName(item) # Get item name
  21.       command=@scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
  22.       if cmdUse>=0 && command==cmdUse # Use item
  23.         ret=pbUseItem(@bag,item,@scene)
  24.         # 0=Item wasn't used; 1=Item used; 2=Close Bag to use in field
  25.         break if ret==2 # End screen
  26.         @scene.pbRefresh
  27.         next
  28.       elsif cmdRead>=0 && command==cmdRead # Read mail
  29.         pbFadeOutIn(99999){
  30.            pbDisplayMail(PokemonMail.new(item,"",""))
  31.         }
  32.       elsif cmdRegister>=0 && command==cmdRegister # Register key item
  33.         @bag.pbRegisterKeyItem(item)
  34.         @scene.pbRefresh
  35.       elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon
  36.         if $Trainer.pokemonCount==0
  37.           @scene.pbDisplay(_INTL("There is no Pokémon."))
  38.         elsif pbIsImportantItem?(item)
  39.           @scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
  40.         else
  41.           # Give item to a Pokémon
  42.           pbFadeOutIn(99999){
  43.              sscene=PokemonScreen_Scene.new
  44.              sscreen=PokemonScreen.new(sscene,$Trainer.party)
  45.              sscreen.pbPokemonGiveScreen(item)
  46.              @scene.pbRefresh
  47.           }
  48.         end
  49.       elsif cmdToss>=0 && command==cmdToss # Toss item
  50.         qty=@bag.pbQuantity(item)
  51.         helptext=_INTL("Toss out how many {1}(s)?",itemname)
  52.         qty=@scene.pbChooseNumber(helptext,qty)
  53.         if qty>0
  54.           if pbConfirm(_INTL("Is it OK to throw away {1} {2}(s)?",qty,itemname))
  55.             pbDisplay(_INTL("Threw away {1} {2}(s).",qty,itemname))
  56.             qty.times { @bag.pbDeleteItem(item) }      
  57.           end
  58.         end  
  59.       elsif cmdMysteryGift>=0 && command==cmdMysteryGift   # Export to Mystery Gift
  60.         pbCreateMysteryGift(1,item)
  61.       end
  62.     end
  63.     @scene.pbEndScene
  64.     return item
  65.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement