mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-04-17 19:20:22 +02:00
deprecate self.jump and add mobs.compatibility_check function.
This commit is contained in:
parent
5fb7b91db0
commit
854834f04e
17
api.lua
17
api.lua
@ -18,7 +18,7 @@ end
|
||||
-- Global table
|
||||
|
||||
mobs = {
|
||||
mod = "redo", version = "20250320",
|
||||
mod = "redo", version = "20250404",
|
||||
spawning_mobs = {}, translate = S,
|
||||
node_snow = has(minetest.registered_aliases["mapgen_snow"])
|
||||
or has("mcl_core:snow") or has("default:snow") or "air",
|
||||
@ -27,6 +27,10 @@ mobs = {
|
||||
}
|
||||
mobs.fallback_node = mobs.node_dirt
|
||||
|
||||
-- load compatibility check function
|
||||
|
||||
dofile(minetest.get_modpath("mobs") .. "/compatibility.lua")
|
||||
|
||||
-- localize common functions
|
||||
|
||||
local pi, abs, min, max = math.pi, math.abs, math.min, math.max
|
||||
@ -1078,7 +1082,7 @@ function mob_class:do_jump()
|
||||
ndef = minetest.registered_nodes[self.looking_at]
|
||||
|
||||
-- jump if possible
|
||||
if self.jump and self.jump_height > 0
|
||||
if self.jump_height > 0
|
||||
and (self.walk_chance == 0 or (ndef.walkable and ndef.drawtype == "normal"))
|
||||
and not blocked and not self.facing_fence then
|
||||
|
||||
@ -1561,7 +1565,7 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
||||
|
||||
local jumpheight = 0
|
||||
|
||||
if self.jump and self.jump_height >= pathfinding_max_jump then
|
||||
if self.jump_height >= pathfinding_max_jump then
|
||||
|
||||
jumpheight = min(ceil(
|
||||
self.jump_height / pathfinding_max_jump), pathfinding_max_jump)
|
||||
@ -2879,9 +2883,6 @@ function mob_class:mob_staticdata()
|
||||
self.following = nil
|
||||
self.state = "stand"
|
||||
|
||||
-- used to rotate older mobs
|
||||
if self.drawtype and self.drawtype == "side" then self.rotate = rad(90) end
|
||||
|
||||
if use_cmi then
|
||||
self.serialized_cmi_components = cmi.serialize_components(self._cmi_components)
|
||||
end
|
||||
@ -3426,6 +3427,10 @@ function mobs:register_mob(name, def)
|
||||
end
|
||||
|
||||
}, mob_class_meta))
|
||||
|
||||
-- look for any older settings for compatibility
|
||||
local self = minetest.registered_entities[name]
|
||||
mobs.compatibility_check(self)
|
||||
end
|
||||
|
||||
-- count how many mobs of one type are inside an area
|
||||
|
2
api.txt
2
api.txt
@ -50,7 +50,7 @@ functions needed for the mob to work properly which contains the following:
|
||||
set to 0 for jumping mobs only.
|
||||
'randomly_turn' if set to false then mob will not turn to face player or
|
||||
randomly turn while walking or standing.
|
||||
'jump' when true allows your mob to jump updwards.
|
||||
'jump' when true allows your mob to jump updwards[DEPRECATED].
|
||||
'jump_height' holds the height your mob can jump, 0 to disable jumping.
|
||||
'can_leap' when true obstacles like fences or pits wont stop a mob
|
||||
from trying to jump out.
|
||||
|
8
compatibility.lua
Normal file
8
compatibility.lua
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
-- called after mob registration to check for older settings
|
||||
|
||||
function mobs.compatibility_check(self)
|
||||
|
||||
-- simple mobs rotation setting
|
||||
if self.drawtype == "side" then self.rotate = math.rad(90) end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user