Add protection area marker for landmarks
parent
b95997b162
commit
ba84a5a751
37
baselib.lua
37
baselib.lua
|
@ -96,7 +96,7 @@ function minecart.set_marker(pos, text, size, ttl)
|
|||
end
|
||||
end
|
||||
|
||||
minetest.register_entity(":minecart:marker_cube", {
|
||||
minetest.register_entity("minecart:marker_cube", {
|
||||
initial_properties = {
|
||||
visual = "cube",
|
||||
textures = {
|
||||
|
@ -118,6 +118,41 @@ minetest.register_entity(":minecart:marker_cube", {
|
|||
end,
|
||||
})
|
||||
|
||||
function minecart.set_land_marker(pos, radius, ttl)
|
||||
local offs = radius + 0.5
|
||||
local posses = {
|
||||
{x = pos.x + offs, y = pos.y, z=pos.z},
|
||||
{x = pos.x, y = pos.y, z=pos.z + offs},
|
||||
{x = pos.x - offs, y = pos.y, z=pos.z},
|
||||
{x = pos.x, y = pos.y, z=pos.z - offs},
|
||||
}
|
||||
for i, pos in ipairs(posses) do
|
||||
local marker = minetest.add_entity(pos, "minecart:marker")
|
||||
if marker ~= nil then
|
||||
marker:set_properties({
|
||||
visual_size = {x = 2 * offs, y = 2 * offs},
|
||||
collisionbox = {-offs, -offs, 0, offs, offs, 0},
|
||||
})
|
||||
marker:set_yaw(math.pi / 2 * i)
|
||||
minetest.after(ttl, marker.remove, marker)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity("minecart:marker", {
|
||||
initial_properties = {
|
||||
visual = "upright_sprite",
|
||||
textures = {"minecart_marker_cube.png"},
|
||||
use_texture_alpha = true,
|
||||
physical = false,
|
||||
glow = 12,
|
||||
static_save = false,
|
||||
},
|
||||
on_punch = function(self)
|
||||
self.object:remove()
|
||||
end,
|
||||
})
|
||||
|
||||
function minecart.is_air_like(name)
|
||||
local ndef = minetest.registered_nodes[name]
|
||||
if ndef and ndef.buildable_to then
|
||||
|
|
|
@ -91,6 +91,10 @@ minetest.register_node("minecart:landmark", {
|
|||
return false
|
||||
end,
|
||||
|
||||
on_punch = function(pos, node, puncher, pointed_thing)
|
||||
minecart.set_land_marker(pos, RANGE, 20)
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky = 3, stone = 1},
|
||||
|
|
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 305 KiB |
Loading…
Reference in New Issue