I tried to make a scenario. I messed up the force. Now I need to find all the worm turrets and set then to enemy. Any idea?
I searched in the docs but found nothing. Entity doesn't contain a field to set force, neither force is without any function to receive entity.
Editor doesn't do this neither.
How to change force for entity in editor or script?
-
- Fast Inserter
- Posts: 152
- Joined: Sun Jun 16, 2019 4:04 pm
- Contact:
Re: How to change force for entity in editor or script?
Code: Select all
/c for _,turret in pairs(game.player.surface.find_entities_filtered{type="turret"}) do if turret.name:find("worm") then turret.force = "enemy" end end
Re: How to change force for entity in editor or script?
In vanilla the extra filtering should be unnecessary - the only 'turret' prototypes in the game are the four worms. Player turrets have their own types - ammo-turret, fluid-turret, and electric-turret.
LuaEntity inherits from LuaControl, which has a Force parameter that can be set like in the code posted above - https://lua-api.factorio.com/latest/Lua ... trol.forceyagaodirac wrote: ↑Sun Jun 27, 2021 1:42 pmEntity doesn't contain a field to set force, neither force is without any function to receive entity.
-
- Fast Inserter
- Posts: 152
- Joined: Sun Jun 16, 2019 4:04 pm
- Contact:
-
- Fast Inserter
- Posts: 152
- Joined: Sun Jun 16, 2019 4:04 pm
- Contact: