
How to make a variable reset to one after reaching the maximum number?
I'm making a dress up game. You press a left or right arrow to change your fairy wings. The left arrow decreases the variable by one, the right arrow increases by one. The variable number determines which wings are shown in game.
This is the screen code that makes the arrows work.
screen wings_category_screen():
add "nf_dressup/menu/menu_wings_border.png"
# Wing Buttons
imagebutton:
idle "wings_arrow_for"
hover "wings_arrow_for_h"
focus_mask True
action [SetVariable("nf_current_wings", nf_current_wings + 1)] # add 1 to variable each click
imagebutton:
idle "wings_arrow_back"
hover "wings_arrow_back_h"
focus_mask True
action [SetVariable("nf_current_wings", nf_current_wings - 1)] # minus 1 to variable each click
The wings are then shown using an elif statement. (Maybe inefficient)
screen nf_character_wings ():
if nf_current_wings == 1:
add "nf_wings1"
elif nf_current_wings == 2:
add "nf_wings2"
elif nf_current_wings == 3:
add "nf_wings3"
elif nf_current_wings == 4:
add "nf_wings4"
elif nf_current_wings == 5:
add "nf_wings5"
elif nf_current_wings == 6:
add "nf_wings6"
elif nf_current_wings == 7:
add "nf_wings7"
elif nf_current_wings == 8:
add "nf_wings8"
elif nf_current_wings == 9:
add "nf_wings9"
elif nf_current_wings == 10:
add "nf_wings10"
else:
pass
This works fine, until I want the variable to reset to 1. I tried adding this to my elif statement:
elif nf_current_wings == 11:
$ nf_current_wings = 1
But then the variable gets stuck at 1 and cannot change when the arrows are clicked anymore. How do I get my variable to reset to one, so my wings options can "loop" around to the beginning? I want my maximum variable to be 11. Once 11 is reached, it resets to 1.