Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
ef0a4e36
Commit
ef0a4e36
authored
10 years ago
by
ShadowNinja
Browse files
Options
Downloads
Patches
Plain Diff
Add registered_ores and registered_decorations
parent
beb6b3e5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
builtin/game/register.lua
+22
-7
22 additions, 7 deletions
builtin/game/register.lua
doc/lua_api.txt
+17
-7
17 additions, 7 deletions
doc/lua_api.txt
with
39 additions
and
14 deletions
builtin/game/register.lua
+
22
−
7
View file @
ef0a4e36
...
...
@@ -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()
...
...
This diff is collapsed.
Click to expand it.
doc/lua_api.txt
+
17
−
7
View file @
ef0a4e36
...
...
@@ -416,6 +416,12 @@ the global `minetest.registered_*` tables.
* `minetest.register_craftitem(name, item definition)`
* added to `minetest.registered_items[name]`
* `minetest.register_ore(ore definition)`
* added to `minetest.registered_ores`
* `minetest.register_decoration(decoration definition)`
* added to `minetest.registered_decorations`
Note that in some cases you will stumble upon things that are not contained
in these tables (e.g. when a mod has been removed). Always check for
existence before trying to access the fields.
...
...
@@ -2193,19 +2199,23 @@ Please note that forceloaded areas are saved when the server restarts.
### Global tables
* `minetest.registered_items`
*
List
of registered items, indexed by name
*
Map
of registered items, indexed by name
* `minetest.registered_nodes`
*
List
of registered node definitions, indexed by name
*
Map
of registered node definitions, indexed by name
* `minetest.registered_craftitems`
*
List
of registered craft item definitions, indexed by name
*
Map
of registered craft item definitions, indexed by name
* `minetest.registered_tools`
*
List
of registered tool definitions, indexed by name
*
Map
of registered tool definitions, indexed by name
* `minetest.registered_entities`
*
List
of registered entity prototypes, indexed by name
*
Map
of registered entity prototypes, indexed by name
* `minetest.object_refs`
*
List
of object references, indexed by active object id
*
Map
of object references, indexed by active object id
* `minetest.luaentities`
* List of Lua entities, indexed by active object id
* Map of Lua entities, indexed by active object id
* `minetest.registered_ores`
* List of registered ore definitions.
* `minetest.registered_decorations`
* List of registered decoration definitions.
Class reference
---------------
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment