Update tubes callbacks to support more inputs recipes.
This commit is contained in:
parent
fdad5d9cfb
commit
3c14014290
@ -432,7 +432,7 @@ function appliance:recipe_step_size(step_size)
|
||||
return int_step_size;
|
||||
end
|
||||
|
||||
function appliance:recipe_inventory_can_put(pos, listname, index, stack, player, recipes)
|
||||
function appliance:recipe_inventory_can_put(pos, listname, index, stack, player)
|
||||
if player then
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
@ -513,15 +513,24 @@ end
|
||||
function appliance:tube_can_insert (pos, node, stack, direction, owner)
|
||||
if self.recipes then
|
||||
if self.have_input then
|
||||
local input = self.recipes.inputs[stack:get_name()];
|
||||
if input then
|
||||
return self:recipe_inventory_can_put(pos, self.input_stack, 1, stack, nil, recipes);
|
||||
if (self.input_stack_size <= 1) then
|
||||
local input = self.recipes.inputs[stack:get_name()];
|
||||
if input then
|
||||
return self:recipe_inventory_can_put(pos, self.input_stack, 1, stack, nil);
|
||||
end
|
||||
else
|
||||
for index = 1,self.input_stack_size do
|
||||
local can_insert = self:recipe_inventory_can_put(pos, self.input_stack, index, stack, nil);
|
||||
if can_insert then
|
||||
return can_insert;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.have_usage then
|
||||
local usage = self.recipes.usages[stack:get_name()];
|
||||
if usage then
|
||||
return self:recipe_inventory_can_put(pos, self.use_stack, 1, stack, nil, recipes);
|
||||
return self:recipe_inventory_can_put(pos, self.use_stack, 1, stack, nil);
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -533,9 +542,18 @@ function appliance:tube_insert (pos, node, stack, direction, owner)
|
||||
local inv = meta:get_inventory();
|
||||
|
||||
if self.have_input then
|
||||
local input = self.recipes.inputs[stack:get_name()];
|
||||
if input then
|
||||
return inv:add_item(self.input_stack, stack);
|
||||
if (self.input_stack_size <= 1) then
|
||||
local input = self.recipes.inputs[stack:get_name()];
|
||||
if input then
|
||||
return inv:add_item(self.input_stack, stack);
|
||||
end
|
||||
else
|
||||
for index = 1,self.input_stack_size do
|
||||
local can_insert = self:recipe_inventory_can_put(pos, self.input_stack, index, stack, nil);
|
||||
if can_insert then
|
||||
return inv:get_stack(add_item(self.input_stack,index):add_item(stack));
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.have_usage then
|
||||
|
Loading…
x
Reference in New Issue
Block a user