Hi defolders,
I’m trying to track player’s streak in a game using
os.date( "%d" )
but something unusual happens or at least it is unusual to me haha.
if I do:
(let’s asume for this example today is June 18)
local today = os.date( "%d" ) -- 18
local streak = 0
if today == 18 then
streak = streak + 1
end
print(streak) -- 0
Defold doesn’t make the comparison. The only way I can get Defold to do the comparison in the expected way is this way:
local today =tonumber( os.date( "%d" )) -- 18
local streak = 0
if today == 18 then
streak = streak + 1
end
print(streak) -- 1
Can anyone tell me why is that? When I use
hour = os.date( "%H" )
I can perform comparisons with the hour without the need of tonumber().
I would really appreciate some light in the matter.
Cheers.