- Sep 30, 2018
- 102
- 70
Hi,
i've the following repetitive code in a screen :
And there others loop with the same code (except variables of course)
Is there a way to optimize and to do a "function" that centralize the part with textbutton ?
If you have a link to the doc, i take of course.
i've the following repetitive code in a screen :
Python:
screen ui:
zorder 105
# BACKPACK
$ _var = 0
$ _xpos = 95
$ _ypos = 55
for _var in Hero.items:
# THE CODE HERE
textbutton findItemName(listOfItems, _var) xpos _xpos ypos _ypos:
action NullAction()
hovered ShowTransient("the_img", msg =findItemDescription(listOfItems , _var))
unhovered Hide("the_img")
tooltip findItemDescription(listOfItems, _var)
style "ui_button"
# SPELLS
$ _var = 0
$ _xpos = 95
$ _ypos = 315
for _var in Hero.spells:
# AND HERE
textbutton findItemName(listOfSpells, _var) xpos _xpos ypos _ypos:
action NullAction()
hovered ShowTransient("the_img", msg =findItemDescription(listOfSpells , _var))
unhovered Hide("the_img")
tooltip findItemDescription(listOfSpells, _var)
style "ui_button"
Is there a way to optimize and to do a "function" that centralize the part with textbutton ?
If you have a link to the doc, i take of course.
Last edited: