aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2015-01-04 21:30:55 -0500
committerShadowNinja <shadowninja@minetest.net>2015-01-05 18:24:15 -0500
commitef0a4e361440430e9512c7adc278c36956275a5c (patch)
treea8bab33b3cff9fa542d6e88d0b7774b759d7472a /builtin
parentbeb6b3e5937160fab583f5dda2be53a651f0ec71 (diff)
downloadminetest-ef0a4e361440430e9512c7adc278c36956275a5c.tar.gz
minetest-ef0a4e361440430e9512c7adc278c36956275a5c.tar.bz2
minetest-ef0a4e361440430e9512c7adc278c36956275a5c.zip
Add registered_ores and registered_decorations
Diffstat (limited to 'builtin')
-rw-r--r--builtin/game/register.lua29
1 files changed, 22 insertions, 7 deletions
diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index f7ebdee9a..c0c579a25 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -226,13 +226,6 @@ function core.register_alias(name, convert_to)
end
end
-local register_biome_raw = core.register_biome
-core.registered_biomes = {}
-function core.register_biome(biome)
- core.registered_biomes[biome.name] = biome
- register_biome_raw(biome)
-end
-
function core.on_craft(itemstack, player, old_craft_list, craft_inv)
for _, func in ipairs(core.registered_on_crafts) do
itemstack = func(itemstack, player, old_craft_list, craft_inv) or itemstack
@@ -375,6 +368,13 @@ end
-- Callback registration
--
+local register_biome_raw = core.register_biome
+core.registered_biomes = {}
+function core.register_biome(biome)
+ core.registered_biomes[biome.name] = biome
+ register_biome_raw(biome)
+end
+
local function make_registration()
local t = {}
local registerfunc = function(func) table.insert(t, func) end
@@ -387,6 +387,21 @@ local function make_registration_reverse()
return t, registerfunc
end
+local function make_registration_wrap(name)
+ local list = {}
+ local full_name = "register_"..name
+ local orig_func = core[full_name]
+ core[full_name] = function(def)
+ table.insert(list, def)
+ orig_func(def)
+ end
+ return list
+end
+
+
+core.registered_ores = make_registration_wrap("ore")
+core.registered_decorations = make_registration_wrap("decoration")
+
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()