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

Need Help With a Clock

Started by almightyantagonist, 08 November 2012 - 04:58 PM
almightyantagonist #1
Posted 08 November 2012 - 05:58 PM
ive got a computer set up a a 1x2 monitor (on the left of the computer) im trying to get it to display the time on the monitor in large numbers and update itself. my code (which i found on this website from a few months ago) thus far is:


function infiniteLoop()
while true do

local time = os.time()
time = textutils.formatTtime(time, false)
term.clear()
term.setCursorPos(1,1)
print(time)
sleep(0.8)

end
end

infiniteLoop()


the problem i am having is that it is not displaying on the monitor even when i run the program with the command "monitor left >program name<"
how can i fix this?
brett122798 #2
Posted 08 November 2012 - 06:02 PM
I don't know the codes because I have never used monitors, but you need to wrap the monitor and also print on the monitor, not on the computer's monitor.
almightyantagonist #3
Posted 08 November 2012 - 06:06 PM
I don't know the codes because I have never used monitors, but you need to wrap the monitor and also print on the monitor, not on the computer's monitor.

ok now i have:


function infiniteLoop()
while true do

mon=peripheral.wrap("left")
local time = os.time()
time = textutils.formatTtime(time, false)
term.clear()
term.setCursorPos(1,1)
mon.print(time)
sleep(0.8)

end
end

infiniteLoop()



still not working.
sjonky #4
Posted 08 November 2012 - 06:13 PM
Yeah as brett is saying you need to wrap the monitor first. so:

m = peripheral.wrap("side")
m.write("time")
Zoinky #5
Posted 08 November 2012 - 06:16 PM

mon = peripheral.wrap("left")
mon.setTextScale(3)
while true do
time = os.time()
time = textutils.formatTime(time, false)
mon.clear()
mon.setCursorPos(1,1)
mon.writeLine(time)
sleep(1)
end

You could try that. Not sure if it'll work D:
almightyantagonist #6
Posted 08 November 2012 - 06:32 PM
thanks everyone who helped me out!


added the text scale line so that the time fits perfectly with the 1x2 monitor.
the final code was as follows:

function infiniteLoop()
while true do

m = peripheral.wrap("left")
m.setTextScale(3)
local time = os.time()
time = textutils.formatTime (time, false)
mon.clear ()
mon.setCursorPos(1,1)
mon.write(time)
sleep(1)
end
end
infiniteLoop()



Thanks again!