self.surface.find_entities{self.pos-{10,10},self.pos+{10,10}} works.
self.surface.find_units {area= {self.pos-{10,10},self.pos+{10,10}},force="player",condition="same"} doesn't.
And some eneity even return a "userdata" when I look into its .force.name
code:
local result = self.surface.find_units {area= {self.pos-{10,10},self.pos+{10,10}},force="player",condition="all"}
log(serpent.block(#result))
for k,v in pairs(result) do
log(k)
log(serpent.block(v))
log(serpent.block(v.name))
log(serpent.block(v.force.name))
end
[1.1.5] surface.find_units function doesn't work at all.
-
- Fast Inserter
- Posts: 152
- Joined: Sun Jun 16, 2019 4:04 pm
- Contact:
Re: [1.1.5] surface.find_units function doesn't work at all.
What kind of units are you looking for?
Can you provide a screenshot of the test setup?
Can you provide a screenshot of the test setup?
-
- Fast Inserter
- Posts: 152
- Joined: Sun Jun 16, 2019 4:04 pm
- Contact:
Re: [1.1.5] surface.find_units function doesn't work at all.
Characters aren't units. They're, well, `character`s.
`find_units` specifically looks for entities of type `unit`, not of type `character`.
`find_units` specifically looks for entities of type `unit`, not of type `character`.
-
- Fast Inserter
- Posts: 152
- Joined: Sun Jun 16, 2019 4:04 pm
- Contact:
Re: [1.1.5] surface.find_units function doesn't work at all.
If you want to search only for player you can use the find entity filtered variant:
https://lua-api.factorio.com/latest/Lua ... s_filtered
Players are of type character so it will grab only them easily.
https://lua-api.factorio.com/latest/Lua ... s_filtered
Players are of type character so it will grab only them easily.