Posted 24 June 2013 - 02:27 PM
Well , I am making the Swan station from LOST and I'm kinda stuck at the timer part (and the periscope but i made another post for that :D/>). Here's the code:
it just wont work. It displays 0:59 and then nothing happens.
--Swan Station Timer
term.clear()
term.setCursorPos(1,1)
m = peripheral.wrap("front")
minutes = 1
seconds = 0
function Xtimer(seconds, minutes, monitor) --a timer function
monitor.clear()
monitor.setCursorPos(3, 3)
seconds = seconds - 1
if (minutes == 0 and seconds == -1 ) then
seconds = 0
end
if(seconds < 0) then
seconds = 59
minutes = minutes - 1
elseif(seconds == 0) then
seconds = tostring(00)
end
if(seconds < 10) then
seconds = "0"..tostring(seconds)
end
monitor.write(minutes..":"..seconds)
seconds = tonumber(timer)
os.sleep(1)
end
timer = os.startTimer(60)
print("Initializing timer...")
os.sleep(1)
while(true) do
if (redstone.getInput("left") and minutes < 4) then
print("Reseting...")
end
if (minutes < 0 and seconds == 0) then
write("System Failture")
end
Xtimer(seconds, minutes, m) -- calling the timer function
end
it just wont work. It displays 0:59 and then nothing happens.