Skip to content

nanobot coding. #168

@gravestristen

Description

@gravestristen

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
  1. [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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions