Deploy capsules as real follower robots?

Place to get help with not working mods / modding interface.
Post Reply
slindenau
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 25, 2016 1:46 pm
Contact:

Deploy capsules as real follower robots?

Post by slindenau »

Is it possible to deploy a destroyer capsule as actual follow robots with the API?

You can do a surface.create_entity on a "destroyer-capsule", but that just leaves them hanging in the air.
You can also make a group with surface.create_unit_group, but then you're just implementing your own follower AI (might also be fun?)

Is there a way to deploy a destroyer capsule like an actual player would by "throwing" a capsule?
My mod: "Auto Deploy Destroyers" (follower robots) viewtopic.php?f=97&t=24545

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Deploy capsules as real follower robots?

Post by Adil »

There's additional parameter field to .create_entity: target.

Code: Select all

game.player.surface.create_entity{name="defender",position=game.player.position, force=game.player.force, target=game.player.character}
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

slindenau
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 25, 2016 1:46 pm
Contact:

Re: Deploy capsules as real follower robots?

Post by slindenau »

Aha, that seems to work. If you create a capsule it spawns the 5 bots, but not as followers.
This way the single destroyer becomes a real followers...thanks!

This is what i had created myself, but like i said...it spawns 5 non follower destroyers???
/c player = game.local_player;
surface = game.surfaces.nauvis;
deployed = surface.create_entity({
name="destroyer-capsule",
amount=1,
position={player.position.x,player.position.y},
force=player.force,
source=player.character,
target=player.character,
speed=1
});
My mod: "Auto Deploy Destroyers" (follower robots) viewtopic.php?f=97&t=24545

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: Deploy capsules as real follower robots?

Post by Adil »

The target field seems not to be accessible after entity is created already.
If you want five followers, use create_entity five times.
If you want capsule projectile first, create dummy copy of that in your data lua, and use trigger_created_entity event to detect when it's time to spawn five followers. Off the top of the head, the example of trigger_created_entity can be seen in my DroneHome mod, albeit there it is used for despawning of drones.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Post Reply

Return to “Modding help”