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

Network Cable Help

Started by GeneralZcool, 21 December 2013 - 08:36 PM
GeneralZcool #1
Posted 21 December 2013 - 09:36 PM
Hi. I am trying to make a shop and I would like to have a computer in the back connected to a monitor in the front. I have them connected via networking cable and wired modems, but I don't know how to transfer info. I want to have the monitor be a sign with words. If you can tell me how this is possible, it would be appreciated.
Edited on 22 December 2013 - 02:21 PM
Goobster22 #2
Posted 22 December 2013 - 09:11 AM
All you have to do is put it as a peripheral

here is an example


term.clear()
term.setCursorPos(1,1)
m = peripheral.wrap("monitor_0")
x = m.getSize()
m.setCursorPos(1,1)
m.write(x)

hopefully you have used monitors before and know how to use them. So you can make the sign super amazing.

P.S. the link in your post we can't access.
gezepi #3
Posted 22 December 2013 - 12:05 PM
If you have a computer and monitor connected with networking cables and wired modems right click on the modem for the monitor. It will says something like
"monitor_1" connected
.In your program you can set up the monitor with

monitor = peripheral.wrap("monitor_1")
Note that if it said monitor_4 was connected you must put that instead of monitor_1.
Using the monitor is pretty much the same as using term (the screen on the computer):

monitor.setCursorPos(1,1,)--Sets the cursor to top left
monitor.write("This will be put on the monitor")
term.setCursorPos(1,1)
term.write("This will be put on the computer screen")

Oh, and your image didn't work. You have to host it on an image website like imgur or imageshack (is this one still around?) then use that link.
awsmazinggenius #4
Posted 22 December 2013 - 12:29 PM
Have you read the awesome wired modem tutorial?
TheOddByte #5
Posted 22 December 2013 - 01:12 PM
Well first make sure it's enabled, Right click the modem so it's red and it should pop up something like 'peripheral monitor_0 connected'
And then it's easy, You can wrap it as you do with other modems, But instead of a side you put the name of the monitor

local mon = peripheral.wrap("monitor_0")
mon.write("Hello World!")
GeneralZcool #6
Posted 22 December 2013 - 01:20 PM
If you have a computer and monitor connected with networking cables and wired modems right click on the modem for the monitor. It will says something like
"monitor_1" connected
.In your program you can set up the monitor with

monitor = peripheral.wrap("monitor_1")
Note that if it said monitor_4 was connected you must put that instead of monitor_1.
Using the monitor is pretty much the same as using term (the screen on the computer):

monitor.setCursorPos(1,1,)--Sets the cursor to top left
monitor.write("This will be put on the monitor")
term.setCursorPos(1,1)
term.write("This will be put on the computer screen")

Oh, and your image didn't work. You have to host it on an image website like imgur or imageshack (is this one still around?) then use that link.

If I wanted to write "Welcome to my shop", would I have to make a new program or could I just use the Lua thing or an already build in program?

Well first make sure it's enabled, Right click the modem so it's red and it should pop up something like 'peripheral monitor_0 connected'
And then it's easy, You can wrap it as you do with other modems, But instead of a side you put the name of the monitor

local mon = peripheral.wrap("monitor_0")
mon.write("Hello World!")

Thanks! That made it seem easier. :)/>

I did what you guys said, but it is only going on one line. Is there a way to get it to go on the next line??
rewbycraft #7
Posted 22 December 2013 - 03:34 PM
If you have a computer and monitor connected with networking cables and wired modems right click on the modem for the monitor. It will says something like
"monitor_1" connected
.In your program you can set up the monitor with

monitor = peripheral.wrap("monitor_1")
Note that if it said monitor_4 was connected you must put that instead of monitor_1.
Using the monitor is pretty much the same as using term (the screen on the computer):

monitor.setCursorPos(1,1,)--Sets the cursor to top left
monitor.write("This will be put on the monitor")
term.setCursorPos(1,1)
term.write("This will be put on the computer screen")

Oh, and your image didn't work. You have to host it on an image website like imgur or imageshack (is this one still around?) then use that link.

If I wanted to write "Welcome to my shop", would I have to make a new program or could I just use the Lua thing or an already build in program?

Well first make sure it's enabled, Right click the modem so it's red and it should pop up something like 'peripheral monitor_0 connected'
And then it's easy, You can wrap it as you do with other modems, But instead of a side you put the name of the monitor

local mon = peripheral.wrap("monitor_0")
mon.write("Hello World!")

Thanks! That made it seem easier. :)/>

I did what you guys said, but it is only going on one line. Is there a way to get it to go on the next line??

Here's how:

local mon = peripheral.wrap("monitor_0")
mon.write("Hello World!")
mon.setCursorPos(1,2)
mon.write("This is on the next line!")
mon.setCursorPos(1,3)
mon.write("This is on the third line!")

Fairly simple. Just set the cursor to the next line with mon.setCursorPos(x,y) (where x=1 means most left and y=1 means most top)
Goobster22 #8
Posted 22 December 2013 - 03:51 PM
What you have to do is change the cursor position.

Here is an example:


term.clear()
term.setCursorPos(1,1)
m = peripheral.wrap("monitor_1")
m.setCursorPos(1,1) --(x,y)
m.print("this is line 1")
m.setCursorPos(1,2)
m.print("this is line 2")
Edited on 22 December 2013 - 02:51 PM
Alice #9
Posted 22 December 2013 - 07:42 PM
print and write are different in that print writes it to nicely wrap against the monitor size but write just cuts it off mid sent
ence.
^just like that.
TheOddByte #10
Posted 23 December 2013 - 11:06 AM
There is no print function for monitors so you'll have to manually change the cursor pos, However you can create a simple print function for the monitor that changes to a new line automatically just as the regular one does

local function mPrint( text )
    local x, y = mon.getCursorPos()
    local mon_w, mon_h = mon.getSize()
    mon.write( text )
    if y < mon_h then
        mon.setCursorPos( 1, y + 1 ) -- Set the cursor pos to a new line
   else
       mon.scroll( 1 )
       mon.setCursorPos( 1, mon_h )
   end
end
Alice #11
Posted 23 December 2013 - 11:20 PM
That's not the entire functionality of the print() function, but yes, that would work.
theoriginalbit #12
Posted 23 December 2013 - 11:33 PM
That's not the entire functionality of the print() function, but yes, that would work.
Well if you want to get technical the print function doesn't do anything like it, this is the entirety of the print function

function print( ... )
  local nLinesPrinted = 0
  for n,v in ipairs( { ... } ) do
    nLinesPrinted = nLinesPrinted + write( tostring( v ) )
  end
  nLinesPrinted = nLinesPrinted + write( "\n" )
  return nLinesPrinted
end
which when simplified is this

function print( ... )
  return write( table.concat( {...} ).."\n" )
end