towny/towny/visualize.lua

41 lines
981 B
Lua
Raw Normal View History

2019-01-12 15:49:44 +00:00
-- Visualize an area
-- TODO: Use particles
2019-01-12 15:49:44 +00:00
local r1 = towny.regions.size
2019-01-13 17:39:18 +00:00
local r2 = towny.regions.height
2019-01-12 15:49:44 +00:00
local c_obj_props = {
hp = 1,
glow = 1,
physical = false,
pointable = true,
visual = "cube",
2019-01-12 21:31:11 +00:00
visual_size = {x = r1, y = r2},
2019-01-12 15:49:44 +00:00
textures = {"towny_visualize.png","towny_visualize.png","towny_visualize.png",
"towny_visualize.png","towny_visualize.png","towny_visualize.png"},
static_save = false,
use_texture_alpha = true,
}
minetest.register_entity("towny:region_visual", {
initial_properties = c_obj_props,
on_punch = function(self)
self.object:remove()
end,
timer0 = 0,
on_step = function (self,dt)
self.timer0 = self.timer0 + 1
if self.timer0 > 600 then
self.object:remove()
end
end
})
2019-01-13 17:39:18 +00:00
local function fl(x)
return math.floor(x)
2019-01-12 15:49:44 +00:00
end
function towny.regions.visualize_area(p1,p2)
2019-01-13 17:39:18 +00:00
local center = {x=fl(p2.x + r1/2)+0.5,y=fl(p2.y + r2/2)+0.5,z=fl(p2.z + r1/2)+0.5}
2019-01-12 15:49:44 +00:00
local e = minetest.add_entity(center, "towny:region_visual")
end