Skip to content

Commit

Permalink
Barreling fixes (#206)
Browse files Browse the repository at this point in the history
* Fix barreling issues

Fixed issues caused by barrel-filling recipes no longer starting with "fill-". Fixed issues caused by icon_size now being an optional parameter.

Added fix for adding too many canisters to emptying recipe outputs if create_fluid_canister is called multiple times, to match the fix that was previously applied to create_gas_bottle.

* Barreling fix

Fixes issues caused by barrel-filling recipes no longer starting with "fill-", by checking the other end of the recipe name string for "-barrel" instead.

---------

Co-authored-by: KiwiHawk <[email protected]>
  • Loading branch information
Qatavin and KiwiHawk authored Nov 13, 2024
1 parent e76e456 commit 094d961
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions boblibrary/auto-bottle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ end
local function get_recipes_for_barrel(name)
local recipes = data.raw["recipe"]
if recipes then
return recipes["fill-" .. name], recipes["empty-" .. name]
return recipes[name], recipes["empty-" .. name]
end
return nil
end
Expand All @@ -35,10 +35,11 @@ end

-- Generates the icons definition for a fill-barrel recipe with the provided fluid definition and icon
local function generate_fill_recipe_icons(fluid, icon)
if fluid.icon and fluid.icon_size then
if fluid.icon then
local iconsize = fluid.icon_size or 64
table.insert(
icon,
{ icon = fluid.icon, icon_size = fluid.icon_size, scale = 16.0 / fluid.icon_size, shift = { 4, -8 } }
{ icon = fluid.icon, icon_size = iconsize, scale = 16.0 / iconsize, shift = { 4, -8 } }
)
elseif fluid.icons and util.combine_icons then
icon = util.combine_icons(icon, fluid.icons, { scale = 0.5, shift = { 4, -8 } })
Expand All @@ -58,10 +59,11 @@ end

-- Generates the icons definition for a empty-barrel recipe with the provided fluid definition and icon
local function generate_empty_recipe_icons(fluid, icon)
if fluid.icon and fluid.icon_size then
if fluid.icon then
local iconsize = fluid.icon_size or 64
table.insert(
icon,
{ icon = fluid.icon, icon_size = fluid.icon_size, scale = 16.0 / fluid.icon_size, shift = { 7, 8 } }
{ icon = fluid.icon, icon_size = iconsize, scale = 16.0 / iconsize, shift = { 7, 8 } }
)
elseif fluid.icons and util.combine_icons then
icon = util.combine_icons(icon, fluid.icons, { scale = 0.5, shift = { 7, 8 } })
Expand Down Expand Up @@ -315,7 +317,7 @@ function bobmods.lib.create_fluid_canister(fluid)
empty_recipe.icons = generate_empty_fluid_canister_icons(fluid)

bobmods.lib.recipe.remove_result(empty_recipe.name, "barrel")
bobmods.lib.recipe.add_result(empty_recipe.name, { type = "item", name = "empty-canister", amount = 1 })
bobmods.lib.recipe.set_result(empty_recipe.name, { type = "item", name = "empty-canister", amount = 1 })
bobmods.lib.tech.remove_recipe_unlock("fluid-handling", empty_recipe.name)
bobmods.lib.tech.remove_recipe_unlock("fluid-barrel-processing", empty_recipe.name)
else
Expand Down
2 changes: 1 addition & 1 deletion bobplates/data-updates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bobmods.lib.create_fluid_canister(data.raw.fluid["alien-fire"])

for i, recipe in pairs(data.raw.recipe) do
if
(string.sub(recipe.name, 1, 5) == "fill-" or string.sub(recipe.name, 1, 6) == "empty-")
string.sub(recipe.name, -7) == "-barrel"
and recipe.category == "crafting-with-fluid"
then
data.raw.recipe[recipe.name].category = "barrelling"
Expand Down

0 comments on commit 094d961

Please sign in to comment.