Machine does not take items in creative mode

This commit is contained in:
DonBatman 2016-04-12 19:41:52 -07:00
parent effa0b57af
commit f1ee74dbd6
2 changed files with 43 additions and 44 deletions

View File

@ -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

View File

@ -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
if not minetest.setting_getbool("creative_mode") then
ingotstack1:take_item()
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()
end
inv:set_stack("craft1",1,ingotstack1)
inv:set_stack("craft2",1,ingotstack2)
inv:set_stack("craft3",1,ingotstack3)
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
if not minetest.setting_getbool("creative_mode") then
resstack:take_item()
inv:set_stack("res",1,resstack)
dyestack:take_item()
end
inv:set_stack("res",1,resstack)
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
if not minetest.setting_getbool("creative_mode") then
dirtstack1:take_item()
inv:set_stack("dirt1",1,dirtstack1)
dirtstack2:take_item()
end
inv:set_stack("dirt1",1,dirtstack1)
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")
if not minetest.setting_getbool("creative_mode") then
decomp:take_item()
end
inven:set_stack("decom",1,decomp)
end
timer:start(10)