Aaron Suen d0e6dcc410 Add "stasis" option and command.
This freezes many things that normally happen automatically
in the world, including most ABMs and AISMs, and a few other
custom step logic items like the player "hot potato" logic.

This can be used for "creative mode" purposes to setup a complex
build without it running itself away from you, and for texture
pack authors, to have time to see things that are normally
transient or difficult to observe because of the effects they have
on nearby things or players.
2020-01-10 06:26:07 -05:00

41 lines
1.1 KiB
Lua

-- LUALOCALS < ---------------------------------------------------------
local minetest, nodecore
= minetest, nodecore
-- LUALOCALS > ---------------------------------------------------------
if nodecore.stasis == nil then
nodecore.stasis = minetest.settings:get_bool("nodecore_stasis")
end
minetest.register_chatcommand("stasis", {
description = "toggle world stasis",
privs = {server = true},
params = "[on|off]",
func = function(_, param)
if param and param ~= "" then
if param:lower() == "on" then
nodecore.stasis = true
elseif param:lower() == "off" then
nodecore.stasis = false
else
return false, "/stasis param not recognized"
end
else
nodecore.stasis = not nodecore.stasis
end
return true, "World is now " .. (nodecore.stasis and "FROZEN" or "ACTIVE")
end
})
local abm = minetest.register_abm
function minetest.register_abm(def, ...)
if not def.ignore_stasis then
local act = def.action
def.action = function(...)
if nodecore.stasis then return end
return act(...)
end
end
return abm(def, ...)
end