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
[lua][question]keep the time ticking
Started by HurdeHack, Oct 21 2012 02:59 PM
2 replies to this topic
#1
Posted 21 October 2012 - 02:59 PM
#2
Posted 21 October 2012 - 04:13 PM
Yeah, you use for loops and if statements ;p
#3
Posted 21 October 2012 - 04: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.
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.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











