From 4bae9f15d53901c8b3d926a01733ef5cb1785e80 Mon Sep 17 00:00:00 2001 From: BuckarooBanzay Date: Tue, 16 Jun 2020 08:19:44 +0200 Subject: [PATCH] marker display --- init.lua | 1 + marker.lua | 45 ++++++++++++++++++++++++++ node.lua | 4 +-- readme.md | 1 - textures/digibuilder_marker_green.png | Bin 0 -> 163 bytes 5 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 marker.lua create mode 100644 textures/digibuilder_marker_green.png 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 0000000000000000000000000000000000000000..1c38b8de0358adccb12600983f58a3cd38c04b1d GIT binary patch literal 163 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPd3p)?5{);RV1)z|Dr;B5V#p&dfANn8XH!>YKbl|{& z0^e7b%9gXX&hz}2p0q%qN6H}UzzRlz10I=WYz(g}IDD