OpenMods / OpenPeripheral

https://openmods.info
MIT License
67 stars 25 forks source link

OpenPeripheral Sensor Block Range Inconsistancy #183

Closed wheelerchristopherg closed 8 years ago

wheelerchristopherg commented 10 years ago

I was trying to sense data from players in the range of a sensor block but when I moved to a certain point, the getPlayerData() function could not get my data even though getPlayerName() was able to see that I was there.

I have CC 1.6.3, OpenModsLib 0.5.1, OpenPeripheral Core 0.4.1, OpenPeripheral Addons 0.1.5, and Forge 9.11.1.965 installed for Minecraft 1.6.4.

Steps to reproduce: First, run this code on a computer in game with a wrapped sensor block:

-- wrap any sensor, this one is on a wired modem system
local p = peripheral.wrap("openperipheral_sensor_0")
local players = {}

while true do
  if p.getPlayerNames()[1] ~= nil then
    players = p.getPlayerData(p.getPlayerNames()[1])
    print(players["username"])
  end
  sleep(.5)
end

Second, walk around along the outside of the sensors range until the program crashes. It should give the error "Entity not found."

Since it was able to see the players name, it should have been able to acquire the rest of the players data. I think this is just a simple range discrepancy.

lyqyd commented 10 years ago

Those functions yield internally, so there may be enough time between the calls for you to leave the range of the sensor.

wheelerchristopherg commented 10 years ago

It happens standing still too, if your standing in the right spot

boq commented 8 years ago

Fixed some time ago in OpenMods/OpenPeripheral-Addons@51614ff017a174f3f7918f03375b3dd598716c36