Jump to content




[lua][question]keep the time ticking


  • You cannot reply to this topic
2 replies to this topic

#1 HurdeHack

  • Members
  • 27 posts

Posted 21 October 2012 - 02: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

#2 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 21 October 2012 - 04:13 PM

Yeah, you use for loops and if statements ;p

#3 exploder

  • Members
  • 69 posts
  • LocationLatvia

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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users