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

How to put programs on monitor?

Started by smurfofiel, 27 January 2013 - 02:03 AM
smurfofiel #1
Posted 27 January 2013 - 03:03 AM
I have searched for it a bit, but i cant find anything about how to put tekst on a monitor. I am kinda noobish on this forum so maybe that's why i cant find it. Can someone post a link to a tutorial or make a piece of code with explenation for me please? and sorry for my bad english
Engineer #2
Posted 27 January 2013 - 04:30 AM
First you need to wrap the monitor to yourcomputer:

local m = peripheral.wrap("side")

m can be anything you want and side has to be: top, bottom, front, back, left and right.

So I want that my moniter prints hello world:

local m = peripheral.wrap("top")
m.write("hello world") -- print is in this case unavailable as far as I know

So let's say we want the user to input the side:

while true do
term.clear()
term.setCursorPos(1,1)
print("Side of the monitor: ")
monRead = lower.string(read()) -- lowers the string so it always hit a statement
if monRead == "top" or monRead == "bottom" or monRead == "front" or monRead == "back" or monRead == "left" or monRead == "right" then
local side = monRead
break
end
end

local m = peripheral.wrap(side)
m.write("Hello world")

This loop will not stop until it hits one of the conditions.
I know this from the wiki. If you need more help, post it :)/>