Finally indent register_mob and make registered mobs global

This commit is contained in:
cora 2022-11-12 02:16:37 +01:00
parent a3415647d4
commit bc496a8682
1 changed files with 198 additions and 196 deletions

View File

@ -1,6 +1,7 @@
mcl_mobs = {}
mcl_mobs.mob_class = {}
mcl_mobs.mob_class_meta = {__index = mcl_mobs.mob_class}
mcl_mobs.registered_mobs = {}
local modname = minetest.get_current_modname()
local path = minetest.get_modpath(modname)
local S = minetest.get_translator(modname)
@ -111,6 +112,7 @@ mcl_mobs.spawning_mobs = {}
function mcl_mobs.register_mob(name, def)
mcl_mobs.spawning_mobs[name] = true
mcl_mobs.registered_mobs[name] = def
local can_despawn
if def.can_despawn ~= nil then
@ -136,8 +138,7 @@ local collisionbox = def.collisionbox or {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}
if collisionbox[5] < 0.79 then
collisionbox[5] = 0.79
end
minetest.register_entity(name, setmetatable({
local final_def = {
use_texture_alpha = def.use_texture_alpha,
head_swivel = def.head_swivel or nil, -- bool to activate this function
head_yaw_offset = def.head_yaw_offset or 0, -- for wonkey model bones
@ -310,7 +311,8 @@ minetest.register_entity(name, setmetatable({
end,
harmed_by_heal = def.harmed_by_heal,
on_lightning_strike = def.on_lightning_strike
},mcl_mobs.mob_class_meta))
}
minetest.register_entity(name, setmetatable(final_def,mcl_mobs.mob_class_meta))
if minetest.get_modpath("doc_identifier") ~= nil then
doc.sub.identifier.register_object(name, "basics", "mobs")