forked from mtcontrib/pipeworks
abstract adding of virtual items
This commit is contained in:
parent
78e081cf25
commit
e92ac0f7b3
|
@ -152,6 +152,12 @@ local function set_formspec(meta, enabled)
|
||||||
"list[current_player;main;0,7;8,4;]")
|
"list[current_player;main;0,7;8,4;]")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function add_virtual_item(inv, listname, index, stack)
|
||||||
|
local stack_copy = ItemStack(stack)
|
||||||
|
stack_copy:set_count(1)
|
||||||
|
inv:set_stack(listname, index, stack_copy)
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("pipeworks:autocrafter", {
|
minetest.register_node("pipeworks:autocrafter", {
|
||||||
description = "Autocrafter",
|
description = "Autocrafter",
|
||||||
drawtype = "normal",
|
drawtype = "normal",
|
||||||
|
@ -214,9 +220,7 @@ minetest.register_node("pipeworks:autocrafter", {
|
||||||
update_autocrafter(pos)
|
update_autocrafter(pos)
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
if listname == "recipe" then
|
if listname == "recipe" then
|
||||||
local stack_copy = ItemStack(stack)
|
add_virtual_item(inv, listname, index, stack)
|
||||||
stack_copy:set_count(1)
|
|
||||||
inv:set_stack(listname, index, stack_copy)
|
|
||||||
after_recipe_change(pos, inv)
|
after_recipe_change(pos, inv)
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
@ -246,9 +250,7 @@ minetest.register_node("pipeworks:autocrafter", {
|
||||||
after_recipe_change(pos, inv)
|
after_recipe_change(pos, inv)
|
||||||
return 0
|
return 0
|
||||||
elseif to_list == "recipe" then
|
elseif to_list == "recipe" then
|
||||||
local stack_copy = ItemStack(stack)
|
add_virtual_item(inv, to_list, to_index, stack)
|
||||||
stack_copy:set_count(1)
|
|
||||||
inv:set_stack(to_list, to_index, stack_copy)
|
|
||||||
after_recipe_change(pos, inv)
|
after_recipe_change(pos, inv)
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user