mirror of
https://github.com/minetest-mods/technic.git
synced 2024-11-15 23:10:41 +01:00
Fix crash issue
This commit is contained in:
parent
3b70b56560
commit
da4f4f5e23
|
@ -121,22 +121,25 @@ function technic.get_recipe(typename, items)
|
|||
return
|
||||
end
|
||||
local recipe = technic.recipes[typename].recipes[index]
|
||||
if recipe then
|
||||
local new_input = {}
|
||||
for i, stack in ipairs(items) do
|
||||
if stack:get_count() < recipe.input[stack:get_name()] then
|
||||
return nil
|
||||
else
|
||||
new_input[i] = ItemStack(stack)
|
||||
new_input[i]:take_item(recipe.input[stack:get_name()])
|
||||
end
|
||||
end
|
||||
return {time = recipe.time,
|
||||
new_input = new_input,
|
||||
output = recipe.output}
|
||||
else
|
||||
return nil
|
||||
end
|
||||
if recipe then
|
||||
local new_input = {}
|
||||
for i, stack in ipairs(items) do
|
||||
local input_count = recipe.input[stack:get_name()]
|
||||
if input_count == nil then
|
||||
-- Handle nil value, maybe return nil or log a warning
|
||||
return nil
|
||||
end
|
||||
if stack:get_count() < input_count then
|
||||
return nil
|
||||
else
|
||||
new_input[i] = ItemStack(stack)
|
||||
new_input[i]:take_item(input_count)
|
||||
end
|
||||
end
|
||||
return {time = recipe.time, new_input = new_input, output = recipe.output}
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user