From 2b5dc41d50965a2190ae7c16cc18129061fa74ab Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Mon, 2 Jan 2017 18:50:03 -0700 Subject: Adding item display entities to the builder heads --- util.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'util.lua') diff --git a/util.lua b/util.lua index 08bdb45..c34d13b 100644 --- a/util.lua +++ b/util.lua @@ -104,7 +104,11 @@ digtron.move_node = function(pos, newpos) newmeta:set_int("build_facing", oldmeta:get_int("build_facing")) newmeta:set_float("fuel_burning", oldmeta:get_float("fuel_burning")) newmeta:set_string("infotext", oldmeta:get_string("infotext")) - + + if minetest.get_item_group(node.name, "digtron") == 4 then + digtron.update_builder_item(newpos) + end + -- remove node from old position minetest.remove_node(pos) end @@ -365,4 +369,26 @@ digtron.burn = function(fuelstore_positions, target, test) end end return current_burned +end + +digtron.remove_builder_item = function(pos) + minetest.debug("removing builder item") + local objects = minetest.env:get_objects_inside_radius(pos, 0.5) + if objects ~= nil then + for _, obj in ipairs(objects) do + if obj and obj:get_luaentity() and obj:get_luaentity().name == "digtron:builder_item" then + obj:remove() + end + end + end +end + +digtron.update_builder_item = function(pos) + digtron.remove_builder_item(pos) + local inv = minetest.get_inventory({type="node", pos=pos}) + local item_stack = inv:get_stack("main", 1) + if not item_stack:is_empty() then + digtron.create_builder_item = item_stack:get_name() + minetest.add_entity(pos,"digtron:builder_item") + end end \ No newline at end of file -- cgit v1.2.3