Skip to content

Commit

Permalink
Placing down an ocula will now cause that ocula to search the entire …
Browse files Browse the repository at this point in the history
…map for an available eyepod and fly to it. Resolves pyanodon/pybugreports#388
  • Loading branch information
notnotmelon committed Nov 10, 2024
1 parent 87ad522 commit 5164e58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Version: 3.0.21
Date: ?
Changes:
- Standardized productivity allowance in korlex -> fiber and yotoi -> fiber recipes. Resolves https://github.com/pyanodon/pybugreports/issues/570
- Oculas are no longer minable while in-transit.
- Placing down an ocula will now cause that ocula to search the entire map for an available eyepod and fly to it. Resolves https://github.com/pyanodon/pybugreports/issues/388
---------------------------------------------------------------------------------------------------
Version: 3.0.20
Date: 2024-11-9
Expand Down
7 changes: 4 additions & 3 deletions scripts/ocula/ocula.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function Oculua.set_target(oculua_data, target)
distraction = defines.distraction.none
}
oculua_data.target = target
entity.minable = false
end

function Oculua.spawn_oculua(ipod_data, player)
Expand Down Expand Up @@ -351,8 +352,8 @@ py.on_event(defines.events.on_ai_command_completed, function(event)
end
end)

function Oculua.find_nearest_ipod(entity)
local ipods = entity.surface.find_entities_filtered {position = entity.position, radius = 100, name = "ipod", force = entity.force, type = "container"}
function Oculua.find_available_ipod(entity)
local ipods = entity.surface.find_entities_filtered {name = "ipod", force = entity.force_index, type = "container"}
for _, ipod in pairs(ipods) do
local ipod_data = storage.ipods[ipod.unit_number]
local inventory = ipod.get_inventory(CHEST)
Expand Down Expand Up @@ -389,7 +390,7 @@ py.on_event(py.events.on_built(), function(event)
storage.ipods[entity.unit_number] = {entity = entity, inventory = inventory, active_oculua = 0}
storage.should_run_oculua_code = true
elseif entity.name == "ocula" then
local ipod = Oculua.find_nearest_ipod(entity)
local ipod = Oculua.find_available_ipod(entity)
if not ipod then return end
storage.oculuas[entity.unit_number] = {
entity = entity,
Expand Down

0 comments on commit 5164e58

Please sign in to comment.