marker display

This commit is contained in:
BuckarooBanzay 2020-06-16 08:19:44 +02:00
parent 684afd7e56
commit 4bae9f15d5
5 changed files with 48 additions and 3 deletions

@ -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")

45
marker.lua Normal file

@ -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,
})

@ -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
})

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B