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

[Question] [Code] Changing move button layout

2
Posts
3
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:

    [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
     

    Atlat

    Atlat
    63
    Posts
    4
    Years
    • Seen yesterday
    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