mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-23 02:51:06 +01:00
Finally indent register_mob and make registered mobs global
This commit is contained in:
parent
a3415647d4
commit
bc496a8682
1 changed files with 198 additions and 196 deletions
|
@ -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,33 +112,33 @@ 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
|
||||
local can_despawn
|
||||
if def.can_despawn ~= nil then
|
||||
can_despawn = def.can_despawn
|
||||
elseif def.spawn_class == "passive" then
|
||||
elseif def.spawn_class == "passive" then
|
||||
can_despawn = false
|
||||
else
|
||||
else
|
||||
can_despawn = true
|
||||
end
|
||||
end
|
||||
|
||||
local function scale_difficulty(value, default, min, special)
|
||||
local function scale_difficulty(value, default, min, special)
|
||||
if (not value) or (value == default) or (value == special) then
|
||||
return default
|
||||
else
|
||||
return math.max(min, value * difficulty)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local collisionbox = def.collisionbox or {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}
|
||||
-- Workaround for <https://github.com/minetest/minetest/issues/5966>:
|
||||
-- Increase upper Y limit to avoid mobs glitching through solid nodes.
|
||||
-- FIXME: Remove workaround if it's no longer needed.
|
||||
if collisionbox[5] < 0.79 then
|
||||
local collisionbox = def.collisionbox or {-0.25, -0.25, -0.25, 0.25, 0.25, 0.25}
|
||||
-- Workaround for <https://github.com/minetest/minetest/issues/5966>:
|
||||
-- Increase upper Y limit to avoid mobs glitching through solid nodes.
|
||||
-- FIXME: Remove workaround if it's no longer needed.
|
||||
if collisionbox[5] < 0.79 then
|
||||
collisionbox[5] = 0.79
|
||||
end
|
||||
|
||||
minetest.register_entity(name, setmetatable({
|
||||
end
|
||||
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,11 +311,12 @@ 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
|
||||
if minetest.get_modpath("doc_identifier") ~= nil then
|
||||
doc.sub.identifier.register_object(name, "basics", "mobs")
|
||||
end
|
||||
end
|
||||
|
||||
end -- END mcl_mobs.register_mob function
|
||||
|
||||
|
|
Loading…
Reference in a new issue