• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Akari, Red, Kris, May - which Pokémon protagonist is your favorite? Let us know by voting in our semifinal favorite protagonist 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.

[Question] [Code] Changing move button layout

  • 14
    Posts
    4
    Years
    Hello,
    I've been making a custom battle UI and decided to change the move button layout; my only issue is that when moving the cursor, it stops at the fourth slot even when I have less than 4 moves. For some reason I can't wrap my mind around how to properly program it so that it stops at the last available move.

    Here is my layout:

    [PokeCommunity.com] [Code] Changing move button layout

    Here is my current code:

    Ruby:
    oldIndex = cw.index
          pbUpdate(cw)
          if Input.trigger?(Input::LEFT)
            cw.index -= 1 if cw.index != 0
          elsif Input.trigger?(Input::RIGHT)
            cw.index += 1 if cw.index != 3
          end
     
    cw.index += 1 if cw.index != 3

    That 3 is a problem because that means it ends on the fourth move no matter what. If it was set to 2 for example, you wouldn't be able to move past the third move. Essentially, that 3 needs to be changed to the number of moves the Pokémon has - 1 (or better yet, do something like cw.index < #moves-1 as that's more flexible in my eyes).
     
    Back
    Top