←  Ask a Pro

ComputerCraft | Programmable Computers for Minecraft

»

Wired Peripherals?

mitterdoo's Photo mitterdoo 17 Mar 2013

As seen in the picture below, a monitor has text written on it without a computer besides it.
Posted Image

How is this pulled off? I can't use
mon=peripheral.wrap("right")
mon.write("Hello, world!")
because it calls nil. I can't use
modem.callRemote("right","write","Hello, world!")
because I don't know the parameters. Can we have some editors edit the wiki so we can actually know these?But for the moment, how do I pull this off?
Quote

OmegaVest's Photo OmegaVest 17 Mar 2013

First, make sure you have "connected" the modem to the peripheral and computer. That took me a moment to figure out. Note the name it tells you, because that will become important very shortly.
Second, wrap your modem. This will reveal a list of functions, obviously.
Third, use modem.getMethodsRemote(peripheral_name).
Fourth, use callRemote(peripheral_name, function_name).

So, write would be used like this:
modem = peripheral.wrap("right")
modem.callRemote("monitor_0", "write", "Hello, World!")

Supposing the name is correct.


Also, I just noticed you can grab the names into a table using getNamesRemote. And I think there is a way to wrap them, but I'm not entirely sure how yet.


EDIT: YEP! Can wrap! Just use the remote name as the side!
Quote

mitterdoo's Photo mitterdoo 17 Mar 2013

View PostOmegaVest, on 17 March 2013 - 12:20 PM, said:

First, make sure you have "connected" the modem to the peripheral and computer. That took me a moment to figure out. Note the name it tells you, because that will become important very shortly.
Second, wrap your modem. This will reveal a list of functions, obviously.
Third, use modem.getMethodsRemote(peripheral_name).
Fourth, use callRemote(peripheral_name, function_name).

So, write would be used like this:
modem = peripheral.wrap("right")
modem.callRemote("monitor_0", "write", "Hello, World!")

Supposing the name is correct.


Also, I just noticed you can grab the names into a table using getNamesRemote. And I think there is a way to wrap them, but I'm not entirely sure how yet.


EDIT: YEP! Can wrap! Just use the remote name as the side!
Thank you very much.
Quote

OmegaVest's Photo OmegaVest 17 Mar 2013

Also, I didn't know this, so I had to look in the zip's directory, but apparently if you typ help <peripherals>, you can get their "full" apis. Make sure the peripheral is plural, ie help printers, or help modems.
Quote

Cloudy's Photo Cloudy 17 Mar 2013

Why overcomplicate things? The peripheral API works with remote peripherals fine. peripheral.getNames() returns peripherals attached.
Quote