This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Mr. Fang's profile picture

Terminal Based Clock

Started by Mr. Fang, 21 September 2012 - 04:10 PM
Mr. Fang #1
Posted 21 September 2012 - 06: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!
Cranium #2
Posted 21 September 2012 - 06: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.