Page 1 of 1

Adding a flag/property

Posted: Wed Jan 10, 2018 12:46 am
by TheSAguy
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?

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
I thought I could add:
enemy.alert_when_damaged = false after "enemy.force=beacon.force"
but that did not work.

Re: Adding a flag/property

Posted: Wed Jan 10, 2018 2:15 am
by eradicator
The documentation lists alert_when_damaged as a [R]ead-only property and looking at base files one can clearly see that it needs to be added to the prototype, i.e. in data(updates, etc).lua stage. You can't add it dynamically to single units.