Skip to content

Commit

Permalink
show waypoint of current mapcleaner location on /mapcleaner_status
Browse files Browse the repository at this point in the history
  • Loading branch information
BuckarooBanzay committed Jun 5, 2020
1 parent 69ced55 commit d43337a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions chat.lua
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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 ..
Expand Down

0 comments on commit d43337a

Please sign in to comment.