The buyItem function is supposed to be called only when the textbutton is clicked, but somehow the textbutton's action is triggered automatically the moment the screen is shown, even though the textbutton was never clicked.
I know for certain that the function was called because some variables that I watch in the debug console changed in value when the screen is called.
The screen is shown using the call screen statement:
Code: Select all
call screen test
Code: Select all
screen test:
add "#000"
modal True
default button_caption = "Buy"
vbox:
textbutton "[button_caption]" action [SetScreenVariable("button_caption","Bought"),buyItem(shopping_item_code, 20)]
textbutton "Back" action [Hide("test"),Return]
Code: Select all
init python:
def buyItem(itemCode, itemCost):
#change some variable values