mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-11 18:30:21 +01:00
code tidy
This commit is contained in:
parent
6b9331064c
commit
36a26d2d21
36
api.lua
36
api.lua
@ -247,7 +247,7 @@ end
|
|||||||
-- calculate distance
|
-- calculate distance
|
||||||
local get_distance = function(a, b)
|
local get_distance = function(a, b)
|
||||||
|
|
||||||
if not a or not b then return 50 end -- nil check
|
if not a or not b then return 50 end -- nil check and default distance
|
||||||
|
|
||||||
local x, y, z = a.x - b.x, a.y - b.y, a.z - b.z
|
local x, y, z = a.x - b.x, a.y - b.y, a.z - b.z
|
||||||
|
|
||||||
@ -672,8 +672,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- custom particle effects
|
-- custom particle effects
|
||||||
local effect = function(pos, amount, texture, min_size, max_size,
|
local effect = function(
|
||||||
radius, gravity, glow, fall)
|
pos, amount, texture, min_size, max_size, radius, gravity, glow, fall)
|
||||||
|
|
||||||
radius = radius or 2
|
radius = radius or 2
|
||||||
min_size = min_size or 0.5
|
min_size = min_size or 0.5
|
||||||
@ -742,17 +742,11 @@ function mob_class:update_tag()
|
|||||||
local text = ""
|
local text = ""
|
||||||
|
|
||||||
if self.horny == true then
|
if self.horny == true then
|
||||||
|
|
||||||
text = "\nLoving: " .. (self.hornytimer - (HORNY_TIME + HORNY_AGAIN_TIME))
|
text = "\nLoving: " .. (self.hornytimer - (HORNY_TIME + HORNY_AGAIN_TIME))
|
||||||
|
|
||||||
elseif self.child == true then
|
elseif self.child == true then
|
||||||
|
|
||||||
text = "\nGrowing: " .. (self.hornytimer - CHILD_GROW_TIME)
|
text = "\nGrowing: " .. (self.hornytimer - CHILD_GROW_TIME)
|
||||||
|
|
||||||
elseif self._breed_countdown then
|
elseif self._breed_countdown then
|
||||||
|
|
||||||
text = "\nBreeding: " .. self._breed_countdown
|
text = "\nBreeding: " .. self._breed_countdown
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.protected then
|
if self.protected then
|
||||||
@ -769,10 +763,7 @@ function mob_class:update_tag()
|
|||||||
|
|
||||||
-- set changes
|
-- set changes
|
||||||
self.object:set_properties({
|
self.object:set_properties({
|
||||||
nametag = self.nametag,
|
nametag = self.nametag, nametag_color = col, infotext = self.infotext})
|
||||||
nametag_color = col,
|
|
||||||
infotext = self.infotext
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -865,12 +856,7 @@ local remove_mob = function(self, decrease)
|
|||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
|
||||||
if decrease and active_limit > 0 then
|
if decrease and active_limit > 0 then
|
||||||
|
|
||||||
active_mobs = active_mobs - 1
|
active_mobs = active_mobs - 1
|
||||||
|
|
||||||
if active_mobs < 0 then
|
|
||||||
active_mobs = 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
--print("-- active mobs: " .. active_mobs .. " / " .. active_limit)
|
--print("-- active mobs: " .. active_mobs .. " / " .. active_limit)
|
||||||
end
|
end
|
||||||
@ -1640,6 +1626,8 @@ end
|
|||||||
|
|
||||||
local los_switcher = false
|
local los_switcher = false
|
||||||
local height_switcher = false
|
local height_switcher = false
|
||||||
|
|
||||||
|
-- are we able to dig this node and add drops?
|
||||||
local can_dig_drop = function(pos)
|
local can_dig_drop = function(pos)
|
||||||
|
|
||||||
if minetest.is_protected(pos, "") then
|
if minetest.is_protected(pos, "") then
|
||||||
@ -1800,7 +1788,8 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
|||||||
local jumpheight = 0
|
local jumpheight = 0
|
||||||
|
|
||||||
if self.jump and self.jump_height >= pathfinding_max_jump then
|
if self.jump and self.jump_height >= pathfinding_max_jump then
|
||||||
jumpheight = min(ceil(self.jump_height / pathfinding_max_jump), pathfinding_max_jump)
|
jumpheight = min(ceil(
|
||||||
|
self.jump_height / pathfinding_max_jump), pathfinding_max_jump)
|
||||||
|
|
||||||
elseif self.stepheight > 0.5 then
|
elseif self.stepheight > 0.5 then
|
||||||
jumpheight = 1
|
jumpheight = 1
|
||||||
@ -2990,8 +2979,7 @@ function mob_class:on_punch(hitter, tflp, tool_capabilities, dir, damage)
|
|||||||
local up = 2
|
local up = 2
|
||||||
|
|
||||||
-- if already in air then dont go up anymore when hit
|
-- if already in air then dont go up anymore when hit
|
||||||
if v.y > 0
|
if v.y > 0 or self.fly then
|
||||||
or self.fly then
|
|
||||||
up = 0
|
up = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3634,13 +3622,9 @@ minetest.register_entity(name, setmetatable({
|
|||||||
messages = def.messages,
|
messages = def.messages,
|
||||||
|
|
||||||
on_spawn = def.on_spawn,
|
on_spawn = def.on_spawn,
|
||||||
|
|
||||||
on_blast = def.on_blast, -- class redifinition
|
on_blast = def.on_blast, -- class redifinition
|
||||||
|
|
||||||
do_punch = def.do_punch,
|
do_punch = def.do_punch,
|
||||||
|
|
||||||
on_breed = def.on_breed,
|
on_breed = def.on_breed,
|
||||||
|
|
||||||
on_grown = def.on_grown,
|
on_grown = def.on_grown,
|
||||||
|
|
||||||
on_activate = function(self, staticdata, dtime)
|
on_activate = function(self, staticdata, dtime)
|
||||||
@ -4292,7 +4276,7 @@ function mobs:register_egg(mob, desc, background, addegg, no_creative)
|
|||||||
"^[mask:mobs_chicken_egg_overlay.png)"
|
"^[mask:mobs_chicken_egg_overlay.png)"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- register new spawn egg containing mob information
|
-- register new spawn egg containing mob information (cannot be stacked)
|
||||||
minetest.register_craftitem(mob .. "_set", {
|
minetest.register_craftitem(mob .. "_set", {
|
||||||
|
|
||||||
description = S("@1 (Tamed)", desc),
|
description = S("@1 (Tamed)", desc),
|
||||||
|
Loading…
Reference in New Issue
Block a user