austinv11 / PeripheralsPlusPlus

A pseudo-port of miscperipherals, with other stuff as well!
GNU General Public License v2.0
25 stars 28 forks source link

nanobot coding. #168

Open gravestristen opened 7 years ago

gravestristen commented 7 years ago

Description

[Description of the issue] If an infected player is offline it breaks the code

Steps to Reproduce

  1. [First step]
    
    local bots = peripheral.wrap("top")
    bots.setLabel("nano") -- what does this line do?

for _, id in --[[i]]pairs(bots.getInfectedEntities()) do local currId = bots.getInfectedEntity(id)

if currId.isPlayer() then print(currId.getPlayerName()) end end


2. [Second step]
run the program and it returns with a list of infected players

**Expected behavior:** [What was supposed to happen]
when the program runs it gives a list of the infected players
**Actual behavior:** [What actually happened]
when the program runs It gives a list of infected players UNLESS they are not unline then it says entity with an id (Player's UUID) cannot be interacted with and stops the program not finishing the list
**Stacktrace (if applicable):** [PASTEBIN or HASTEBIN link to the stacktrace. Do NOT copy and paste the log into the issue post itself.]

**Version affected:** [The version of Peripherals++ *and* Forge]
Peripherals++-1.3.6, fml 7.10.99.99
### Additional Information
[Any other information that may be able to help me with the problem]
I would suggest implementing something like .isInteractable() to check if the id is interactable and return with a true/false so I could do something like:

for _, id in --[[i]]pairs(bots.getInfectedEntities()) do
  local currId = bots.getInfectedEntity(id)

  if currId.isPlayer() and currId.isInteractable() then
    print(currId.getPlayerName())