local odliczanie_por_roku
local czas=0
local x=2
local czastimera=0
local jedynkowiec=0
Poryroku = Timer.new(1000, 13)
Poryroku:addEventListener(Event.TIMER, function(e)
local czas = dataSaver.loadValue("|D|somevalue")
czas=czas+jedynkowiec
czastimera=Poryroku:getCurrentCount()
jedynkowiec=czastimera/czastimera
dataSaver.saveValue("|D|somevalue", czas)
print("TIMER", Poryroku:getCurrentCount())
print("czas",czas)
end)
Poryroku:start()
--------------------------------------------------------------------------------
why when I'm changing "somevalue" to something else, gideros says :
main.lua:9: attempt to perform arithmetic on local 'czas' (a nil value)
stack traceback:
main.lua:9: in function
Comments
local czas = dataSaver.loadValue("|D|somevalue")
juts omit 'local'.
i don't know if this helps in any way though.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
try this:
...
local czas = dataSaver.loadValue("|D|somevalue")
-- add this lines
if czas == nil then
czas = 0
end
...
so you need to check if czas is nil and make it 0
Likes: Jacko
simplest way to deal with that is default values using or
Likes: ar2rsawseen, Jacko, MoKaLux
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps