2019-10-02 20:33:39 +03:00
|
|
|
--[[
|
|
|
|
|
|
|
|
TechAge
|
|
|
|
=======
|
|
|
|
|
|
|
|
Copyright (C) 2019 Joachim Stolberg
|
|
|
|
|
|
|
|
GPL v3
|
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
mark.lua:
|
|
|
|
|
|
|
|
]]--
|
|
|
|
|
|
|
|
local marker_region = {}
|
|
|
|
|
|
|
|
function techage.unmark_position(name)
|
|
|
|
if marker_region[name] ~= nil then --marker already exists
|
|
|
|
--wip: make the area stay loaded somehow
|
|
|
|
for _, entity in ipairs(marker_region[name]) do
|
|
|
|
entity:remove()
|
|
|
|
end
|
|
|
|
marker_region[name] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-27 13:14:37 +03:00
|
|
|
function techage.mark_position(name, pos, nametag, color, time)
|
2019-10-02 20:33:39 +03:00
|
|
|
local marker = minetest.add_entity(pos, "techage:position_cube")
|
|
|
|
if marker ~= nil then
|
|
|
|
marker:set_nametag_attributes({color = color, text = nametag})
|
|
|
|
marker:get_luaentity().player_name = name
|
|
|
|
if not marker_region[name] then
|
|
|
|
marker_region[name] = {}
|
|
|
|
end
|
|
|
|
marker_region[name][#marker_region[name] + 1] = marker
|
|
|
|
end
|
2019-10-27 13:14:37 +03:00
|
|
|
minetest.after(time or 30, techage.unmark_position, name)
|
2019-10-02 20:33:39 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_entity(":techage:position_cube", {
|
|
|
|
initial_properties = {
|
|
|
|
visual = "cube",
|
|
|
|
textures = {
|
|
|
|
"techage_cube_mark.png",
|
|
|
|
"techage_cube_mark.png",
|
|
|
|
"techage_cube_mark.png",
|
|
|
|
"techage_cube_mark.png",
|
|
|
|
"techage_cube_mark.png",
|
|
|
|
"techage_cube_mark.png",
|
|
|
|
},
|
|
|
|
--use_texture_alpha = true,
|
|
|
|
physical = false,
|
2019-11-08 23:10:05 +03:00
|
|
|
visual_size = {x = 1.1, y = 1.1},
|
|
|
|
collisionbox = {-0.55,-0.55,-0.55, 0.55,0.55,0.55},
|
2019-10-02 20:33:39 +03:00
|
|
|
glow = 8,
|
|
|
|
},
|
|
|
|
on_step = function(self, dtime)
|
|
|
|
if marker_region[self.player_name] == nil then
|
|
|
|
self.object:remove()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
on_punch = function(self, hitter)
|
|
|
|
techage.unmark_position(self.player_name)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|