tidy breed function
This commit is contained in:
parent
b4a943690c
commit
0dc95615e5
32
api.lua
32
api.lua
@ -21,6 +21,8 @@ else
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local FS = function(...) return minetest.formspec_escape(S(...)) end
|
||||||
|
|
||||||
|
|
||||||
-- CMI support check
|
-- CMI support check
|
||||||
local use_cmi = minetest.global_exists("cmi")
|
local use_cmi = minetest.global_exists("cmi")
|
||||||
@ -34,8 +36,8 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
|
|||||||
-- Global
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20230816",
|
version = "20230927",
|
||||||
intllib = S,
|
translate = S, intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||||
or (use_mc2 and "mcl_core:snow") or "default:snow",
|
or (use_mc2 and "mcl_core:snow") or "default:snow",
|
||||||
@ -1587,6 +1589,8 @@ function mob_class:breed()
|
|||||||
-- make sure baby is actually there
|
-- make sure baby is actually there
|
||||||
if ent2 then
|
if ent2 then
|
||||||
|
|
||||||
|
textures = self.base_texture
|
||||||
|
|
||||||
-- using specific child texture (if found)
|
-- using specific child texture (if found)
|
||||||
if self.child_texture then
|
if self.child_texture then
|
||||||
textures = self.child_texture[1]
|
textures = self.child_texture[1]
|
||||||
@ -1675,8 +1679,7 @@ function mob_class:replace(pos)
|
|||||||
local newnode = with
|
local newnode = with
|
||||||
|
|
||||||
-- pass actual node name when using table or groups
|
-- pass actual node name when using table or groups
|
||||||
if type(oldnode) == "table"
|
if type(oldnode) == "table" or oldnode:find("group:") then
|
||||||
or oldnode:find("group:") then
|
|
||||||
oldnode = minetest.get_node(pos).name
|
oldnode = minetest.get_node(pos).name
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2485,6 +2488,11 @@ function mob_class:do_states(dtime)
|
|||||||
self:set_velocity(0)
|
self:set_velocity(0)
|
||||||
self.state = "stand"
|
self.state = "stand"
|
||||||
self:set_animation("stand")
|
self:set_animation("stand")
|
||||||
|
|
||||||
|
-- try to turn so we are not stuck
|
||||||
|
yaw = yaw + random(-1, 1) * 1.5
|
||||||
|
yaw = self:set_yaw(yaw, 4)
|
||||||
|
|
||||||
else
|
else
|
||||||
self:set_velocity(self.run_velocity)
|
self:set_velocity(self.run_velocity)
|
||||||
self:set_animation("walk")
|
self:set_animation("walk")
|
||||||
@ -3929,6 +3937,8 @@ function mobs:add_mob(pos, def)
|
|||||||
if not ent then
|
if not ent then
|
||||||
--print("[mobs] entity not found " .. def.name)
|
--print("[mobs] entity not found " .. def.name)
|
||||||
return false
|
return false
|
||||||
|
else
|
||||||
|
effect(pos, 15, "tnt_smoke.png", 1, 2, 2, 15, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
if def.child then
|
if def.child then
|
||||||
@ -4762,7 +4772,6 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
self.health = self.health + 4
|
self.health = self.health + 4
|
||||||
|
|
||||||
if self.health >= self.hp_max then
|
if self.health >= self.hp_max then
|
||||||
|
|
||||||
self.health = self.hp_max
|
self.health = self.hp_max
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -4821,8 +4830,7 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
|
|
||||||
-- if mob has been tamed you can name it with a nametag
|
-- if mob has been tamed you can name it with a nametag
|
||||||
if item:get_name() == "mobs:nametag"
|
if item:get_name() == "mobs:nametag"
|
||||||
and (name == self.owner
|
and (name == self.owner or minetest.check_player_privs(name, "protection_bypass")) then
|
||||||
or minetest.check_player_privs(name, "protection_bypass")) then
|
|
||||||
|
|
||||||
-- store mob and nametag stack in external variables
|
-- store mob and nametag stack in external variables
|
||||||
mob_obj[name] = self
|
mob_obj[name] = self
|
||||||
@ -4831,13 +4839,9 @@ function mobs:feed_tame(self, clicker, feed_count, breed, tame)
|
|||||||
local tag = self.nametag or ""
|
local tag = self.nametag or ""
|
||||||
local esc = minetest.formspec_escape
|
local esc = minetest.formspec_escape
|
||||||
|
|
||||||
minetest.show_formspec(name, "mobs_nametag",
|
minetest.show_formspec(name, "mobs_nametag", "size[8,4]"
|
||||||
"size[8,4]" ..
|
.. "field[0.5,1;7.5,0;name;" .. esc(FS("Enter name:")) .. ";" .. esc(tag) .. "]"
|
||||||
"field[0.5,1;7.5,0;name;" ..
|
.. "button_exit[2.5,3.5;3,1;mob_rename;" .. esc(FS("Rename")) .. "]")
|
||||||
esc(S("Enter name:")) ..
|
|
||||||
";" .. tag .. "]" ..
|
|
||||||
"button_exit[2.5,3.5;3,1;mob_rename;" ..
|
|
||||||
esc(FS("Rename")) .. "]")
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user