[SOLVED] if/else in imagebuttons
Posted: Sun Apr 21, 2024 10:58 am
I would like to write a series of buttons that must be pressed in a certain order, but the second and subsequent buttons do not always accept the variable changed when the first button is clicked, although the clicks are processed. How could this be fixed or implemented in a different form?
Code: Select all
define mwrcount = 0
define mwround = 0
define m1 = False
define m2 = False
label mground1:
hide screen M1lvl
$ m1 = False
$ m2 = False
show screen M1lvl
"ROUND 1"
label mgokay:
"[mwrcount], [m1], [m2]"
screen M1lvl():
vbox:
xalign 0.29 yalign 0.448
imagebutton:
auto "button_%s.png"
action [SetVariable("m1", True), Jump("mgokay")]
activate_sound click
vbox:
xalign 0.41 yalign 0.56
imagebutton:
auto "button_%s.png"
if m1:
action [SetVariable("m2", True), Jump("mgokay")]
activate_sound click
else:
action [IncrementVariable("mwrcount", 1), Jump("mgwrong1")]
vbox:
xalign 0.755 yalign 0.24
imagebutton:
auto "button_%s.png"
if m1:
if m2:
action Jump("next_round")
activate_sound click
else:
action [IncrementVariable("mwrcount", 1), Jump("mgwrong1")]
else:
action [IncrementVariable("mwrcount", 1), Jump("mgwrong1")]
label mgwrong1:
"Wrong answer"
jump mground1