27 posts
Posted 21 October 2012 - 03:59 PM
hello im pretty long active here but im not an pro in lua scripting well anyway my question is is it possible to keep an time ticking i mean in a code
im dutch so dont look at translate faults XD
2088 posts
Location
South Africa
Posted 21 October 2012 - 05:13 PM
Yeah, you use for loops and if statements ;p
71 posts
Location
Latvia
Posted 21 October 2012 - 05:19 PM
Yes, it is possible using a loop.
This is a basic 24 clock going on loop:
while true do – Here starts the loop
local time = os.time()
time = textutils.formatTime(time, true) – Replace true with false for 12- hour clock.
print("Time:"..time)
sleep(0.2) – We want to add sleep so computer doesn't throw error out after some time.
term.clear() – Clear screen so it's nice and clean
term.setCursorPos(1,1) – Set Cursor to starting point.
end
And this will make clock refresh every 0.2 second.