Why won't the action from my button work?
I made a list for the buttons in my startscreen, but the action won't work
Here's my init for the button
startButtons = []
startButtons.push(
play = object
x = 0
y = -2
width = 80
height = 26
size = 10
text = "Play"
sprite = "sprite39"
color = "rgb(255,161,113)"
action = function() mode = "play" end
scale = 1
end
)
And the update code
for button in startButtons
button.scale = 1
if checkRectMouseHover(button.x,button.y,button.width,button.height) then
button.color = "rgb(255,161,113)"
if mouse.press then
button.action()
end
if mouse.pressed then
button.scale = 1.1
end
else
button.color = "rgb(197,124,87)"
end
end
And then the way I called those, and the mode in the general init-function
init = function()
mode = "start"
initStartscreen()
end
I've also got this bit in the general update-function if it's relevant
if mode == "start" then
updateStartscreen()
elsif mode == "play" then
...
But the action still won't work, does anyone know why?