show waypoint of current mapcleaner location on /mapcleaner_status

This commit is contained in:
BuckarooBanzay 2020-06-05 11:09:50 +02:00
parent 69ced55559
commit d43337af32

View File

@ -1,5 +1,32 @@
local storage = mapcleaner.storage
-- shows a waypoint for given seconds
local function show_waypoint(playername, pos, name, seconds)
local player = minetest.get_player_by_name(playername)
if not player then
return
end
local id = player:hud_add({
hud_elem_type = "waypoint",
name = name,
text = "m",
number = 0xFF0000,
world_pos = pos
})
minetest.after(seconds, function()
player = minetest.get_player_by_name(playername)
if not player then
return
end
player:hud_remove(id)
end)
end
minetest.register_chatcommand("mapcleaner_status", {
func = function(name)
local chunk_x = storage:get_int("chunk_x")
@ -10,6 +37,14 @@ minetest.register_chatcommand("mapcleaner_status", {
local delete_count = storage:get_int("delete_count")
local visited_count = storage:get_int("visited_count")
-- calculate node position
local pos = {
x = (chunk_x * 80) + 40,
y = (chunk_y * 80) + 40,
z = (chunk_z * 80) + 40
}
show_waypoint(name, pos, "Mapcleaner", 10)
return true, "Generated: " .. generated_count ..
" Protected: " .. protected_count ..
" Deleted: " .. delete_count ..