Wanting to adjust turret targeting priorities

Place to get help with not working mods / modding interface.
Illiander42
Filter Inserter
Filter Inserter
Posts: 530
Joined: Mon Feb 05, 2018 10:01 am
Contact:

Wanting to adjust turret targeting priorities

Post by Illiander42 »

I'm wanting to write a simple mod to let you say "this turret shoots the thing farthest away, this one shoots the thing nearest" and looking through the documentation I can't see how to do it.

Is there a mod that already does this, or is it something we can't do?

Why:

I want to set up a combined defence line where the laser turrets prioritise the stuff that stays at range (currently just spitters), and the bullet turrets take the stuff against the wall.
321freddy
Fast Inserter
Fast Inserter
Posts: 125
Joined: Fri Sep 23, 2016 10:16 pm
Contact:

Re: Wanting to adjust turret targeting priorities

Post by 321freddy »

AFAIK turrets don't have a prioritising mechanic built in, so you would have to simulate it.
You can set the shootng target of a turret using LuaEntity::shooting_target
Although I don't know how this could be used in a way that doesn't completely kill your performance.
Maybe use the events on_entity_damaged and on_entity_died with the cause parameter to script the desired behaviour.
Post Reply

Return to “Modding help”