Skip to content

Commit

Permalink
More biofluid fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Nov 9, 2024
1 parent 9f026bf commit 1cfc2bc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
4 changes: 2 additions & 2 deletions prototypes/biofluid/provider-tank.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ ENTITY {
type = "furnace",
bottleneck_ignore = true,
minable = {mining_time = 0.2, result = "provider-tank"},
icon = "__pyindustry__/graphics/icons/overflow-valve.png",
icon_size = 32,
icon = "__pyalienlifegraphics__/graphics/icons/chest-provider.png",
icon_size = 64,
flags = {"placeable-player", "player-creation", "placeable-neutral", "placeable-enemy"},
corpse = "small-remnants",
max_health = data.raw["pipe"]["pipe"].max_health,
Expand Down
4 changes: 2 additions & 2 deletions prototypes/biofluid/requester-tank.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ ENTITY {
bottleneck_ignore = true,
additional_pastable_entities = {"requester-tank"},
minable = {mining_time = 0.2, result = "requester-tank"},
icon = "__pyindustry__/graphics/icons/overflow-valve.png",
icon_size = 32,
icon = "__pyalienlifegraphics__/graphics/icons/chest-request.png",
icon_size = 64,
flags = {"placeable-player", "player-creation", "placeable-neutral", "placeable-enemy"},
corpse = "small-remnants",
max_health = data.raw["pipe"]["pipe"].max_health,
Expand Down
4 changes: 3 additions & 1 deletion scripts/biofluid/biofluid-gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ py.on_event(defines.events.on_gui_opened, function(event)
Biofluid.build_bioport_gui(entity, player)
elseif connection_type == Biofluid.REQUESTER then
Biofluid.build_requester_gui(entity, player)
elseif connection_type == Biofluid.PROVIDER then
player.opened = nil
end
end)

Expand Down Expand Up @@ -223,7 +225,7 @@ function Biofluid.build_requester_gui(entity, player)
camera.zoom = 2

local label_flow = content_flow.add {type = "flow", direction = "horizontal"}
label_flow.add {type = "label", caption = {"gui-logistic.title-request"}}.style.font = "default-semibold"
label_flow.add {type = "label", caption = {"gui-logistic.title-requests"}}.style.font = "default-semibold"
label_flow.add {type = "empty-widget", style = "py_empty_widget"}
label_flow.add {type = "label", caption = {"gui.priority"}}.style.font = "default-semibold"

Expand Down
27 changes: 12 additions & 15 deletions scripts/biofluid/biofluid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ py.on_event(py.events.on_built(), function(event)
elseif entity.type == "pipe-to-ground" then
entity.operable = false
elseif connection_type == Biofluid.PROVIDER then
entity.operable = false
storage.biofluid_providers[unit_number] = {entity = entity}
end
Biofluid.built_pipe()
Expand All @@ -75,7 +74,7 @@ local ENTITY_BIOFLUID_PIPE_INDEXES = {
["vessel-to-ground"] = 1,
["vessel"] = 1,
["bioport"] = 1,
["provider-tank"] = 1,
["provider-tank"] = 2,
["requester-tank"] = 1,
}

Expand Down Expand Up @@ -147,7 +146,7 @@ function Biofluid.update_bioport_animation(bioport_data)
else
local new_animation_name = "bioport-animation-" .. creature_name .. "-" .. math.min(new_stage, 10)
if animation_data.id then
rendering.set_animation(animation_data.id, new_animation_name)
rendering.get_object_by_id(animation_data.id).animation = new_animation_name
else
animation_data.id = rendering.draw_animation {
animation = new_animation_name,
Expand Down Expand Up @@ -196,10 +195,8 @@ local function random_order(l)
local order = {}
local i = 1
for unit_number in pairs(l) do
if elem.valid then
insert(order, random(1, i), elem)
i = i + 1
end
insert(order, random(1, i), unit_number)
i = i + 1
end
return ipairs(order)
end
Expand All @@ -208,8 +205,8 @@ local function build_providers_by_contents(network_data, relavant_fluids)
local providers_by_contents = {}
network_data.providers_by_contents = providers_by_contents
local providers = network_data.biofluid_providers

local min_fluid_reserve = 10000

for unit_number in pairs(providers) do
local provider_data = storage.biofluid_providers[unit_number]
if not provider_data then goto continue end
Expand All @@ -232,7 +229,7 @@ local function build_providers_by_contents(network_data, relavant_fluids)
end
end

local function process_unfulfilled_requests(unfulfilled_requests, relavant_fluids)
local function process_unfulfilled_requests(unfulfilled_request, relavant_fluids)
local network_id = unfulfilled_request.network_id
local network_data = storage.biofluid_networks[network_id]
local providers_by_contents = network_data.providers_by_contents
Expand Down Expand Up @@ -304,7 +301,7 @@ py.register_on_nth_tick(143, "update-biofluid", "pyal", function()
Biofluid.render_error_icons()

local unfulfilled_requests, relavant_fluids = Biofluid.get_unfulfilled_requests()

for _, unfulfilled_request in pairs(unfulfilled_requests) do
process_unfulfilled_requests(unfulfilled_request, relavant_fluids)
end
Expand Down Expand Up @@ -561,18 +558,18 @@ local function dropoff(biorobot_data)
end
local requester = requester_data.entity
local name, amount, temperature = biorobot_data.name, biorobot_data.delivery_amount, biorobot_data.temperature
local contents = requester.fluidbox[1]
local contents = requester.fluidbox[2]
if contents then
if contents.name ~= name then
go_home(biorobot_data); return
end
requester.fluidbox[1] = {
requester.fluidbox[2] = {
name = name,
amount = contents.amount + amount,
temperature = combine_tempatures(contents.amount, contents.temperature, amount, temperature)
}
elseif amount > 0 then
requester.fluidbox[1] = {name = name, amount = amount, temperature = temperature}
requester.fluidbox[2] = {name = name, amount = amount, temperature = temperature}
end
go_home(biorobot_data)
if biorobot_data.alt_mode_sprite then
Expand Down Expand Up @@ -648,7 +645,7 @@ function Biofluid.get_unfulfilled_requests()
if not fluid_name then goto continue end
local goal = requester_data.amount
if goal == 0 then goto continue end
local contents = requester.fluidbox[1]
local contents = requester.fluidbox[2]
local already_stored = requester_data.incoming
if not contents then
-- pass
Expand Down Expand Up @@ -706,7 +703,7 @@ function Biofluid.why_isnt_my_bioport_working(bioport_data)
return "entity-status.no-food"
elseif not has_creature then
return "entity-status.no-creature"
elseif not next(network.requesters) and not next(network.providers) then
elseif not next(network.biofluid_requesters) and not next(network.biofluid_providers) then
return "entity-status.no-biofluid-network"
elseif entity.get_inventory(OUTPUT_INVENTORY).get_item_count("guano") > 97 then
return "entity-status.full-output"
Expand Down

0 comments on commit 1cfc2bc

Please sign in to comment.