aboutsummaryrefslogtreecommitdiff
path: root/chatcommands.lua
diff options
context:
space:
mode:
authorThomas Rudin <thomas@rudin.io>2019-10-12 21:36:18 +0200
committerThomas Rudin <thomas@rudin.io>2019-10-12 21:36:18 +0200
commita792602f6c768855605b4e6496c3921f742bf6da (patch)
tree0c5a23b4a8ebb8f55763024b4eb970d16b8b14d7 /chatcommands.lua
parent3839b34a256701b54c9cb9f5a1091e4a257815da (diff)
downloadmesecons_debug-a792602f6c768855605b4e6496c3921f742bf6da.tar.gz
mesecons_debug-a792602f6c768855605b4e6496c3921f742bf6da.zip
per mapblock penalty and hud display
Diffstat (limited to 'chatcommands.lua')
-rw-r--r--chatcommands.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/chatcommands.lua b/chatcommands.lua
new file mode 100644
index 0000000..58792c3
--- /dev/null
+++ b/chatcommands.lua
@@ -0,0 +1,48 @@
+
+
+minetest.register_chatcommand("mesecons_hud", {
+ description = "mesecons_hud on/off",
+ func = function(name, params)
+ local enable = params == "on"
+ mesecons_debug.hud[name] = enable
+ if enable then
+ return true, "mesecons hud enabled"
+ else
+ return true, "mesecons hud disabled"
+ end
+ end
+})
+
+minetest.register_chatcommand("mesecons_stats", {
+ description = "shows some mesecons stats for the current position",
+ func = function(name)
+ local player = minetest.get_player_by_name(name)
+ if not player then
+ return
+ end
+
+ local ctx = mesecons_debug.get_context(player:get_pos())
+ return true, "Mapblock usage: " .. ctx.avg_micros .. " us/s " ..
+ "(across " .. mesecons_debug.context_store_size .." mapblocks)"
+ end
+})
+
+minetest.register_chatcommand("mesecons_enable", {
+ description = "enables the mesecons globlastep",
+ privs = {mesecons_debug=true},
+ func = function()
+ -- flush actions, while we are on it
+ mesecon.queue.actions = {}
+ mesecons_debug.enabled = true
+ return true, "mesecons enabled"
+ end
+})
+
+minetest.register_chatcommand("mesecons_disable", {
+ description = "disables the mesecons globlastep",
+ privs = {mesecons_debug=true},
+ func = function()
+ mesecons_debug.enabled = false
+ return true, "mesecons disabled"
+ end
+})