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

Openperipheral sensor wireless

Started by Nobilem, 09 October 2016 - 06:31 PM
Nobilem #1
Posted 09 October 2016 - 08:31 PM
Hello

I've a problem with my sensors on an instalation wich look like this :



I've a problem with the code on my computer
  1. p = peripheral.wrap("openperipheral_sensor_0")
  2. player = p.getPlayers()
  3. print(player[1].name)
The computer show me "attempt to index ? (nil value)"

So I ask you if you have an answer to code this type of config.
Lupus590 #2
Posted 10 October 2016 - 08:32 AM
which line did it error on? (the number in the error message)
do the sensors have modems?
I recall that modems only work with full blocks, so you will need a peripheral proxy (from open peripherals) with each sensor.
is there a player in range?
Sewbacca #3
Posted 10 October 2016 - 12:39 PM
I thought you have to load the ocs API first woth calling os.loadAPI('ocs/apis/sensor') and then sensor.wrap('openperipheral_sensor_0'), right?
Lyqyd #4
Posted 10 October 2016 - 03:22 PM
You're confusing OpenPeripherals and OpenCCSensors, and OCS no longer requires the use of the sensor API.
Sewbacca #5
Posted 10 October 2016 - 04:11 PM
You're confusing OpenPeripherals and OpenCCSensors, and OCS no longer requires the use of the sensor API.
Oh, thanks!
Nice, more unification!
Lyqyd #6
Posted 10 October 2016 - 05:47 PM
There's no unification planned, nor is there likely ever to be one. OpenP was forked from OCS.
Nobilem #7
Posted 10 October 2016 - 06:45 PM
My error code is line 2. But there is 14 sensors on my base. I suppose it doesn't recognize what is "openperipheral_sensor_0" (or others numbers).
When I click on the modem it show me
"openperipheral_sensor_0" connected/disconnected.
Sewbacca #8
Posted 10 October 2016 - 07:36 PM
There's no unification planned, nor is there likely ever to be one. OpenP was forked from OCS.

I meant with unification that you don't have to use sensor.wrap, just peripheral.wrap, like peripheral.wrap('monitor_0').
Dog #9
Posted 10 October 2016 - 10:02 PM
The first things that come to mind for me are the following:

1. Is the modem that is connected to the sensor turned on when you try this? (Should display "openperipheral_sensor_0" connected or something similar in chat)

2. Is getPlayers() a valid method for that sensor?
Bomb Bloke #10
Posted 11 October 2016 - 05:13 AM
2. Is getPlayers() a valid method for that sensor?

You're thinking of an attempt to call nil.
Dog #11
Posted 11 October 2016 - 05:30 AM
2. Is getPlayers() a valid method for that sensor?

You're thinking of an attempt to call nil.
I have the worst time mixing those two up (and it's not like it's that hard to tell them apart). :/ Thanks, BB :)/>