• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Item that turns on a Switch?

Kaon

Cheese Whiz
12
Posts
17
Years
    • Seen Jun 27, 2016
    Is it possible to define an item to turn a switch on when used from the bag?

    Example: Item 1 is used and it triggers Switch 32 to turn on/off.
     
    1,224
    Posts
    10
    Years
  • A simple item handler would do

    Code:
    ItemHandlers::UseInField.add(:ITEM1,proc{|item|  
       Kernel.pbMessage(_INTL("{1} used the {2}!",$Trainer.name,PBItems.getName(item)))
       $game_switches[32] = !$game_switches[32]
    })
     

    Kaon

    Cheese Whiz
    12
    Posts
    17
    Years
    • Seen Jun 27, 2016
    Ah, thanks! But how do I make it so it's indicative of whether or not that switch is on?

    Ex: "Player turned ITEM1 on!" and "Player turned ITEM1 off!"

    Also, how do I make it so it's a key item that shows the "use" option? I already defined it as "useable outside of battle" in items.txt and yet, for some reason, it has "deselect" instead of "use" in the command prompts...

    Apologies for my ignorance.
     
    Last edited:

    DeKay

    Mega Evolved
    22
    Posts
    9
    Years
    • Seen Oct 11, 2015
    Ah, thanks! But how do I make it so it's indicative of whether or not that switch is on?

    Ex: "Player turned ITEM1 on!" and "Player turned ITEM1 off!"

    Try this
    Code:
    ItemHandlers::UseInField.add(:ITEM1,proc{|item|
       state = ($game_switches[32]) ? "off" : "on"
       Kernel.pbMessage(_INTL("{1} turned {2} {3}!",$Trainer.name,PBItems.getName(item),state))
       $game_switches[32] = !$game_switches[32]   
    })
    Also, how do I make it so it's a key item that shows the "use" option? I already defined it as "useable outside of battle" in items.txt and yet, for some reason, it has "deselect" instead of "use" in the command prompts...

    Chances are that you didn't add the UseFromBag Part. (It's the top part.)
    you pretty much do the exact same thing. Except exchanging the UseInField with UseFromBag.
    (You need both. UseFromBag and UseInField.)

    Code:
    ItemHandlers::UseFromBag.add(:ITEM1,proc{|item|
       state = ($game_switches[32]) ? "off" : "on"
       Kernel.pbMessage(_INTL("{1} turned {2} {3}!",$Trainer.name,PBItems.getName(item),state))
       $game_switches[32] = !$game_switches[32]   
    })
    Or based on your Item do this instead of the above:
    Code:
    ItemHandlers::UseFromBag.add(:ITEM1,proc{|item| next [COLOR=Red]2[/COLOR]})

    The red number should be replace by your needs

    • 0 if the item was not used.
    • 1 - The item was used, and the Bag screen stays open.
    • 2 - The item was used, and the Bag screen is closed.
    • 3 - The item was used, and it was consumed.
    • 4 - The item was used, it was consumed, and the Bag screen is closed.
     
    Last edited:

    Kaon

    Cheese Whiz
    12
    Posts
    17
    Years
    • Seen Jun 27, 2016
    So, do I use both of the codes you gave? Or do I have to merge them into one somehow? I'm not quite sure how I should integrate them into PokemonItemEffects.
     

    DeKay

    Mega Evolved
    22
    Posts
    9
    Years
    • Seen Oct 11, 2015
    So, do I use both of the codes you gave? Or do I have to merge them into one somehow? I'm not quite sure how I should integrate them into PokemonItemEffects.

    Did you try reading this [https://pokemonessentials.wikia.com/wiki/Item_effects]
    It might help you.

    The UseInField part has to be put to the other UseInField Handlers and the UseFromBag part has to be put to all the other UseFromBag Handlers.
    No Idea how I should explain that, I thought it was pretty obvious.
     

    Kaon

    Cheese Whiz
    12
    Posts
    17
    Years
    • Seen Jun 27, 2016
    Oh, okay, looks like I did put it in correctly but I was a goof and totally misspelled the UseFromBag handler.

    It works like a charm, thanks!
     
    Back
    Top