How to Make Textbutton Loop from Last Item to First Item in List (solved)
Posted: Tue Jul 10, 2018 5:29 pm
Okay, so I'm making a character creator game (dressup game style) and I have a screen that allows the player to click left or right to scroll through available character options. However! Right now, the player can go from start to finish, but when they reach the end (say item 22) they have to click the back button and go through the whole list again to get to the beginning.
I've tried searching the forums for a way to make the buttons loop back to item 01 if you click > while on the last item (22), but I don't think I have the right keywords. I'm mostly coming up with a bunch of unrelated stuff. I feel like this shouldn't be too difficult, but I've reached a bit of a block in my own search. If anyone could help me out, I'd super appreciate it! Here is my code:
I've tried searching the forums for a way to make the buttons loop back to item 01 if you click > while on the last item (22), but I don't think I have the right keywords. I'm mostly coming up with a bunch of unrelated stuff. I feel like this shouldn't be too difficult, but I've reached a bit of a block in my own search. If anyone could help me out, I'd super appreciate it! Here is my code:
Code: Select all
init python:
base, hips, waist, arms, chest, face, mouth, nose, eyes, brows, ears = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 # default dressup items
base_styles_num, hips_styles_num, waist_styles_num, arms_styles_num, chest_styles_num, face_styles_num, mouth_styles_num, nose_styles_num, eyes_styles_num, brows_styles_num, ears_styles_num = 4, 3, 3, 4, 12, 12, 12, 12, 12, 12, 22 # number of styles for each dressup item
Code: Select all
frame:
xalign 1.0
xsize 1407
yfill True
hbox:
xalign 0.05
yalign 0.05
spacing 25
textbutton _("<") action SetVariable('base', max(base-1,0))
text "Base"
textbutton _(">") action SetVariable('base',min(base+1,base_styles_num))