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

[Question] trouble with displaying time

Started by Oneredweasel, 26 November 2012 - 06:17 AM
Oneredweasel #1
Posted 26 November 2012 - 07:17 AM
Ok, firstly I'm a complete noob to CC and Lua so if I'm making a really obvious mistake cut me a little slack.

Anyway what I want to do is fairly simple: have a monitor that displays a short message and the time. Displaying my message was easy but adding in the time is confusing me. This is the program I have now (named "Text"):

term.clear
term.setCursorPos(5, 3)
nTime == os.time()
print ("Welcome Player")\(
print ("The time is "..textutils.formatTime ( nTime, false))

every time i try to run this I get this error code; bios:206: [string "text"]:2: '=' expected
it says to add an = sign but I don't think I need one anywhere it's really anoying

also will I need some sort of loop to refresh the time and keep it updated (I'll be displaying all this on a big monitor)
thanks!
Kingdaro #2
Posted 26 November 2012 - 07:18 AM
On the first line, there should be () after term.clear.

Also, on line 4, that ( probably shouldn't be there.
JoshhT #3
Posted 26 November 2012 - 10:28 PM
Kingdaro pointed out two errors.
I also spotted this.

nTime == os.time()

Should be

nTime = os.time()
Oneredweasel #4
Posted 27 November 2012 - 12:14 AM
THANKS! that was a quick response and this has been bothering me to no end, all I had to do was add that () and then turn the == on line 3 into a =.
p.s. the \( on line 4 was just a typo, my actual program didn't have that