Page 1 of 1

Get entity by unit_number

Posted: Mon Jun 12, 2017 10:05 am
by Zephir
Hi there,

is there a way to get an entity by its unit_number like:

local myentity = surface.entities[777]
or
local myentity = surface.find_entity(unit_number = 777)

Thanks in advance

Zephir

Re: Get entity by unit_number

Posted: Mon Jun 12, 2017 10:20 am
by Nexela
Nope, and it wouldn't be any faster then doing it yourself with find_entities and checking for unit_numbers.

Best thing to do would be to store the entity in your global table indexed by its unit number.

Re: Get entity by unit_number

Posted: Mon Jun 12, 2017 10:27 am
by Zephir
Thanks for the answer, I did this now, I thought this would be easier and less storage consuming.