Skip to content

Commit

Permalink
Fix crash with fluid fluid fuel value formatting. (pyanodon/pybugrepo…
Browse files Browse the repository at this point in the history
  • Loading branch information
notnotmelon committed Aug 19, 2023
1 parent 62df254 commit 92f5389
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 2.1.4
Date: ?
Changes:
- Fix crash with fluid fluid fuel value formatting. (https://github.com/pyanodon/pybugreports/issues/307)
---------------------------------------------------------------------------------------------------
Version: 2.1.3
Date: 2023-7-25
Changes:
Expand Down
9 changes: 4 additions & 5 deletions prototypes/recipes/fuel-canister-recipes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ for f, fluid in pairs(data.raw.fluid) do
ignore_for_dependencies = true
}

local fuel_amount

if string.match(fluid.fuel_value, "KJ") ~= nil then
local fuel_amount = 50
if string.match(fluid.fuel_value, "[kK]J") then
fuel_amount = math.ceil(10/ (string.match(fluid.fuel_value, "[%d%.]+") / 1000))
elseif string.match(fluid.fuel_value, "MJ") ~= nil then
elseif string.match(fluid.fuel_value, "[mM]J") then
fuel_amount = math.ceil(10/ (string.match(fluid.fuel_value, "[%d%.]+")))
end

Expand All @@ -67,7 +66,7 @@ for f, fluid in pairs(data.raw.fluid) do
enabled = false,
energy_required = 0.2,
ingredients = {
{type = "fluid", name = fluid.name, amount = fuel_amount},
{type = "fluid", name = fluid.name, amount = fuel_amount},
{type = "item", name = "empty-fuel-canister", amount = 1}
},
results = {
Expand Down

0 comments on commit 92f5389

Please sign in to comment.