Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix disappearing entity while scanning #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions resmon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -461,18 +461,20 @@ function resmon.scan_current_site(player_index)
local max_dist = settings.global["YARM-grow-limit"].value
for i = 1, to_scan do
local entity = table.remove(site.next_to_scan, 1)
local entity_position = entity.position
local surface = entity.surface
site.first_center = site.first_center or find_center(site.extents)

-- Look in every direction around this entity...
for _, dir in pairs(defines.direction) do
-- ...and if there's a resource, add it
local search_pos = shift_position(entity_position, dir)
if max_dist < 0 or util.distance(search_pos, site.first_center) < max_dist then
local found = find_resource_at(surface, search_pos)
if found and found.name == site.ore_type then
resmon.add_single_entity(player_index, found)
if entity and entity.valid then
local entity_position = entity.position
local surface = entity.surface
site.first_center = site.first_center or find_center(site.extents)

-- Look in every direction around this entity...
for _, dir in pairs(defines.direction) do
-- ...and if there's a resource, add it
local search_pos = shift_position(entity_position, dir)
if max_dist < 0 or util.distance(search_pos, site.first_center) < max_dist then
local found = find_resource_at(surface, search_pos)
if found and found.name == site.ore_type then
resmon.add_single_entity(player_index, found)
end
end
end
end
Expand Down