Why is this not working?
local TimeTable = {
Day = {
Calculated = 0,
Seconds = 86400
},
Hour = {
Calculated = 0,
Seconds = 3600
},
Minute = {
Calculated = 0,
Seconds = 60
},
Second = {
Calculated = 0,
Seconds = 1
}
}
table.sort(TimeTable,function(one,two) return one.Seconds < two.Seconds end)
local SecondsAvailable = 86400
for i,v in pairs (TimeTable) do
v.Calculated = math.floor(SecondsAvailable/v.Seconds)
SecondsAvailable = SecondsAvailable - (v.Calculated*v.Seconds)
print(i,":",v.Calculated)
end
OUTPUT:
Hour : 24
Minute : 0
Day : 0
Second : 0
But it Should be like:
Day : 1
Hour : 0
Minute : 0
Second : 0
