Posted 04 April 2015 - 06:48 AM
So I've been trying to make a subway system similar to the Moscow Metro, By that I mean that there is a Display at the end of each platform that displays the current time and the time since the last train has passed, So I've been trying to write a program to do that… And thats when I got here, I don't really know how the Lua Language works so I need some help, I tried combining both a clock function and timer function in a program but only the clock apears.
m = peripheral.wrap("front")
min = 0
hrs = 0
m.clear()
m.setTextScale(2)
function updateClock(m)
while true do
mcT = os.time()
m.setCursorPos(6,1)
m.write(textutils.formatTime(mcT, true))
sleep(0.1)
end
end
updateClock(m)
function timer(m)
for sec = 0, 60, 1 do
m.setCursorPos(6,2)
m.print(min, ":", sec)
if sec == (60) then
min = min + 1
timer()
end
if min == (60) then
hrs = hrs + 1
min = 0
end
sleep (1)
end
sec = 0
end
timer(m)
if rs.getInput("back") then
min = 0
sec = 0
hrs = 0
end
This is the program that I've written so far, but it doesn't appear to work. Bassicly Im trying to get it to where the timer resets when a train passes over it using an activator rail. As mentioned before I don't reallt know the way Lua works so… I need help with this… Please…