• 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.

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

  • 15
    Posts
    3
    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?
     

    StCooler

    Mayst thou thy peace discover.
  • 9,311
    Posts
    4
    Years
    • Seen yesterday
    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.
     
  • 15
    Posts
    3
    Years
    • Seen Dec 15, 2021
    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?
     

    StCooler

    Mayst thou thy peace discover.
  • 9,311
    Posts
    4
    Years
    • Seen yesterday
    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.
     
  • 15
    Posts
    3
    Years
    • Seen Dec 15, 2021
    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.
     

    StCooler

    Mayst thou thy peace discover.
  • 9,311
    Posts
    4
    Years
    • Seen yesterday
    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