Skip to content

Commit

Permalink
fix stove/oven table outputs and replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
Elkien3 committed Nov 11, 2022
1 parent fa75566 commit 43a252f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 9 additions & 4 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,14 @@ cooking.register_craft = function(tbl)
end
if tbl.type == "oven" or tbl.type == "stove" then
tbl.recipe = table_to_string(tbl.recipe)
local output_main = tbl.output
if type(output_main) == "table" then
output_main = output_main[1]
local output_main
if type(tbl.output) == "table" then
output_main = tbl.output[1]
assert(#tbl.output == 1, "oven/stove crafts must have only 1 output, use replacements for anything else.")
else
output_main = tbl.output
end
cooking.registered_cookcrafts[tbl.recipe] = {output = tbl.output, time = tbl.cooktime or 10, method = tbl.type}
cooking.registered_cookcrafts[tbl.recipe] = {output = tbl.output, time = tbl.cooktime or 10, method = tbl.type, replacements = tbl.replacements}
if not cooking.registered_cookcrafts[output_main] then
cooking.registered_cookcrafts[output_main] = {output = tbl.burned or "cooking:burnt_food", time = 60, method = tbl.type}
end
Expand Down Expand Up @@ -411,6 +414,8 @@ function cooking.get_craft_result(tbl)
if craft.method ~= method then return empty end
if type(craft.output) == "string" then
craft.output = ItemStack(craft.output)
elseif type(craft.output) == "table" then
craft.output = ItemStack(craft.output[1])
end
if cooking_aftercraft then
if soup then
Expand Down
13 changes: 8 additions & 5 deletions ovenstove.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,14 @@ local function furnace_node_timer(pos, elapsed)
--if inv:room_for_item("dst", aftercooked.items[1]) then
--inv:add_item("dst", aftercooked.items[1])
local item = cooked.item
if type(item) == "table" then
item = item[1]
for i, item in pairs(cooked.item) do
if i ~= 1 then
minetest.add_item(pos, cooked.item[i])
minetest.chat_send_all("1")
if cooked.replacements then
minetest.chat_send_all("2")
if type(cooked.replacements) == "string" then
minetest.add_item(pos, cooked.replacements)
else
for i, item in pairs(cooked.replacements) do
minetest.add_item(pos, cooked.replacements[i])
end
end
end
Expand Down

0 comments on commit 43a252f

Please sign in to comment.