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

[OpenPeripherals] Missing arguments for Sensor

Started by Yanniclord, 23 February 2015 - 02:10 AM
Yanniclord #1
Posted 23 February 2015 - 03:10 AM
Hello everyone. So i was putting my time into CC again, and i got very far this time with most of my programs, however one is clogging me up. Its a program for the OpenPeripheral Sensor, wich i wanted to open for specific players. Now i know this has been asked about before, but the mod updated, and it seems some stuff changed wich i cannot figure out how to fix. Firstly, here my code:
Spoilersensor = peripheral.wrap("top")
while true do
local users = {["LokeYourLord"] = true,
["Bassern"] = true}
for _, name in pairs(sensor.getPlayerByName()) do
if users[name] then
door = true
end
end
if door then
rs.setOutput("left",true)
else
rs.setOuzput("left",false)
end
sleep(1)
end

Now the problem with this one is that when i run the program, it says this: "door:5: Not enough arguments, first missing: username". I cannot figure out how to fix this, cause i came so far that i saw it changed the "getPlayerNames" to "getPlayerByName" by calling in "lua" the "peripheral.getMethods("top")", so i came that far, however i did change that as you can see in the code. What is wrong now?

Thanks in advance for the help :)/>
martmists #2
Posted 09 April 2015 - 04:27 PM
Hey,
although i am having problems with the sensor because it isnt really clear what it returns, i have found what makes your program crash.
the "getPlayerByName()" needs an username, so do: sensor.getPlayerByName(USERNAME)
I hope this helps :)/>
kukeiko #3
Posted 11 April 2015 - 01:41 AM
I think they renamed it to getPlayers to better reflect its new contents, hier a screenie with what it returns

http://i.imgur.com/n9h8IrI.png