mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-24 16:20:19 +01:00
mobs:add_mob() can now set mob texture
This commit is contained in:
parent
768ef84bd8
commit
ce47b81da5
19
api.lua
19
api.lua
@ -11,7 +11,7 @@ local use_mc2 = minetest.get_modpath("mcl_core")
|
|||||||
-- Global
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20231012",
|
version = "20231015",
|
||||||
translate = S,
|
translate = 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"]
|
||||||
@ -3851,18 +3851,22 @@ function mobs:add_mob(pos, def)
|
|||||||
effect(pos, 15, "tnt_smoke.png", 1, 2, 2, 15, 5)
|
effect(pos, 15, "tnt_smoke.png", 1, 2, 2, 15, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- use new texture if found
|
||||||
|
local new_texture = def.texture or ent.base_texture
|
||||||
|
|
||||||
if def.child then
|
if def.child then
|
||||||
|
|
||||||
local textures = ent.base_texture
|
ent.mommy_tex = new_texture -- how baby looks when grown
|
||||||
|
ent.base_texture = new_texture
|
||||||
|
|
||||||
-- using specific child texture (if found)
|
-- using specific child texture (if found)
|
||||||
if ent.child_texture then
|
if ent.child_texture then
|
||||||
textures = ent.child_texture[1]
|
new_texture = ent.child_texture[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- and resize to half height (multiplication is faster than division)
|
-- and resize to half height (multiplication is faster than division)
|
||||||
mob:set_properties({
|
mob:set_properties({
|
||||||
textures = textures,
|
textures = new_texture,
|
||||||
visual_size = {
|
visual_size = {
|
||||||
x = ent.base_size.x * .5,
|
x = ent.base_size.x * .5,
|
||||||
y = ent.base_size.y * .5
|
y = ent.base_size.y * .5
|
||||||
@ -3886,6 +3890,13 @@ function mobs:add_mob(pos, def)
|
|||||||
})
|
})
|
||||||
|
|
||||||
ent.child = true
|
ent.child = true
|
||||||
|
|
||||||
|
-- if not child set new texture
|
||||||
|
elseif def.texture then
|
||||||
|
|
||||||
|
ent.base_texture = new_texture
|
||||||
|
|
||||||
|
mob:set_properties({textures = new_texture})
|
||||||
end
|
end
|
||||||
|
|
||||||
if def.owner then
|
if def.owner then
|
||||||
|
Loading…
Reference in New Issue
Block a user