Get entity by unit_number

Place to get help with not working mods / modding interface.
Zephir
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Apr 21, 2017 11:32 am
Contact:

Get entity by unit_number

Post 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
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Get entity by unit_number

Post 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.
Zephir
Burner Inserter
Burner Inserter
Posts: 7
Joined: Fri Apr 21, 2017 11:32 am
Contact:

Re: Get entity by unit_number

Post by Zephir »

Thanks for the answer, I did this now, I thought this would be easier and less storage consuming.
Post Reply

Return to “Modding help”