Skip to content

Commit

Permalink
Fixed crawdad not eating a new piece of food to continue to fuel modu…
Browse files Browse the repository at this point in the history
…les even when both slots have stacks of food loaded. Resolves pyanodon/pybugreports#563
  • Loading branch information
notnotmelon committed Nov 10, 2024
1 parent b8034b0 commit 2737d1b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Date: ?
- 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
- Fixed crawdad not eating a new piece of food to continue to fuel modules even when both slots have stacks of food loaded. Resolves https://github.com/pyanodon/pybugreports/issues/563
---------------------------------------------------------------------------------------------------
Version: 3.0.20
Date: 2024-11-9
Expand Down
39 changes: 31 additions & 8 deletions scripts/mounts/mounts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,42 @@ py.register_on_nth_tick(239, "update-mounts", "pyal", function(event)
end

local grid = mount.grid
local burner = mount.burner

for _, equipment in pairs(grid.equipment) do
local missing = equipment.max_energy - equipment.energy
if missing > 0 then
local burner = mount.burner
if burner.remaining_burning_fuel < missing / transfer_efficiency then
equipment.energy = equipment.energy + burner.remaining_burning_fuel * transfer_efficiency
burner.remaining_burning_fuel = 0
if missing <= 0 then goto dosent_need_energy end

if burner.remaining_burning_fuel <= 0 then
local fuel_inventory = burner.inventory
if fuel_inventory.is_empty() then break end

for i = 1, #fuel_inventory do
local fuel = fuel_inventory[i]
if not fuel.valid_for_read then goto invalid_fuel_item end
local prototype = fuel.prototype
local fuel_value = prototype.fuel_value
if not prototype.fuel_value then goto invalid_fuel_item end

burner.currently_burning = fuel
burner.remaining_burning_fuel = fuel_value
fuel.count = fuel.count - 1
break
else
burner.remaining_burning_fuel = burner.remaining_burning_fuel - missing / transfer_efficiency
equipment.energy = equipment.energy + missing
::invalid_fuel_item::
end
end

if burner.remaining_burning_fuel <= 0 then break end

if burner.remaining_burning_fuel < missing / transfer_efficiency then
equipment.energy = equipment.energy + burner.remaining_burning_fuel * transfer_efficiency
burner.remaining_burning_fuel = 0
else
burner.remaining_burning_fuel = burner.remaining_burning_fuel - missing / transfer_efficiency
equipment.energy = equipment.energy + missing
end

::dosent_need_energy::
end
end
end)
Expand Down

0 comments on commit 2737d1b

Please sign in to comment.