From f1ee74dbd6b870fe6c102435f3c8ee97f2d002d2 Mon Sep 17 00:00:00 2001 From: DonBatman Date: Tue, 12 Apr 2016 19:41:52 -0700 Subject: [PATCH] Machine does not take items in creative mode --- init.lua | 38 ++++++++++++++++++-------------------- machine.lua | 49 +++++++++++++++++++++++++------------------------ 2 files changed, 43 insertions(+), 44 deletions(-) diff --git a/init.lua b/init.lua index 018394d..b06a5aa 100644 --- a/init.lua +++ b/init.lua @@ -1,32 +1,31 @@ dofile(minetest.get_modpath("mymulch").."/machine.lua") - local mulch_tab = { -{"black", "Black", "mymulch_black.png", "^[colorize:black:240"}, -{"blue", "Blue", "mymulch_blue.png", "^[colorize:#0404B4:100"}, -{"brown", "Brown", "mymulch_brown.png", "^[colorize:#190B07:160"}, -{"cyan", "Cyan", "mymulch_cyan.png", "^[colorize:cyan:120"}, -{"dark_green", "Dark Green", "mymulch_dark_green.png", "^[colorize:#071907:200"}, -{"dark_grey", "Dark Grey", "mymulch_dark_grey.png", "^[colorize:black:150"}, -{"green", "Green", "mymulch_green.png", "^[colorize:green:160"}, -{"grey", "Grey", "mymulch_grey.png", "^[colorize:black:150"}, -{"magenta", "Magenta", "mymulch_magenta.png", "^[colorize:magenta:160"}, -{"orange", "Orange", "mymulch_orange.png", "^[colorize:orange:150"}, -{"pink", "Pink", "mymulch_pink.png", "^[colorize:#FE2E9A:150"}, -{"red", "Red", "mymulch_red.png", "^[colorize:#B40404:150"}, -{"violet", "Violet", "mymulch_violet.png", "^[colorize:#2F0B3A:150"}, -{"white", "White", "mymulch_white.png", "^[colorize:white:150"}, -{"yellow", "Yellow", "mymulch_yellow.png", "^[colorize:yellow:150"}, -{"tan", "Tan", "mymulch_tan.png", ""}, -} + {"black", "Black", "mymulch_black.png", "^[colorize:black:240"}, + {"blue", "Blue", "mymulch_blue.png", "^[colorize:#0404B4:100"}, + {"brown", "Brown", "mymulch_brown.png", "^[colorize:#190B07:160"}, + {"cyan", "Cyan", "mymulch_cyan.png", "^[colorize:cyan:120"}, + {"dark_green", "Dark Green", "mymulch_dark_green.png", "^[colorize:#071907:200"}, + {"dark_grey", "Dark Grey", "mymulch_dark_grey.png", "^[colorize:black:150"}, + {"green", "Green", "mymulch_green.png", "^[colorize:green:160"}, + {"grey", "Grey", "mymulch_grey.png", "^[colorize:black:150"}, + {"magenta", "Magenta", "mymulch_magenta.png", "^[colorize:magenta:160"}, + {"orange", "Orange", "mymulch_orange.png", "^[colorize:orange:150"}, + {"pink", "Pink", "mymulch_pink.png", "^[colorize:#FE2E9A:150"}, + {"red", "Red", "mymulch_red.png", "^[colorize:#B40404:150"}, + {"violet", "Violet", "mymulch_violet.png", "^[colorize:#2F0B3A:150"}, + {"white", "White", "mymulch_white.png", "^[colorize:white:150"}, + {"yellow", "Yellow", "mymulch_yellow.png", "^[colorize:yellow:150"}, + {"tan", "Tan", "mymulch_tan.png", ""}, + } + for i in ipairs (mulch_tab) do local mat = mulch_tab[i][1] local desc = mulch_tab[i][2] local image = mulch_tab[i][3] local dye = mulch_tab[i][4] - minetest.register_node("mymulch:mulch_"..mat, { description = desc.." Mulch", drawtype = "normal", @@ -44,7 +43,6 @@ minetest.register_node("mymulch:mulch_"..mat, { }), }) - end diff --git a/machine.lua b/machine.lua index e023a85..200b903 100644 --- a/machine.lua +++ b/machine.lua @@ -109,21 +109,14 @@ minetest.register_node("mymulch:machine", { can_dig = function(pos,player) local meta = minetest.get_meta(pos); local inv = meta:get_inventory() - if not inv:is_empty("craft1") then - return false - elseif not inv:is_empty("craft2") then - return false - elseif not inv:is_empty("craft3") then - return false - elseif not inv:is_empty("craft4") then - return false - elseif not inv:is_empty("res") then - return false - elseif not inv:is_empty("mulch") then - return false - elseif not inv:is_empty("dye") then - return false - elseif not inv:is_empty("res2") then + if not inv:is_empty("craft1") or + not inv:is_empty("craft2") or + not inv:is_empty("craft3") or + not inv:is_empty("craft4") or + not inv:is_empty("res") or + not inv:is_empty("mulch") or + not inv:is_empty("dye") or + not inv:is_empty("res2") then return false end return true @@ -320,13 +313,15 @@ end for i = 0, outputmulch-1 do give[i+1]=inv:add_item("res",mulcht) end - ingotstack1:take_item() + if not minetest.setting_getbool("creative_mode") then + ingotstack1:take_item() + ingotstack2:take_item() + ingotstack3:take_item() + ingotstack4:take_item() + end inv:set_stack("craft1",1,ingotstack1) - ingotstack2:take_item() inv:set_stack("craft2",1,ingotstack2) - ingotstack3:take_item() inv:set_stack("craft3",1,ingotstack3) - ingotstack4:take_item() inv:set_stack("craft4",1,ingotstack4) end @@ -392,9 +387,11 @@ then for i = 0, outputdye-1 do giveme[i+1]=inv:add_item("res2",dyet..dyem) end - resstack:take_item() + if not minetest.setting_getbool("creative_mode") then + resstack:take_item() + dyestack:take_item() + end inv:set_stack("res",1,resstack) - dyestack:take_item() inv:set_stack("dye",1,dyestack) end @@ -431,9 +428,11 @@ then for j = 0, outputdirt-1 do giveme[j+1]=inv:add_item("res3",dirt) end - dirtstack1:take_item() + if not minetest.setting_getbool("creative_mode") then + dirtstack1:take_item() + dirtstack2:take_item() + end inv:set_stack("dirt1",1,dirtstack1) - dirtstack2:take_item() inv:set_stack("dirt2",1,dirtstack2) end end @@ -475,7 +474,9 @@ for i in ipairs (mulch_tab) do if deco == "mymulch:mulch_"..mat then inven:add_item("clay", "default:clay_lump") - decomp:take_item() + if not minetest.setting_getbool("creative_mode") then + decomp:take_item() + end inven:set_stack("decom",1,decomp) end timer:start(10)