2019-12-29 18:46:07 +01:00
|
|
|
local storage = mapcleaner.storage
|
2019-12-29 17:56:55 +01:00
|
|
|
|
2020-06-05 11:09:50 +02:00
|
|
|
|
|
|
|
-- 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
|
|
|
|
|
|
|
|
|
2019-12-29 18:46:07 +01:00
|
|
|
minetest.register_chatcommand("mapcleaner_status", {
|
2019-12-29 17:56:55 +01:00
|
|
|
func = function(name)
|
2019-12-29 18:46:07 +01:00
|
|
|
local chunk_x = storage:get_int("chunk_x")
|
|
|
|
local chunk_y = storage:get_int("chunk_y")
|
|
|
|
local chunk_z = storage:get_int("chunk_z")
|
|
|
|
local generated_count = storage:get_int("generated_count")
|
|
|
|
local protected_count = storage:get_int("protected_count")
|
|
|
|
local delete_count = storage:get_int("delete_count")
|
|
|
|
local visited_count = storage:get_int("visited_count")
|
2019-12-29 17:56:55 +01:00
|
|
|
|
2020-06-05 11:09:50 +02:00
|
|
|
-- 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)
|
|
|
|
|
2019-12-29 17:56:55 +01:00
|
|
|
return true, "Generated: " .. generated_count ..
|
|
|
|
" Protected: " .. protected_count ..
|
|
|
|
" Deleted: " .. delete_count ..
|
2019-12-29 18:46:07 +01:00
|
|
|
" Count: " .. visited_count ..
|
|
|
|
" current chunk: " .. chunk_x .. "/" .. chunk_y .. "/" .. chunk_z
|
2019-12-29 17:56:55 +01:00
|
|
|
end
|
|
|
|
})
|
2019-12-30 20:34:50 +01:00
|
|
|
|
|
|
|
minetest.register_chatcommand("mapcleaner_max_time", {
|
|
|
|
description = "sets the max time usage in microseconds",
|
|
|
|
privs = { server = true },
|
|
|
|
func = function(name, params)
|
|
|
|
local value = tonumber(params)
|
|
|
|
if value then
|
|
|
|
mapcleaner.max_time_usage = value
|
2020-01-07 12:54:52 +01:00
|
|
|
storage:set_string("max_time_usage", value)
|
2019-12-30 20:34:50 +01:00
|
|
|
return true, "New value: " .. value
|
2020-01-07 12:54:52 +01:00
|
|
|
|
2019-12-30 20:34:50 +01:00
|
|
|
else
|
|
|
|
return true, "Value: " .. mapcleaner.max_time_usage
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2020-02-03 08:49:33 +01:00
|
|
|
minetest.register_chatcommand("mapcleaner_max_lag", {
|
|
|
|
description = "sets the max lag value in seconds",
|
|
|
|
privs = { server = true },
|
|
|
|
func = function(name, params)
|
|
|
|
local value = tonumber(params)
|
|
|
|
if value then
|
|
|
|
mapcleaner.max_lag = value
|
|
|
|
storage:set_string("max_lag", value)
|
|
|
|
return true, "New value: " .. value
|
|
|
|
|
|
|
|
else
|
|
|
|
return true, "Value: " .. mapcleaner.max_lag
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2019-12-30 20:34:50 +01:00
|
|
|
minetest.register_chatcommand("mapcleaner_step_interval", {
|
|
|
|
description = "sets the step_interval in seconds",
|
|
|
|
privs = { server = true },
|
|
|
|
func = function(name, params)
|
|
|
|
local value = tonumber(params)
|
|
|
|
if value then
|
|
|
|
mapcleaner.step_interval = value
|
2020-01-07 12:54:52 +01:00
|
|
|
storage:set_string("step_interval", value)
|
2019-12-30 20:34:50 +01:00
|
|
|
return true, "New value: " .. value
|
2020-01-07 12:54:52 +01:00
|
|
|
|
2019-12-30 20:34:50 +01:00
|
|
|
else
|
|
|
|
return true, "Value: " .. mapcleaner.step_interval
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
2020-01-07 12:54:52 +01:00
|
|
|
|
|
|
|
minetest.register_chatcommand("mapcleaner_run", {
|
|
|
|
description = "sets or gets the run state",
|
|
|
|
privs = { server = true },
|
|
|
|
func = function(name, params)
|
|
|
|
if params == "true" then
|
|
|
|
mapcleaner.run = true
|
|
|
|
storage:set_string("run", "1")
|
|
|
|
|
|
|
|
elseif params == "false" then
|
|
|
|
mapcleaner.run = false
|
|
|
|
storage:set_string("run", "0")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if mapcleaner.run then
|
|
|
|
return true, "mapcleaner running!"
|
|
|
|
else
|
|
|
|
return true, "mapcleaner stopped"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|