3 posts
Posted 16 December 2012 - 12:01 AM
hello
i am new to computer craft and want to make a ingame clock with monitors.
i found this code, and put into a program called "clock", then a write monitor right clock(got my monitor on the right) and get this error: "textutils:30: attempt to compare function with number"
function infiniteLoop()
while true do
local time = os.time()
time = textutils.formatTime(time, false)
term.clear()
term.setCursorPos(1,1)
print(time)
sleep(0.8)
end
end
infiniteLoop()
2088 posts
Location
South Africa
Posted 16 December 2012 - 12:15 AM
Just use this:
Will print on computer terminal and monitor
monitorSide = "right"
mon = peripheral.wrap(monitorSide)
while true do
term.clear()
term.setCursorPos(1,1)
mon.clear()
mon.setCursorPos(1,1)
print( textutils.formatTime( os.time() , false ) )
mon.write( textutils.formatTime( os.time() , false ) )
sleep(0.8)
end
7508 posts
Location
Australia
Posted 16 December 2012 - 12:41 AM
Just use this:
Will print on computer terminal and monitor
monitorSide = "right"
mon = peripheral.wrap(monitorSide)
while true do
term.clear()
term.setCursorPos(1,1)
mon.clear()
mon.setCursorPos(1,1)
print( textutils.formatTime( os.time() , false ) )
mon.write( textutils.formatTime( os.time() , false ) )
sleep(0.8)
end
term.clear() and term.setCursorPos(1,1) arent required…
3 posts
Posted 16 December 2012 - 12:45 AM
Just use this:
Will print on computer terminal and monitor
monitorSide = "right"
mon = peripheral.wrap(monitorSide)
while true do
term.clear()
term.setCursorPos(1,1)
mon.clear()
mon.setCursorPos(1,1)
print( textutils.formatTime( os.time() , false ) )
mon.write( textutils.formatTime( os.time() , false ) )
sleep(0.8)
end
thanks, but i wrote it, and comes with this error: "bios:338: [string "clock"]:8: '=' expected"
the program is called clock
7508 posts
Location
Australia
Posted 16 December 2012 - 12:59 AM
works fine for me…
also i suggest making the sleep no bigger than 0.4 or you will skip numbers sometimes as the computer never starts at the perfect time. (I've experimented till i found the right number)
the program is called clock
the error tells us this…