Adding a flag/property
Posted: Wed Jan 10, 2018 12:46 am
Hi,
I'd like to add the following to a unit I convert:
"alert_when_damaged = false"
How would I do that in the below code?
I thought I could add:
enemy.alert_when_damaged = false after "enemy.force=beacon.force"
but that did not work.
I'd like to add the following to a unit I convert:
"alert_when_damaged = false"
How would I do that in the below code?
Code: Select all
for i, enemy in ipairs(surface.find_enemy_units(beacon.position, global.NE_Buildings.Settings.Search_Distance)) do --search area of ten around each ACS
if enemy.force == (enemyForce) then --do only if not already controlled
if math.random(global.minds.difficulty*2)==1 then --easy = 16.5% chance, normal = 10%, hard = 5%
enemy.force=beacon.force
enemy.set_command{type=defines.command.wander,distraction=defines.distraction.by_enemy}
table.insert(global.minds, enemy)
end
end
end
enemy.alert_when_damaged = false after "enemy.force=beacon.force"
but that did not work.