timer.performWithDelay(.....) no id and nil?

Hi All,

I am trying to store the ID of a timer in a scene wide variable so I can cancel it when the scene changes - sounds easy but all I’m seeing is a nil value error

local t1; -- Set at the top of the file --237 lines later in a scene:show() function t1 = timer.performWithDelay(1000, initialWelcomeBubble); timerTable:insert(t1); -- \<-- ERROR on this line. Why is t1 not available to be set?

Any thoughts?

Hi,

Not sure if the “timerTable” is some type of module, but generally you would use:

table.insert(timerTable, t1)

To insert a value into a table.

-dev

Thanks Develephant, that’s removed the error - still need to assess if that’s loaded into the timerTable but do you know why timerTable:insert(…) failed and table.insert(table, val) worked?

Any thoughts as to why this doesn’t work:

for v in timerTable do if v.expired == false then timer.cancel(v); end end

This code is fired in the scene:hide() / will hide section.

It might help for us to see how you’re creating timerTable.

Rob

Like this, at the top of the lua file:

local timerTable = {};

Hi,

Not sure if the “timerTable” is some type of module, but generally you would use:

table.insert(timerTable, t1)

To insert a value into a table.

-dev

Thanks Develephant, that’s removed the error - still need to assess if that’s loaded into the timerTable but do you know why timerTable:insert(…) failed and table.insert(table, val) worked?

Any thoughts as to why this doesn’t work:

for v in timerTable do if v.expired == false then timer.cancel(v); end end

This code is fired in the scene:hide() / will hide section.

It might help for us to see how you’re creating timerTable.

Rob

Like this, at the top of the lua file:

local timerTable = {};