Multiple actions for an imagebutton

Cenc

Well-Known Member
Game Developer
Jun 22, 2019
1,615
2,818
Hey all,

Been messing with this for some time now, I know you cannot have more than 1 action listed, however I am wondering if there is a way to do the following:

I have several screen overlays that when clicked will toggle to show more imagebuttons, id like to have the first imagebutton act as a 'master' in that it will clear all the imagebuttons that have been created.

my code as follows:

Python:
init python:
    idir = "images/overlay/"
    showMenu_items = False


screen interface():
    $ ShowHide = idir + "showhide.png"
    $ ShowHide_h = idir + "showhide_h.png"
    $ rel_select = False

    imagebutton:
        idle ShowHide
        hover ShowHide_h
        action [ToggleVariable("showMenu_items")]
#       i need something here to do the next line
#        action ToggleScreen("rel_select")
        focus_mask True
        pos (5, 2)

    if showMenu_items:
        use blah blah
        use blah blah
the commented out part is what ive been messing with, ive tried ' and ' , ive also tried:

Python:
IF rel_select:
    action ToggleScreen("rel_select")
else:
    action [ToggleVariable("showMenu_items")]
but computer says no. I'm probably missing something simple (normally am) so any help / advice / copy + paste would be appreciated.

Thanks
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,783
try this, but you also have to toggle the var rel_select within the screen interface somewhere because its a local screen variable.
Python:
screen interface():
    default ShowHide = idir + "showhide.png"
    default ShowHide_h = idir + "showhide_h.png"
    default rel_select = False

    imagebutton:
        idle ShowHide
        hover ShowHide_h
        action (ToggleScreen("rel_select") if rel_select else ToggleVariable("showMenu_items"))
        focus_mask True
        pos (5, 2)

    if showMenu_items:
        use blah blah
        use blah blah
 

Cenc

Well-Known Member
Game Developer
Jun 22, 2019
1,615
2,818
Thanks for the response.

Unfortunately I have the variable rel_select being toggled in another screen. but I managed a work around by having the additional imagebuttons on a timer.

which works :)
 

the66

beware, the germans are cumming
Modder
Donor
Respected User
Jan 27, 2017
7,667
23,783
then remove the default rel_select statement and the global variable rel_select is used.
and btw you can use the screen language statement action If(rel_select, ToggleScreen("rel_select"), ToggleVariable("showMenu_items")).