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

[HELP] Monitor connection..

Started by 1337patchy, 04 August 2012 - 08:29 PM
1337patchy #1
Posted 04 August 2012 - 10:29 PM
Hey :P/>/> I have a program that runs on startup, to display some info as follows
repeat
print("yada")
sleep(0.3)
print("lol")
x=3
until x==10

for example ;)/>/> i can use monitor front startup, but i would like the program to display into the monitor directly when the pc starts, so that i dont have to manually run the monitor after the server is restarted, so the connection to the monitor has to be inbuilt in the startup program..but why
i have this at top (before the repeat line):
local mon = peripheral.wrap("front")
if not mon then
print("error")
else
mon.clear()
end
and i tried replacing the print("yada") lines, to mon.write("yada") for example, but it only writes the first line, only executes what is before the sleep(0.3) :(/>/> Anyone can help me at this?
MysticT #2
Posted 04 August 2012 - 10:51 PM
The write function of the monitor won't move the cursor, you need to do it yourself. Or go the easy way and redirect the terminal:

local mon = peripheral.wrap("front") -- get the monitor
term.redirect(mon) -- redirect the output to the monitor
print("Hello, I'm on a monitor!") -- print some stuff to the monitor
term.restore() -- restore the output to the terminal
1337patchy #3
Posted 04 August 2012 - 11:03 PM
Thanks once again mate :P/>/>
Works as a charm!