Hey there,
I have an external module, built like this:
local M = {
var1 = "123",
var2 = "456"
}
return M
It’s included as data in every other lua file so I can always get access to it from outside like this:
print(data.var1)
so that works fine. Now I have written some code somewhere else in the app:
local table = {
{data.var1},
{data.var2}
}
functions.refreshData(table)
the last line reffers so this function:
function refreshData(targets)
if data.error\_message == nil and data.networkerror == false and dataloaded(section) == true then
for i = 1, #targets do
print(targets[i][1])
end
elseif data.error\_message == nil and data.networkerror == false and dataloaded(section) == false then
print("data not loaded")
stopTimer(myTimerNew)
myTimerNew = timer.performWithDelay(500,refreshData(targets))
end
end
as you can see I have a timer which is reloading the function refreshData() in case that the data (which the app requests in the background) is not there yet.
my problem is that the function which I pass to the table to, doesn’t seem to get the object data.var1 and data.var2 itself but already the values so everything I get printed out is always NIL. But I know that the data got updated successfully in the meantime.
how can I make a mapping to the var-obj from the data module instead of passing the values?
any help appreciated,
roman [import]uid: 140000 topic_id: 33180 reply_id: 333180[/import]