mirror of
https://github.com/ElCeejo/animalia.git
synced 2025-03-15 04:11:25 +00:00
Crash fixes, multimesh support
This commit is contained in:
parent
2b48caa781
commit
1b9382bee3
6 changed files with 49 additions and 102 deletions
|
@ -222,6 +222,7 @@ end
|
|||
------------------------
|
||||
-- Environment Access --
|
||||
------------------------
|
||||
|
||||
function animalia.get_nearby_mate(self)
|
||||
local pos = self.object:get_pos()
|
||||
if not pos then return end
|
||||
|
|
112
api/libri.lua
112
api/libri.lua
|
@ -38,7 +38,7 @@ local generate_mobs = {
|
|||
["animalia:chicken"] = "Chicken",
|
||||
["animalia:cow"] = "Cow",
|
||||
["animalia:owl"] = "Owl",
|
||||
--["animalia:tropical_fish"] = "Tropical Fish",
|
||||
["animalia:tropical_fish"] = "Tropical Fish",
|
||||
["animalia:fox"] = "Fox",
|
||||
["animalia:frog"] = "Frog",
|
||||
["animalia:horse"] = "Horse",
|
||||
|
@ -93,15 +93,24 @@ local function max_health(name)
|
|||
return minetest.registered_entities[name].max_health or 20
|
||||
end
|
||||
|
||||
local function mob_textures(name)
|
||||
local function mob_textures(name, mesh_no)
|
||||
local def = minetest.registered_entities[name]
|
||||
return def.textures or {unpack(def.male_textures), unpack(def.female_textures)}
|
||||
local textures = def.textures
|
||||
if def.male_textures
|
||||
or def.female_textures then
|
||||
textures = {unpack(def.male_textures), unpack(def.female_textures)}
|
||||
end
|
||||
if def.mesh_textures then
|
||||
textures = def.mesh_textures[mesh_no or 1]
|
||||
end
|
||||
return textures
|
||||
end
|
||||
|
||||
local biome_cubes = {}
|
||||
|
||||
local function generate_page(mob)
|
||||
local name = mob:split(":")[2]
|
||||
local def = minetest.registered_entities[mob]
|
||||
local page = {
|
||||
{ -- Info
|
||||
element_type = "label",
|
||||
|
@ -114,8 +123,9 @@ local function generate_page(mob)
|
|||
element_type = "model",
|
||||
offset = {x = 1.5, y = 1.5},
|
||||
size = {x = 5, y = 5},
|
||||
mesh_iter = def.meshes and 1,
|
||||
texture_iter = 1,
|
||||
text = "mesh;animalia_bat.b3d;" .. mob_textures(mob)[1] .. ";-30,225;false;false;0,0;0"
|
||||
text = "mesh;" .. def.mesh .. ";" .. mob_textures(mob)[1] .. ";-30,225;false;false;0,0;0"
|
||||
},
|
||||
{ -- Spawn Biome
|
||||
element_type = "image",
|
||||
|
@ -228,82 +238,6 @@ minetest.register_on_mods_loaded(function()
|
|||
start_iter = 12,
|
||||
offset = {x = 1.75, y = 1.5}
|
||||
}
|
||||
},
|
||||
["animalia:tropical_fish"] = {
|
||||
{ -- Info
|
||||
element_type = "label",
|
||||
center_text = true,
|
||||
font_size = 20,
|
||||
offset = {x = 8, y = 1.5},
|
||||
file = "animalia_libri_tropical_fish.txt"
|
||||
},
|
||||
{ -- Image
|
||||
element_type = "model",
|
||||
offset = {x = 1.5, y = 1.5},
|
||||
size = {x = 5, y = 5},
|
||||
texture_iter = 1,
|
||||
models = {
|
||||
"animalia_clownfish.b3d",
|
||||
"animalia_clownfish.b3d",
|
||||
"animalia_angelfish.b3d"
|
||||
},
|
||||
text = "mesh;animalia_clownfish.b3d;" .. mob_textures("animalia:tropical_fish")[1] .. ";-30,225;false;false;0,0;0"
|
||||
},
|
||||
{ -- Spawn Biome
|
||||
element_type = "image",
|
||||
offset = {x = 0.825, y = 8.15},
|
||||
size = {x = 1, y = 1},
|
||||
biome_iter = 1,
|
||||
text = biome_cubes[get_spawn_biomes("animalia:tropical_fish")[1]]
|
||||
},
|
||||
{ -- Biome Label
|
||||
element_type = "tooltip",
|
||||
offset = {x = 0.825, y = 8.15},
|
||||
size = {x = 1, y = 1},
|
||||
biome_iter = 1,
|
||||
text = correct_string(get_spawn_biomes("animalia:tropical_fish")[1])
|
||||
},
|
||||
libri.render_element({ -- Health Icon
|
||||
element_type = "image",
|
||||
offset = {x = 2.535, y = 8.15},
|
||||
size = {x = 1, y = 1},
|
||||
text = "animalia_libri_health_fg.png"
|
||||
}),
|
||||
libri.render_element({ -- Health Amount
|
||||
element_type = "label",
|
||||
offset = {x = 3.25, y = 9},
|
||||
text = "x" .. max_health("animalia:tropical_fish") / 2
|
||||
}),
|
||||
libri.render_element({ -- Lasso Icon
|
||||
element_type = "item_image",
|
||||
offset = {x = 4.25, y = 8.15},
|
||||
size = {x = 1, y = 1},
|
||||
text = "animalia:lasso"
|
||||
}),
|
||||
libri.render_element({ -- Lasso Indication Icon
|
||||
element_type = "image",
|
||||
offset = {x = 4.75, y = 8.75},
|
||||
size = {x = 0.5, y = 0.5},
|
||||
text = "animalia_libri_" .. can_lasso("animalia:tropical_fish") .. "_icon.png"
|
||||
}),
|
||||
libri.render_element({ -- Net Icon
|
||||
element_type = "item_image",
|
||||
offset = {x = 6, y = 8.15},
|
||||
size = {x = 1, y = 1},
|
||||
text = "animalia:net"
|
||||
}),
|
||||
libri.render_element({ -- Net Indication Icon
|
||||
element_type = "image",
|
||||
offset = {x = 6.5, y = 8.75},
|
||||
size = {x = 0.5, y = 0.5},
|
||||
text = "animalia_libri_" .. can_net("animalia:tropical_fish") .. "_icon.png"
|
||||
}),
|
||||
libri.render_element({ -- Styling
|
||||
element_type = "image",
|
||||
offset = {x = -0.7, y = -0.5},
|
||||
size = {x = 17.5, y = 11.5},
|
||||
text = "animalia_libri_info_fg.png"
|
||||
})
|
||||
}
|
||||
}
|
||||
for mob in pairs(generate_mobs) do
|
||||
|
@ -462,13 +396,19 @@ local function iterate_libri_images()
|
|||
if page ~= "home" then
|
||||
for _, info in ipairs(elements) do
|
||||
if info.texture_iter then
|
||||
local textures = mob_textures(page)
|
||||
if textures[info.texture_iter + 1] then
|
||||
info.texture_iter = info.texture_iter + 1
|
||||
else
|
||||
info.texture_iter = 1
|
||||
local def = minetest.registered_entities[page]
|
||||
local textures = mob_textures(page, info.mesh_iter)
|
||||
|
||||
local tex_i = info.texture_iter
|
||||
info.texture_iter = (textures[tex_i + 1] and tex_i + 1) or 1
|
||||
|
||||
local mesh_i = info.mesh_iter
|
||||
if info.texture_iter < 2 then -- Only iterate mesh if all textures have been shown
|
||||
info.mesh_iter = def.meshes and ((def.meshes[mesh_i + 1] and mesh_i + 1) or 1)
|
||||
textures = mob_textures(page, info.mesh_iter)
|
||||
end
|
||||
local mesh = (info.models and info.models[info.texture_iter]) or minetest.registered_entities[page].mesh
|
||||
|
||||
local mesh = (info.mesh_iter and def.meshes[info.mesh_iter]) or def.mesh
|
||||
info.text = "mesh;" .. mesh .. ";" .. textures[info.texture_iter] .. ";-30,225;false;false;0,0;0]"
|
||||
end
|
||||
if info.biome_iter then
|
||||
|
|
3
init.lua
3
init.lua
|
@ -84,7 +84,8 @@ minetest.register_on_mods_loaded(function()
|
|||
local pets = (name and animalia.pets[name]) or {}
|
||||
for _, obj in ipairs(pets) do
|
||||
local ent = obj and obj:get_luaentity()
|
||||
if ent.assist_owner then
|
||||
if ent
|
||||
and ent.assist_owner then
|
||||
ent.owner_target = self
|
||||
end
|
||||
end
|
||||
|
|
|
@ -204,4 +204,4 @@ creatura.register_mob("animalia:bat", {
|
|||
creatura.register_spawn_item("animalia:bat", {
|
||||
col1 = "392517",
|
||||
col2 = "321b0b"
|
||||
})
|
||||
})
|
|
@ -323,9 +323,12 @@ creatura.register_mob("animalia:cat", {
|
|||
self:memorize("trust", self.trust)
|
||||
end,
|
||||
deactivate_func = function(self)
|
||||
if self.owner
|
||||
and animalia.pets[self.owner][self.object] then
|
||||
animalia.pets[self.owner][self.object] = nil
|
||||
if self.owner then
|
||||
for i, object in ipairs(animalia.pets[self.owner] or {}) do
|
||||
if object == self.object then
|
||||
animalia.pets[self.owner][i] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
|
@ -18,16 +18,23 @@ creatura.register_mob("animalia:tropical_fish", {
|
|||
boid_seperation = 0.3,
|
||||
bouyancy_multiplier = 0,
|
||||
-- Visuals
|
||||
mesh = "animalia_clownfish.b3d",
|
||||
meshes = {
|
||||
"animalia_clownfish.b3d",
|
||||
"animalia_angelfish.b3d"
|
||||
},
|
||||
hitbox = {
|
||||
width = 0.15,
|
||||
height = 0.3
|
||||
},
|
||||
visual_size = {x = 7, y = 7},
|
||||
textures = {
|
||||
"animalia_clownfish.png",
|
||||
"animalia_blue_tang.png",
|
||||
"animalia_angelfish.png"
|
||||
visual_size = {x = 10, y = 10},
|
||||
mesh_textures = {
|
||||
{
|
||||
"animalia_clownfish.png",
|
||||
"animalia_blue_tang.png"
|
||||
},
|
||||
{
|
||||
"animalia_angelfish.png"
|
||||
}
|
||||
},
|
||||
animations = {
|
||||
swim = {range = {x = 1, y = 20}, speed = 20, frame_blend = 0.3, loop = true},
|
||||
|
@ -61,11 +68,6 @@ creatura.register_mob("animalia:tropical_fish", {
|
|||
activate_func = function(self)
|
||||
animalia.initialize_api(self)
|
||||
animalia.initialize_lasso(self)
|
||||
if self.texture_no == 3 then
|
||||
self.object:set_properties({
|
||||
mesh = "animalia_angelfish.b3d",
|
||||
})
|
||||
end
|
||||
end,
|
||||
step_func = function(self)
|
||||
animalia.step_timers(self)
|
||||
|
|
Loading…
Add table
Reference in a new issue