From b614a24d23386b0859ea507b4258b087baa2ed78 Mon Sep 17 00:00:00 2001 From: tacigar Date: Wed, 14 Sep 2016 19:22:44 +0900 Subject: [PATCH] [UPDATE] Update inactive core writer callbasks (allow) --- maidroid_tool/core_writer.lua | 39 ++++++++++++++++++++++++----------- maidroid_tool/depends.txt | 1 + 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/maidroid_tool/core_writer.lua b/maidroid_tool/core_writer.lua index c29da5d..93f409e 100644 --- a/maidroid_tool/core_writer.lua +++ b/maidroid_tool/core_writer.lua @@ -17,18 +17,6 @@ }, }; - function allow_metadata_inventory_put(pos, listname, index, stack, player) - - end - - function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) - - end - - function allow_metadata_inventory_take(pos, listname, index, stack, player) - - end - (function() -- register a definition of an inactive core writer. local tiles = { "maidroid_tool_core_writer_top.png", @@ -57,6 +45,33 @@ end + function allow_metadata_inventory_put(pos, listname, index, stack, player) + local meta = minetest.get_meta(pos) + local inventory = meta:get_inventory() + local itemname = stack:get_name() + + if (listname == "fuel" and itemname == "default:coal_lump") then + return stack:get_count() + elseif listname == "dye" and minetest.get_item_group(itemname, "dye") > 0 then + return stack:get_count() + else if listname == "core" and maidroid.is_core(itemname then + return stack:get_count() + end + return 0 + end + + function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.get_meta(pos) + local inventory = meta:get_inventory() + local stack = inventory:get_stack(from_list, from_index) + + return allow_metadata_inventory_put(pos, listname, to_index, stack, player) + end + + function allow_metadata_inventory_take(pos, listname, index, stack, player) + return stack:get_count() -- maybe add more. + end + minetest.register_node("maidroid_tool:core_writer", { description = "maidroid tool : core writer", drawtype = "nodebox", diff --git a/maidroid_tool/depends.txt b/maidroid_tool/depends.txt index 6aec5ed..bac044c 100644 --- a/maidroid_tool/depends.txt +++ b/maidroid_tool/depends.txt @@ -1,3 +1,4 @@ default +dye maidroid maidroid_core