Peripherals++

Peripherals++

359k Downloads

Nano Swarm

Nohicom opened this issue · 10 comments

commented

How do I call a Nano Swarm? I've thrown one into myself to try to read information about my player, but I won't work. The current code is just a test that reads what entites are connected, whether one is a player, and what the player name is.

The Code:
nano1

What Happens:
nano2

Am I calling it wrong? How do the Nano Swarms work?

commented

isPlayer() is not a function of the antenna. It is a function of the player object which can be accessed with getInfectedEntities().

commented

So how would I use that in code? Which player object do I call/how do I
find it?

On Sat, Aug 1, 2015 at 6:10 PM, grandmind [email protected] wrote:

Closed #101 #101.


Reply to this email directly or view it on GitHub
#101 (comment)
.

commented

In your example, "bots" is an array with all entities connected to the antenna through nano swarms. For each entity in this array, you can use .isPlayer() to know if it's a player or not, and then get specifically your player entity. After that, you can use player methods on this entity.
More generally, when you get stuck with a method, read the docs, and try using methods through the lua interpreter in a computer ;)

commented

I might be misunderstanding you, but I'm pretty sure that in his example, "bots" in the antenna peripheral. He can get the entities array with the getInfectedEntities() function.

commented

I understand that I would use the getInfectedEntities() somehow, but how I
go about doing that specifically?

For instance, if I wanted to test for ".isPlayer()", would I do
"bots.getInfectedEntities().isPlayer()"? how would I get the individual
entities to test/interact with?

On Sat, Aug 1, 2015 at 8:27 PM, grandmind [email protected] wrote:

I might be misunderstanding you, but I'm pretty sure that in his example,
"bots" in the antenna peripheral. He can get the entities array with the
getInfectedEntities() function.


Reply to this email directly or view it on GitHub
#101 (comment)
.

commented

The method returns an array of all the infected entities on which you can perform those functions.

commented

Yes, how? I understand that I use that method to do so, but give me a
specific example of the code I would use, within the screenshot examples,
to specifically test whether entity 77 (me) is a player?

On Sat, Aug 1, 2015 at 8:48 PM, grandmind [email protected] wrote:

The method returns an array of all the infected entities on which you can
perform those functions.


Reply to this email directly or view it on GitHub
#101 (comment)
.

commented

Um... how to access an array?
antenna.getInfectedEntities()[1].isPlayer()

commented

Alright, thank you. I was probably being exceptionally dumb today, most
likely out of lack of sleep, so thank you for all of your help and
patience. :)

On Sat, Aug 1, 2015 at 8:53 PM, grandmind [email protected] wrote:

Um... how to access an array?
antenna.getInfectedEntities()[1].isPlayer()


Reply to this email directly or view it on GitHub
#101 (comment)
.

commented

Do you mind showing the finalized code, I have the code corrected but when it comes to tostring it says too few arguments.