To cut right to the chase, I have these two snippets of Lua code. One of which generates three buttons to put in a menu window:
for i=1,3,1 do
local button = Button:new()
button.minHeight = 24
button.name = i
local buttonText = Text:new()
buttonText.text = "Stage "..i
buttonText:SetAlignment(HA_CENTER, VA_CENTER)
window:AddChild(button)
button:SetStyleAuto()
button:AddChild(buttonText)
buttonText:SetStyleAuto()
SubscribeToEvent(button, "Released", "LoadStage")
end
and later on I have that event:
function LoadStage(object, eventType, eventData)
log:Write(LOG_INFO, "Loaded stage "..object.name)
end
In theory, this should result in the log mentioning βLoaded stage 1β, βLoaded stage 2β and βLoaded stage 3β when I press the appropiate button. However, it doesnβt work properly and pressing the buttons results in an βExecute Lua function failed: [string βinitβ]:61: attempt to concatenate field βnameβ (a nil value)β error in the log. Any help?