• 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] What does "x ? y: z" inside the script do?

  • 85
    Posts
    7
    Years
    • Seen Nov 24, 2023
    I'm trying to do some changes to my script, but I ran into a code that has "x ? y: z" in it and I don't know what it means. Can someone please help me out?

    Example:
    Code:
    def pbRaiseHappinessAndLowerEV(pokemon,scene,ev,messages)
      h=(pokemon.happiness<255)
      e=(pokemon.ev[ev]>0)
      if !h && !e
        scene.pbDisplay(_INTL("It won't have any effect."))
        return false
      end
      if h
        pokemon.changeHappiness("evberry")
      end
      if e
        pokemon.ev[ev]-=10
        pokemon.ev[ev]=0 if pokemon.ev[ev]<0
        pokemon.calcStats
      end
      scene.pbRefresh
      scene.pbDisplay(messages[2-(h ? 0 : 1)-(e ? 0 : 2)])
      return true
    end
     
    Last edited:
    when you see that format it returns either 'y' or 'z' depending on what 'x' is equal to. for example in the pbDisplay(message) above, if 'e' or 'h' is equal to 'a value' due to how they are defined at the top, it will return 'z' and if it is 'nil' it will return 'y'
    which is why we see 'if !h && !e'
     
    when you see that format it returns either 'y' or 'z' depending on what 'x' is equal to. for example in the pbDisplay(message) above, if 'e' or 'h' is equal to 'a value' due to how they are defined at the top, it will return 'z' and if it is 'nil' it will return 'y'
    which is why we see 'if !h && !e'

    I understand. Thanks a lot!
     
    Back
    Top