diff --git a/init.lua b/init.lua index f40ae72..44998ae 100644 --- a/init.lua +++ b/init.lua @@ -8,6 +8,7 @@ local MP = minetest.get_modpath("digibuilder") -- common functions dofile(MP.."/common.lua") +dofile(MP.."/marker.lua") dofile(MP.."/formspec.lua") dofile(MP.."/digiline_rules.lua") dofile(MP.."/digiline_validate_pos.lua") diff --git a/marker.lua b/marker.lua new file mode 100644 index 0000000..c2188d0 --- /dev/null +++ b/marker.lua @@ -0,0 +1,45 @@ + +function digibuilder.show_marker(pos, radius) + local entity = "digibuilder:marker" + + minetest.add_entity({x=pos.x+radius, y=pos.y+radius, z=pos.z+radius}, entity) + minetest.add_entity({x=pos.x-radius, y=pos.y+radius, z=pos.z+radius}, entity) + minetest.add_entity({x=pos.x+radius, y=pos.y+radius, z=pos.z-radius}, entity) + minetest.add_entity({x=pos.x-radius, y=pos.y+radius, z=pos.z-radius}, entity) + minetest.add_entity({x=pos.x+radius, y=pos.y-radius, z=pos.z+radius}, entity) + minetest.add_entity({x=pos.x-radius, y=pos.y-radius, z=pos.z+radius}, entity) + minetest.add_entity({x=pos.x+radius, y=pos.y-radius, z=pos.z-radius}, entity) + minetest.add_entity({x=pos.x-radius, y=pos.y-radius, z=pos.z-radius}, entity) +end + +local texture = "digibuilder_marker_green.png" + +minetest.register_entity("digibuilder:marker", { + initial_properties = { + visual = "cube", + visual_size = {x=1.05, y=1.05}, + static_save = false, + textures = { + texture, + texture, + texture, + texture, + texture, + texture + }, + collisionbox = {-0.525, -0.525, -0.525, 0.525, 0.525, 0.525}, + physical = false, + }, + + on_activate = function(self) + minetest.after(8.0, function() self.object:remove() end) + end, + + on_rightclick=function(self) + self.object:remove() + end, + + on_punch = function(self) + self.object:remove() + end, +}) diff --git a/node.lua b/node.lua index 375e27e..265cfd9 100644 --- a/node.lua +++ b/node.lua @@ -126,7 +126,7 @@ minetest.register_node("digibuilder:digibuilder", { return stack:get_count() end, - on_punch = function()--pos, node, puncher) - --TODO show marker on punch + on_punch = function(pos) + digibuilder.show_marker(pos, digibuilder.max_radius) end }) diff --git a/readme.md b/readme.md index 5a066d9..5c2f24d 100644 --- a/readme.md +++ b/readme.md @@ -9,7 +9,6 @@ State: **WIP** # TODO * [ ] `after_place_node(pos, placer, itemstack, pointed_thing)` compat (digtron mod?) -* [ ] area display on punch (like in the jumpdrive/protector mod) further issues: * [ ] Storage of read schematics/buildings diff --git a/textures/digibuilder_marker_green.png b/textures/digibuilder_marker_green.png new file mode 100644 index 0000000..1c38b8d Binary files /dev/null and b/textures/digibuilder_marker_green.png differ