• 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!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • 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

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