Created
November 15, 2012 23:53
-
-
Save SQReder/4082519 to your computer and use it in GitHub Desktop.
Script: countdown3.lua:21: attempt to perform arithmetic on a nil value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROPERTIES = {year=0, month=0, day=0, hour=0, min=0, sec=0, fintext=""} | |
function Initialize() | |
RELEASEDATE = {} | |
setmetatable(RELEASEDATE, getmetatable(PROPERTIES)) | |
for k,v in pairs(PROPERTIES) do | |
if k ~= fintext then | |
RELEASEDATE[k] = v | |
end | |
end | |
RELEASEDATE.isdst = true | |
RELEASETEXT = PROPERTIES.fintext or "" | |
end | |
function GetTimeLeft() | |
local dif = os.time(RELEASEDATE) - os.time() | |
local timeleft = { | |
[1] = math.floor((dif/60/60+4)/24), --day, change the -7 to whatever you need depending on your location compared to iceland. Hour difference + or - | |
[2] = math.floor(dif/60/60+4)%24, --hour, change the -7 to whatever you need depending on your location compared to iceland. Hour difference + or - | |
[3] = math.floor(dif/60)%60, --minute | |
[4] = math.floor(dif)%60 --second | |
} | |
local text = {} | |
for i=1, #timeleft do | |
if i == 1 then | |
if timeleft[i] > 0 then | |
table.insert(text,timeleft[i]) | |
end | |
else | |
table.insert(text,timeleft[i]) | |
end | |
end | |
if dif <= 0 then | |
text = RELEASETEXT | |
else | |
text = table.concat(text,":") | |
end | |
return tostring(text) | |
end | |
function Update() | |
end | |
function GetStringValue() | |
return GetTimeLeft() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment