Hello,
I’m stuck trying to accomplish something that is probably stupidly easy…
As per title of post… i have a table containing some buttons (lots more then in the code below).
…user presses one of them and code needs to load an associated image, who’s name is stored in the table together with the object (button) related to it.
Keep getting “nil” attemps
local Buttons ={
[1] = {button=display.newCircle(hor.w01,vert.h1, 20),buttonName=“PA1”,strokeWidth=1,toLoad=“p_a_1”},
[2] = {button=display.newCircle(hor.w03,vert.h1, 20),buttonName=“PA3”,strokeWidth=1,toLoad=“p_a_3”},
[3] = {button=display.newCircle(hor.w05,vert.h1, 20),buttonName=“PA5”,strokeWidth=1,toLoad=“p_a_5”}}
local function seatSelector( event )
--…do loads of stuff on the objects etc etc…
loadImageFunction (event.target.toLoad) --<---- how to access the “toLoad” string attached to the event target?
end
local function setEventListener()
for i =1 , #seatButtons do
seatButtons[i].button:addEventListener( “tap”, seatSelector )
end
end
setEventListener()
this has stomped me all day…