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

[solved] [openperipherals] over lan

Started by aligator123456, 04 February 2014 - 04:29 PM
aligator123456 #1
Posted 04 February 2014 - 05:29 PM
hi

How can I use OpenPeripheral over lan?
I only found a tutorial for the old system without channels:
http://www.computerc...attery-monitor/


For example I would like to read the EUCapacity of a batbox.
If I put the batbox beside the PC, I can read the data very simple. but how does this work if I conect two or more over lan/wlan

I hope someone can help me.
aligator123456
Edited on 05 February 2014 - 09:42 AM
ingie #2
Posted 04 February 2014 - 06:09 PM
attach a wired modem to the batbox, then activate it by right clicking on the modem… cable to the computer, with a modem on that too…

then the batbox, from memory, should be "batbox_0" - this should be confirmed when you right-click the modem on the batbox itself, the _0 bit changes for each modem you attach to each batbox

you can then read the capacity with peripheral.wrap("batbox_0").getEUStored() - change batbox_0 to whatever yours is called obviously.
theoriginalbit #3
Posted 04 February 2014 - 08:19 PM
in addition to what ingie stated, when you activate the modem on the batbox it will tell you its name in your chat — this is what he means by "confirmed".

it should also be noted that when you're putting any non-solid block — for example chests — onto a network as opposed to directly beside the computer you must make use of the Peripheral Proxy as well as the modem.

lastly it should also be pointed out that if you have multiple devices on a network of the same type and you wish to use them all you can generically loop through and use them all like so

for _, name in pairs(peripheral.getNames()) do
  if peripheral.getType(name) == "batbox" then
    -- it was a batbox, do what you wish with it here
  end
end
aligator123456 #4
Posted 05 February 2014 - 10:42 AM
Thank you!
it works great.

aligator123456