6Square4
(Garchy)
#1
Making a chest that is claimed every 6 hours, server side works fine but I can’t make it show the remaining time. Here’s the code:
local Time = newDataValue.Inventory.Chests["Energy Orbs Chest #1"];
local secondsRemaining = os.time() - (Time - 21600);
local TimeLeft = "READY"
if secondsRemaining <= 0 then
TimeLeft = "READY";
else
TimeLeft = string.format("%02i:%02i:%02i", (secondsRemaining * 60 * 60) % 24, (secondsRemaining * 60) % 60, secondsRemaining % 60)
end
Any ideas?
RFL890
(RFL890)
#2
How frequently is this code running?
It looks like the math in your format string is a bit off. Try this:
TimeLeft = string.format("%02i:%02i:%02i", secondsRemaining / 3600, (secondsRemaining / 60) % 60, secondsRemaining % 60)
6Square4
(Garchy)
#4
Ty! There’s 1 other issue where it’s just counting up instead? I believe it’s the secondsRemaining variable this time!
6Square4
(Garchy)
#5
Runs about every 0.5-1 seconds.
6Square4
(Garchy)
#6
Solved! This is the new secondsRemaining line:
local secondsRemaining = 21600 - (os.time() - Time)
system
(system)
Closed
#7
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.