Weird menu bug when going up and down

So, I’ve been working on this menu system for the last little bit, basically a knock-off of the old Final Fantasy games’ menus. For the most part, it’s working fine, however I’ve been having an issue with navigating the main menu.
I’m using a cursor object (basically just a sprite with a variable attached to it named “Location”), but it’s malfunctioning a little bit. When the player presses the up button, it simply subtracts one from the variable, unless it’s at the top, where it’ll simply change the variable to the maximum amount (9) so the cursor is at the bottom. The reverse is supposed to happen when you press down, but instead it’ll go all the way to the bottom before going back to the top. I’m not sure why. It’s very similar code, but behaves very differently. I’ve been racking my brain on it for the last couple days (and doing other things to finish the menu).
If anyone has any idea on what I should change, please tell me.

May I suggest a refactored approach to what you’re doing, which should eliminate your bug in the process. The following will replace all your cursor events:

3 Likes

That’s definitely an idea. I’m still learning the system so my code is probably unnecessarily verbose, especially since I don’t know all the events yet. The use of “Trigger once” might help at the very least. Thanks for the suggestion.

Edit: Just tried out most of it, and it seems to have solved the problem. Thanks.

1 Like