what is shooting_target?
and what does he do?
how to target a specific type or object?
https://lua-api.factorio.com/latest/Lua ... ing_target
shooting target
Re: shooting target
It looks like it should return at what the turret is currently shooting (if called with nothing), but can be called with a different LuaEntity to make it change target.
I have mods! I guess!
Link
Link
Re: shooting target
well he turns to LuaEntity. But how can I ask him to shoot at the target I want, and ignore everything else? I give him food shooting_target = "tank" and he ignores the recipe, shoots everything that is the enemy
P.S.Sorry, I'm using Google translator)
Re: shooting target
The target has to be a specific entity that has to be in range of the turret. Something like this would work:
Code: Select all
local targets = turret.surface.find_entities_filtered{
type = "car",
name = "tank",
position = turret.position,
radius = turret.prototype.turret_range
}
for _, t in pairs(targets) do
if t.valid and t.force ~= turret.force then
turret.shooting_target = t
break
end
end
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Re: shooting target
Thank you very much, the code itself does not work. I had to change it and a miracle started. I couldn’t check the current function itself (since I need an enemy on the tank) I will be able to check it) thanksPi-C wrote: ↑Thu Mar 19, 2020 5:12 pmThe target has to be a specific entity that has to be in range of the turret. Something like this would work:I think it's not possible to order a turret to shoot only at certain entity types, so after the turret has killed the target, it will automatically look for a new target, which may be any entity belonging to an enemy force.Code: Select all
local targets = turret.surface.find_entities_filtered{ type = "car", name = "tank", position = turret.position, radius = turret.prototype.turret_range } for _, t in pairs(targets) do if t.valid and t.force ~= turret.force then turret.shooting_target = t break end end