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

ComputerCraft Clock

Started by michaelcampbell229, 09 August 2015 - 02:50 AM
michaelcampbell229 #1
Posted 09 August 2015 - 04:50 AM
I have this code:


moniter = peripheral.wrap("back")
moniter.setTextScale(3)
while true do
sleep(0.75)
moniter.setCursorPos(1,1)
moniter.clear()
moniter.write(textutils.formatTime(os.time().true))
end
moniter.restore()


I know this code did work, i saw it on a Youtube video (it was uploaded in 2013) and i was wondering why it doesnt work anymore, or did i make a typo?
Edited on 09 August 2015 - 05:51 AM
Lyqyd #2
Posted 09 August 2015 - 06:42 AM
Moved to Ask a Pro.
HPWebcamAble #3
Posted 09 August 2015 - 07:06 AM
What happens when you run it?



I'd assume it doesn't work because of this:
(Should throw an 'attempt to index number' I believe)

moniter.write(textutils.formatTime(os.time().true))
(The arguments in question here are 'os.time()' and 'true')

Instead of a period (.), you need to use a comma (,) to separate the arguments, like this:

moniter.write(textutils.formatTime(os.time(),true))
Edited on 09 August 2015 - 05:07 AM
michaelcampbell229 #4
Posted 09 August 2015 - 08:01 AM
Thanks HPWebcamAble that fixed everything. I didnt notice the comma!

I fixed the first post so the code was in the code format, just learnt how to do it.