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

Wired Peripherals?

Started by mitterdoo, 17 March 2013 - 10:12 AM
mitterdoo #1
Posted 17 March 2013 - 11:12 AM
As seen in the picture below, a monitor has text written on it without a computer besides it.


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?
OmegaVest #2
Posted 17 March 2013 - 12:20 PM
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!
mitterdoo #3
Posted 17 March 2013 - 12:45 PM
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.
OmegaVest #4
Posted 17 March 2013 - 01:02 PM
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.
Cloudy #5
Posted 17 March 2013 - 02:03 PM
Why overcomplicate things? The peripheral API works with remote peripherals fine. peripheral.getNames() returns peripherals attached.