aboutsummaryrefslogtreecommitdiff
path: root/builtin/game
diff options
context:
space:
mode:
authorzeuner <github@quidecco.de>2017-08-27 16:39:47 +0000
committerSmallJoker <SmallJoker@users.noreply.github.com>2017-08-27 18:39:47 +0200
commit1f207a3ddbb5fbe903996a924443d9f9522b48a8 (patch)
tree3b7899b6757780ba3c9f7e22e93c455c98eedcc3 /builtin/game
parente09c7fceaa93ad3d7d85f657df0663f6efc70281 (diff)
downloadminetest-1f207a3ddbb5fbe903996a924443d9f9522b48a8.tar.gz
minetest-1f207a3ddbb5fbe903996a924443d9f9522b48a8.tar.bz2
minetest-1f207a3ddbb5fbe903996a924443d9f9522b48a8.zip
Lua API: Add function to deregister single biomes (#5445)
Diffstat (limited to 'builtin/game')
-rw-r--r--builtin/game/register.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index 87d1c5659..ad16651f8 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -505,6 +505,19 @@ local function make_registration_wrap(reg_fn_name, clear_fn_name)
return list
end
+local function make_wrap_deregistration(reg_fn, clear_fn, list)
+ local unregister = function (unregistered_key)
+ local temporary_list = table.copy(list)
+ clear_fn()
+ for k,v in pairs(temporary_list) do
+ if unregistered_key ~= k then
+ reg_fn(v)
+ end
+ end
+ end
+ return unregister
+end
+
core.registered_on_player_hpchanges = { modifiers = { }, loggers = { } }
function core.registered_on_player_hpchange(player, hp_change)
@@ -543,6 +556,8 @@ core.registered_biomes = make_registration_wrap("register_biome", "cle
core.registered_ores = make_registration_wrap("register_ore", "clear_registered_ores")
core.registered_decorations = make_registration_wrap("register_decoration", "clear_registered_decorations")
+core.unregister_biome = make_wrap_deregistration(core.register_biome, core.clear_registered_biomes, core.registered_biomes)
+
core.registered_on_chat_messages, core.register_on_chat_message = make_registration()
core.registered_globalsteps, core.register_globalstep = make_registration()
core.registered_playerevents, core.register_playerevent = make_registration()