• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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.

[Scripting Question] Essentials 1.18.1 - Item that show options.

  • 15
    Posts
    4
    Years
    • Seen Dec 15, 2021
    Hello everyone.

    You see ... I have an important question about scripting. I'd like to create an item that includes both PC and Pokéradar, but I can't figure out how to display options when using the item. Someone help me?
     
    If your item is well defined in the PBS file, this code should work (I didn't test it though):

    Code:
    ItemHandlers::UseFromBag.add(:YOUR_ITEM,proc { |item|
      
      cmds = ["Access PC", "Pokéradar", "Cancel"]
      c = pbMessage("Do what?", cmds, 2)
      
      if c == 0
        pbPokeCenterPC
      
      elsif c == 1
        pbUsePokeRadar
      end 
      next 1
    })

    Basically, in game, when the player uses this item from the bag, they get asked if they want to use the PC or Pokéradar, and uses the PC or the Pokéradar (or nothing) depending on their response.
     
    If your item is well defined in the PBS file, this code should work (I didn't test it though):

    Code:
    ItemHandlers::UseFromBag.add(:YOUR_ITEM,proc { |item|
      
      cmds = ["Access PC", "Pokéradar", "Cancel"]
      c = pbMessage("Do what?", cmds, 2)
      
      if c == 0
        pbPokeCenterPC
      
      elsif c == 1
        pbUsePokeRadar
      end 
      next 1
    })

    Basically, in game, when the player uses this item from the bag, they get asked if they want to use the PC or Pokéradar, and uses the PC or the Pokéradar (or nothing) depending on their response.


    It works perfectly! Thanks ... But one thing ... If I want to add another option, how do I do it?
     
    If you want another option, add a new value between "Pokéradar" and "Cancel" + a new condition in the if (which would be elsif c == 2).

    If you're asking that kind of questions, then before making a fangame, maybe you should try to learn how to script by yourself. It's OK to ask for help but you should try stuff yourself.
     
    If you want another option, add a new value between "Pokéradar" and "Cancel" + a new condition in the if (which would be elsif c == 2).

    If you're asking that kind of questions, then before making a fangame, maybe you should try to learn how to script by yourself. It's OK to ask for help but you should try stuff yourself.

    I think I am not explaining myself well ... I have tried and, secondly, what I want is that, when pressing an option, I ask you something else.
     
    If you want to ask again, use pbMessage(message, option_list).
    "message" is the message you want to display (like "what do you want?")
    and "option_list" is a list of strings enumerating the options.
    The return value is the index chosen in the option_list.
     
    Back
    Top