2 posts
Location
France
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
- p = peripheral.wrap("openperipheral_sensor_0")
- player = p.getPlayers()
- 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.
2427 posts
Location
UK
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?
463 posts
Location
Star Wars
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?
8543 posts
Posted 10 October 2016 - 03:22 PM
You're confusing OpenPeripherals and OpenCCSensors, and OCS no longer requires the use of the sensor API.
463 posts
Location
Star Wars
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!
8543 posts
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.
2 posts
Location
France
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.
463 posts
Location
Star Wars
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').
1220 posts
Location
Earth orbit
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?
7083 posts
Location
Tasmania (AU)
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.
1220 posts
Location
Earth orbit
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 :)/>