Page 1 of 1

Custom atributes

Posted: Fri Feb 14, 2020 1:41 pm
by Diamonde123
Hello,
I want to make a vehicle that releases drones when enemy is near. I wanted to add special inventory for drones.

Code: Select all

	if ent.name == "sf-reaver" and not ent.scarabey then
		ent.scarabey=0
	end
it says

Code: Select all

LuaEntity doesn't contain key scarabey.
How to add a new atribute?

Re: Custom atributes

Posted: Fri Feb 14, 2020 3:14 pm
by darkfrei
Store it in global table:

Code: Select all

if not global.vehicles then
  global.vehicles = {}
end
global.vehicles[entity.unit_number] = {entity=entity, scarabey=scarabey}
Then you can call it from global table:

Code: Select all

local scarabey = global.vehicles[entity.unit_number].scarabey
https://lua-api.factorio.com/latest/Lua ... nit_number

Re: Custom atributes

Posted: Fri Feb 14, 2020 3:39 pm
by Diamonde123
Thanks