mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-11 10:20:21 +01:00
simplify string/table searches
This commit is contained in:
parent
d65b80fa51
commit
296fad85ca
33
api.lua
33
api.lua
@ -287,7 +287,7 @@ function mob_class:set_velocity(v)
|
|||||||
|
|
||||||
-- if mob standing inside fluid with viscocity which isn't in self.fly_in
|
-- if mob standing inside fluid with viscocity which isn't in self.fly_in
|
||||||
-- then slow down mob accordingly
|
-- then slow down mob accordingly
|
||||||
if visc and visc > 0 and not check_for(self.standing_in, self.fly_in)then
|
if visc and visc > 0 and not check_for(self.standing_in, self.fly_in) then
|
||||||
|
|
||||||
new_vel.x = new_vel.x ~= 0 and new_vel.x / visc or 0
|
new_vel.x = new_vel.x ~= 0 and new_vel.x / visc or 0
|
||||||
new_vel.y = new_vel.y ~= 0 and new_vel.y / visc or 0
|
new_vel.y = new_vel.y ~= 0 and new_vel.y / visc or 0
|
||||||
@ -587,20 +587,9 @@ function mob_class:flight_check()
|
|||||||
|
|
||||||
if not def then return false end
|
if not def then return false end
|
||||||
|
|
||||||
if type(self.fly_in) == "string"
|
-- are we standing inside what we should be to fly/swim ?
|
||||||
and self.standing_in == self.fly_in then
|
if check_for(self.standing_in, self.fly_in) then
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
elseif type(self.fly_in) == "table" then
|
|
||||||
|
|
||||||
for _,fly_in in pairs(self.fly_in) do
|
|
||||||
|
|
||||||
if self.standing_in == fly_in then
|
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- stops mobs getting stuck inside stairs and plantlike nodes
|
-- stops mobs getting stuck inside stairs and plantlike nodes
|
||||||
@ -1289,22 +1278,10 @@ function mob_class:follow_holding(clicker)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local item = clicker:get_wielded_item()
|
local item = clicker:get_wielded_item()
|
||||||
local t = type(self.follow)
|
|
||||||
|
|
||||||
-- single item
|
-- are we holding an item mob can follow ?
|
||||||
if t == "string"
|
if check_for(item:get_name(), self.follow) then
|
||||||
and item:get_name() == self.follow then
|
|
||||||
return true
|
return true
|
||||||
|
|
||||||
-- multiple items
|
|
||||||
elseif t == "table" then
|
|
||||||
|
|
||||||
for no = 1, #self.follow do
|
|
||||||
|
|
||||||
if self.follow[no] == item:get_name() then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
Loading…
Reference in New Issue
Block a user