Skip to content

Commit

Permalink
add some extra null checks in biofluid
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Jan 10, 2024
1 parent 84bb961 commit 9f5968f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Date: ???
- Nerfed scrondrix path 1. No longer grants bonus cubs
- Buffed scrondrix path 2. Multiplies meat by 3x instead of 5x. No more -20% speed downgrade
- Nerfed composter path 1. Dried biomass amount reduced 12 -> 4
- Fixed improper migrations to new biofluid system causing crashes (https://github.com/pyanodon/pybugreports/issues/367)
---------------------------------------------------------------------------------------------------
Version: 2.1.13
Date: 2024-1-8
Expand Down
5 changes: 5 additions & 0 deletions migrations/biofluid.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
--for _, surface in pairs(game.surfaces) do
--for _, pipe in pairs(surface.find_entities_filtered{name = {'vessel', 'bioport'}}) do
--pipe.destroy()
--end
--end
24 changes: 13 additions & 11 deletions scripts/biofluid/biofluid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -364,17 +364,19 @@ local function find_new_home(biorobot_data, network_data)
local home
local min_robot_count = 999
for unit_number, bioport in pairs(network_data.bioports) do
local bioport_data = global.biofluid_bioports[bioport.unit_number]
if unit_number ~= old_home and bioport.valid and bioport_data then
local robot_count = bioport.get_inventory(INPUT_INVENTORY).get_item_count(biorobot_data.entity.name)
if robot_count < 6 then
home = bioport
biorobot_data.bioport = unit_number
break
elseif robot_count < min_robot_count then
min_robot_count = robot_count
home = bioport
biorobot_data.bioport = unit_number
if bioport.valid then
local bioport_data = global.biofluid_bioports[bioport.unit_number]
if unit_number ~= old_home and bioport.valid and bioport_data then
local robot_count = bioport.get_inventory(INPUT_INVENTORY).get_item_count(biorobot_data.entity.name)
if robot_count < 6 then
home = bioport
biorobot_data.bioport = unit_number
break
elseif robot_count < min_robot_count then
min_robot_count = robot_count
home = bioport
biorobot_data.bioport = unit_number
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions scripts/biofluid/network-builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ function Biofluid.built_pipe(entity, update_graphics)
end

function Biofluid.is_looking_at_us(entity, connection, network_positions)
if not entity.valid then return nil end
if not network_positions then
network_positions = Biofluid.network_positions(entity.surface_index)
end
Expand Down

0 comments on commit 9f5968f

Please sign in to comment.