mapcleaner/chat.lua

90 lines
2.4 KiB
Lua
Raw Normal View History

2019-12-29 18:46:07 +01:00
local storage = mapcleaner.storage
2019-12-29 17:56:55 +01:00
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
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
storage:set_string("max_time_usage", value)
2019-12-30 20:34:50 +01:00
return true, "New value: " .. value
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
storage:set_string("step_interval", value)
2019-12-30 20:34:50 +01:00
return true, "New value: " .. value
2019-12-30 20:34:50 +01:00
else
return true, "Value: " .. mapcleaner.step_interval
end
end
})
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
})