Jump to content




Terminal Based Clock


  • You cannot reply to this topic
1 reply to this topic

#1 Mr. Fang

  • Members
  • 82 posts

Posted 21 September 2012 - 05:10 PM

I was wondering how I could make a clock out of a Computer that would essentially update itself without me having to manually reboot the computer. Below are a couple of my ideas... but I'm not sure if they work... or if they have downsides... Please let me know if you find anything helpful.

(The code would be within the startup program)

Code #1
print(os.time)
os.reboot()

or

Code #2
shell.run("time")
os.reboot()
(I have doubts on this one, I think it'll run the program, and then not reboot the computer...

Thank you for looking!

#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 21 September 2012 - 05:19 PM

I use this function here to print the time in 12 hour format at the top right of a monitor.
local mon = peripheral.wrap("side") --change to the side the monitor is on.
local function time()
while pM do
local mX,mY = mon.getSize()
local t = os.time()
time = textutils.formatTime(t,false) --change to true for 24 hour format
mon.setCursorPos(mX-9,3)
mon.write(time)
sleep(0)
end
end
It will continually update the minecraft time on the monitor.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users