summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaceDeer <derksenmobile@gmail.com>2017-09-14 00:47:53 -0600
committerFaceDeer <derksenmobile@gmail.com>2017-09-14 00:47:53 -0600
commit576aeeade02104a41ccb60d4dda91f8e364639a1 (patch)
treeeabd873651b03df83dd6009d14fb158205a2ef0c
parent46bffd82d38ded68bcf102efd25da06a96e64a5d (diff)
add ability to read node type as well as facing, simplifies programming
-rw-r--r--nodes/node_builders.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/nodes/node_builders.lua b/nodes/node_builders.lua
index 19bbe9f..53edaa5 100644
--- a/nodes/node_builders.lua
+++ b/nodes/node_builders.lua
@@ -169,10 +169,15 @@ minetest.register_node("digtron:builder", {
end
elseif fields.read then
- local meta = minetest.get_meta(pos)
local facing = minetest.get_node(pos).param2
local buildpos = digtron.find_new_pos(pos, facing)
- meta:set_int("build_facing", minetest.get_node(buildpos).param2)
+ local target_node = minetest.get_node(buildpos)
+ if target_node.name ~= "air" and minetest.get_item_group(target_node.name, "digtron") == 0 then
+ local meta = minetest.get_meta(pos)
+ local inv = meta:get_inventory()
+ inv:set_stack("main", 1, target_node.name)
+ meta:set_int("build_facing", target_node.param2)
+ end
end
if fields.help and minetest.get_modpath("doc") then --check for mod in case someone disabled it after this digger was built