code cleanup

creative won't take items
This commit is contained in:
DonBatman 2016-04-12 19:51:47 -07:00
parent 4cee33a979
commit 7c5ab717f9
2 changed files with 46 additions and 49 deletions

View File

@ -20,55 +20,55 @@ minetest.register_node("mysheetmetal:machine", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.5, -0.0625, -0.3125, 0.5, 0.0625, 0.1875}, -- NodeBox6 {-0.5, -0.0625, -0.3125, 0.5, 0.0625, 0.1875},
{-0.5, 0.125, -0.3125, 0.5, 0.1875, 0.125}, -- NodeBox7 {-0.5, 0.125, -0.3125, 0.5, 0.1875, 0.125},
{-0.5, 0.1875, -0.25, 0.5, 0.25, 0.125}, -- NodeBox8 {-0.5, 0.1875, -0.25, 0.5, 0.25, 0.125},
{-0.5, -0.0625, -0.4375, 0.5, 0.0625, -0.3125}, -- NodeBox9 {-0.5, -0.0625, -0.4375, 0.5, 0.0625, -0.3125},
{0, -0.25, -0.4375, 0.0625, -0.0625, -0.375}, -- NodeBox10 {0, -0.25, -0.4375, 0.0625, -0.0625, -0.375},
{0, -0.3125, -0.4375, 0.5, -0.25, -0.375}, -- NodeBox11 {0, -0.3125, -0.4375, 0.5, -0.25, -0.375},
{-0.5, -0.5, 0.0625, -0.375, -0.0625, 0.1875}, -- NodeBox12 {-0.5, -0.5, 0.0625, -0.375, -0.0625, 0.1875},
{0, 0.25, 0, 0.0625, 0.5, 0.0625}, -- NodeBox13 {0, 0.25, 0, 0.0625, 0.5, 0.0625},
{0.0625, 0.4375, 0, 0.5, 0.5, 0.0625}, -- NodeBox14 {0.0625, 0.4375, 0, 0.5, 0.5, 0.0625},
{-0.5, 0.0625, 0.125, 0.5, 0.1875, 0.1875}, -- NodeBox15 {-0.5, 0.0625, 0.125, 0.5, 0.1875, 0.1875},
{-0.5, -0.5, -0.3125, -0.375, -0.0625, -0.1875}, -- NodeBox16 {-0.5, -0.5, -0.3125, -0.375, -0.0625, -0.1875},
{0.5, -0.0625, -0.3125, 1.5, 0.0625, 0.1875}, -- NodeBox6 {0.5, -0.0625, -0.3125, 1.5, 0.0625, 0.1875},
{0.5, 0.125, -0.3125, 1.5, 0.1875, 0.125}, -- NodeBox7 {0.5, 0.125, -0.3125, 1.5, 0.1875, 0.125},
{0.5, 0.1875, -0.25, 1.5, 0.25, 0.125}, -- NodeBox8 {0.5, 0.1875, -0.25, 1.5, 0.25, 0.125},
{0.5, -0.0625, -0.4375, 1.5, 0.0625, -0.3125}, -- NodeBox9 {0.5, -0.0625, -0.4375, 1.5, 0.0625, -0.3125},
{1, -0.25, -0.4375, 1.0625, -0.0625, -0.375}, -- NodeBox10 {1, -0.25, -0.4375, 1.0625, -0.0625, -0.375},
{0.5, -0.3125, -0.4375, 1.0625, -0.25, -0.375}, -- NodeBox11 {0.5, -0.3125, -0.4375, 1.0625, -0.25, -0.375},
{1.375, -0.5, 0.0625, 1.5, -0.0625, 0.1875}, -- NodeBox12 {1.375, -0.5, 0.0625, 1.5, -0.0625, 0.1875},
{1, 0.25, 0, 1.0625, 0.5, 0.0625}, -- NodeBox13 {1, 0.25, 0, 1.0625, 0.5, 0.0625},
{0.5, 0.4375, 0, 1.0625, 0.5, 0.0625}, -- NodeBox14 {0.5, 0.4375, 0, 1.0625, 0.5, 0.0625},
{0.5, 0.0625, 0.125, 1.5, 0.1875, 0.1875}, -- NodeBox15 {0.5, 0.0625, 0.125, 1.5, 0.1875, 0.1875},
{1.375, -0.5, -0.3125, 1.5, -0.0625, -0.1875}, -- NodeBox16 {1.375, -0.5, -0.3125, 1.5, -0.0625, -0.1875},
} }
}, },
selection_box = { selection_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.5, -0.0625, -0.3125, 1.5, 0.0625, 0.1875}, -- NodeBox6 {-0.5, -0.0625, -0.3125, 1.5, 0.0625, 0.1875},
{-0.5, 0.125, -0.3125, 1.5, 0.1875, 0.125}, -- NodeBox7 {-0.5, 0.125, -0.3125, 1.5, 0.1875, 0.125},
{-0.5, 0.1875, -0.25, 1.5, 0.25, 0.125}, -- NodeBox8 {-0.5, 0.1875, -0.25, 1.5, 0.25, 0.125},
{-0.5, -0.0625, -0.4375, 1.5, 0.0625, -0.3125}, -- NodeBox9 {-0.5, -0.0625, -0.4375, 1.5, 0.0625, -0.3125},
{0, -0.25, -0.4375, 0.0625, -0.0625, -0.375}, -- NodeBox10 {0, -0.25, -0.4375, 0.0625, -0.0625, -0.375},
{0, -0.3125, -0.4375, 1.0625, -0.25, -0.375}, -- NodeBox11 {0, -0.3125, -0.4375, 1.0625, -0.25, -0.375},
{-0.5, -0.5, 0.0625, -0.375, -0.0625, 0.1875}, -- NodeBox12 {-0.5, -0.5, 0.0625, -0.375, -0.0625, 0.1875},
{0, 0.25, 0, 0.0625, 0.4375, 0.0625}, -- NodeBox13 {0, 0.25, 0, 0.0625, 0.4375, 0.0625},
{0, 0.4375, 0, 1.0625, 0.5, 0.0625}, -- NodeBox14 {0, 0.4375, 0, 1.0625, 0.5, 0.0625},
{-0.5, 0.0625, 0.125, 1.5, 0.1875, 0.1875}, -- NodeBox15 {-0.5, 0.0625, 0.125, 1.5, 0.1875, 0.1875},
{-0.5, -0.5, -0.3125, -0.375, -0.0625, -0.1875}, -- NodeBox16 {-0.5, -0.5, -0.3125, -0.375, -0.0625, -0.1875},
{1, -0.25, -0.4375, 1.0625, -0.0625, -0.375}, -- NodeBox10 {1, -0.25, -0.4375, 1.0625, -0.0625, -0.375},
{1.375, -0.5, 0.0625, 1.5, -0.0625, 0.1875}, -- NodeBox12 {1.375, -0.5, 0.0625, 1.5, -0.0625, 0.1875},
{1, 0.25, 0, 1.0625, 0.4375, 0.0625}, -- NodeBox13 {1, 0.25, 0, 1.0625, 0.4375, 0.0625},
{1.375, -0.5, -0.3125, 1.5, -0.0625, -0.1875}, -- NodeBox16 {1.375, -0.5, -0.3125, 1.5, -0.0625, -0.1875},
} }
}, },
@ -81,11 +81,9 @@ minetest.register_node("mysheetmetal:machine", {
can_dig = function(pos,player) can_dig = function(pos,player)
local meta = minetest.env:get_meta(pos); local meta = minetest.env:get_meta(pos);
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("ingot") then if not inv:is_empty("ingot") or
return false not inv:is_empty("ingot2") or
elseif not inv:is_empty("ingot2") then not inv:is_empty("res") then
return false
elseif not inv:is_empty("res") then
return false return false
end end
return true return true
@ -130,7 +128,7 @@ end,
on_receive_fields = function(pos, formname, fields, sender) on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
--eaves trough
if fields["et"] if fields["et"]
or fields["etocorner"] or fields["etocorner"]
or fields["eticorner"] or fields["eticorner"]
@ -268,23 +266,22 @@ then
local ingotstack = inv:get_stack("ingot", 1) local ingotstack = inv:get_stack("ingot", 1)
local ingotstack2 = inv:get_stack("ingot2", 1) local ingotstack2 = inv:get_stack("ingot2", 1)
local resstack = inv:get_stack("res", 1) local resstack = inv:get_stack("res", 1)
----------------------------------------------------------------------------------
--register nodes
----------------------------------------------------------------------------------
if ingotstack:get_name()=="default:steel_ingot" and if ingotstack:get_name()=="default:steel_ingot" and
ingotstack2:get_name()=="dye:white" then ingotstack2:get_name()=="dye:white" then
make_ok = "1" make_ok = "1"
end end
----------------------------------------------------------------------
if make_ok == "1" then if make_ok == "1" then
local give = {} local give = {}
for i = 0, anzahl-1 do for i = 0, anzahl-1 do
give[i+1]=inv:add_item("res",shape) give[i+1]=inv:add_item("res",shape)
end end
if not minetest.setting_getbool("creative_mode") then
ingotstack:take_item() ingotstack:take_item()
inv:set_stack("ingot",1,ingotstack)
ingotstack2:take_item() ingotstack2:take_item()
end
inv:set_stack("ingot",1,ingotstack)
inv:set_stack("ingot2",1,ingotstack2) inv:set_stack("ingot2",1,ingotstack2)
end end
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 236 KiB