mirror of
https://github.com/ElCeejo/animalia.git
synced 2025-07-19 12:44:58 -04:00
Updated Libri, Fixed Horse riding visuals
This commit is contained in:
parent
8a34dce37c
commit
e4af546bdc
45 changed files with 1370 additions and 1282 deletions
608
api/api.lua
608
api/api.lua
|
@ -222,6 +222,8 @@ end
|
|||
------------------------
|
||||
|
||||
function animalia.set_nametag(self, clicker)
|
||||
local plyr_name = clicker and clicker:get_player_name()
|
||||
if not plyr_name then return end
|
||||
local item = clicker:get_wielded_item()
|
||||
if item
|
||||
and item:get_name() ~= "animalia:nametag" then
|
||||
|
@ -235,7 +237,7 @@ function animalia.set_nametag(self, clicker)
|
|||
self.nametag = self:memorize("nametag", name)
|
||||
self.despawn_after = self:memorize("despawn_after", nil)
|
||||
activate_nametag(self)
|
||||
if not creative then
|
||||
if not minetest.is_creative_enabled(plyr_name) then
|
||||
item:take_item()
|
||||
clicker:set_wielded_item(item)
|
||||
end
|
||||
|
@ -449,6 +451,13 @@ function animalia.do_growth(self, interval)
|
|||
end
|
||||
end
|
||||
|
||||
function animalia.random_sound(self)
|
||||
if self:timer(8)
|
||||
and random(4) < 2 then
|
||||
self:play_sound("random")
|
||||
end
|
||||
end
|
||||
|
||||
function animalia.add_trust(self, player, amount)
|
||||
self.trust_cooldown = 60
|
||||
local plyr_name = player:get_player_name()
|
||||
|
@ -459,9 +468,11 @@ function animalia.add_trust(self, player, amount)
|
|||
end
|
||||
|
||||
function animalia.feed(self, player, tame, breed)
|
||||
local plyr_name = clicker and clicker:get_player_name()
|
||||
if not plyr_name then return end
|
||||
local item, item_name = self:follow_wielded_item(player)
|
||||
if item_name then
|
||||
if not creative then
|
||||
if not minetest.is_creative_enabled(plyr_name) then
|
||||
item:take_item()
|
||||
player:set_wielded_item(item)
|
||||
end
|
||||
|
@ -538,10 +549,9 @@ function animalia.mount(self, player, params)
|
|||
animate_player(player, "sit", 30)
|
||||
end
|
||||
self.rider = player
|
||||
local mob_size = self.object:get_properties().visual_size
|
||||
local player_size = player:get_properties().visual_size
|
||||
player:set_attach(self.object, "Torso", params.pos, params.rot)
|
||||
player:set_eye_offset({x = 0, y = 25, z = 0}, {x = 0, y = 15, z = 15})
|
||||
self:clear_utility()
|
||||
end
|
||||
|
||||
--------------
|
||||
|
@ -682,592 +692,4 @@ animalia.register_biome_group("common", {
|
|||
min_humidity = 20,
|
||||
max_humidity = 80,
|
||||
min_height = 1
|
||||
})
|
||||
|
||||
---------------
|
||||
-- Libri API --
|
||||
---------------
|
||||
|
||||
local function contains_item(inventory, item)
|
||||
return inventory and inventory:contains_item("main", ItemStack(item))
|
||||
end
|
||||
|
||||
function animalia.get_libri(inventory)
|
||||
local list = inventory:get_list("main")
|
||||
for i = 1, inventory:get_size("main") do
|
||||
local stack = list[i]
|
||||
if stack:get_name()
|
||||
and stack:get_name() == "animalia:libri_animalia" then
|
||||
return stack, i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local get_libri = animalia.get_libri
|
||||
|
||||
function animalia.add_libri_page(self, player, page)
|
||||
local inv = minetest.get_inventory({type = "player", name = player:get_player_name()})
|
||||
if contains_item(inv, "animalia:libri_animalia") then
|
||||
local libri, list_i = get_libri(inv)
|
||||
local pages = minetest.deserialize(libri:get_meta():get_string("pages")) or {}
|
||||
if #pages > 0 then
|
||||
local add_page = true
|
||||
for i = 1, #pages do
|
||||
if pages[i].name == page.name then
|
||||
add_page = false
|
||||
break
|
||||
end
|
||||
end
|
||||
if add_page then
|
||||
table.insert(pages, page)
|
||||
libri:get_meta():set_string("pages", minetest.serialize(pages))
|
||||
inv:set_stack("main", list_i, libri)
|
||||
return true
|
||||
end
|
||||
else
|
||||
table.insert(pages, page)
|
||||
libri:get_meta():set_string("pages", minetest.serialize(pages))
|
||||
inv:set_stack("main", list_i, libri)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function animalia.get_item_list(list, offset_x, offset_y) -- Creates a visual list of items for Libri formspecs
|
||||
local size = 1 / #list
|
||||
if size < 0.45 then size = 0.45 end
|
||||
local spacing = 0.3
|
||||
local total_scale = size + spacing
|
||||
local max_horiz = 3
|
||||
local form = {}
|
||||
for i = 1, #list do
|
||||
local vert_multi = math.floor((i - 1) / max_horiz)
|
||||
local horz_multi = (total_scale * max_horiz) * vert_multi
|
||||
local pos_x = offset_x + ((total_scale * i) - horz_multi)
|
||||
local pos_y = offset_y + (total_scale * vert_multi )
|
||||
table.insert(form, "item_image[" .. pos_x .. "," .. pos_y .. ";" .. size .. "," .. size .. ";" .. list[i] .. "]")
|
||||
end
|
||||
return table.concat(form, "")
|
||||
end
|
||||
|
||||
local function get_inventory_cube(name)
|
||||
local def = minetest.registered_nodes[name]
|
||||
local tiles
|
||||
if name:find(".png") then
|
||||
tiles = {
|
||||
name,
|
||||
name,
|
||||
name
|
||||
}
|
||||
elseif def then
|
||||
tiles = table.copy(def.tiles) or table.copy(def.textures)
|
||||
else
|
||||
return
|
||||
end
|
||||
if not tiles
|
||||
or type(tiles) ~= "table"
|
||||
or #tiles < 1 then
|
||||
return
|
||||
end
|
||||
for i = 1, #tiles do
|
||||
if type(tiles[i]) == "table" then
|
||||
tiles[i] = tiles[i].name
|
||||
end
|
||||
end
|
||||
local cube
|
||||
if #tiles < 3 then
|
||||
cube = minetest.inventorycube(tiles[1], tiles[1], tiles[1])
|
||||
else
|
||||
cube = minetest.inventorycube(tiles[1], tiles[3], tiles[3])
|
||||
end
|
||||
return cube
|
||||
end
|
||||
|
||||
local function get_textures(name)
|
||||
local def = minetest.registered_entities[name]
|
||||
local textures = def.textures
|
||||
if not textures then
|
||||
if #def.female_textures < 2 then
|
||||
textures = {def.female_textures[1], def.male_textures[1]}
|
||||
else
|
||||
textures = {}
|
||||
local num = #def.female_textures
|
||||
for i = 1, num do
|
||||
if num + #def.male_textures < 7 then
|
||||
textures = {unpack(def.male_textures), unpack(def.female_textures)}
|
||||
else
|
||||
if i < num * 0.5 then
|
||||
table.insert(textures, def.female_textures[i])
|
||||
else
|
||||
table.insert(textures, def.male_textures[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return textures
|
||||
end
|
||||
|
||||
local animalia_libri_info = {}
|
||||
|
||||
local libri_animal_info = {
|
||||
["animalia:bat"] = {
|
||||
invcube = "default:stone",
|
||||
info = {
|
||||
domestication = {
|
||||
"While they can't be truly",
|
||||
"domesticated, Bats will begin ",
|
||||
"to trust you if you feed them ",
|
||||
"often. A Bat that trusts you will ",
|
||||
"not flee when you walk near it.",
|
||||
"This is useful as it allows ",
|
||||
"Players to keep them around ",
|
||||
"to harvest their guano, which ",
|
||||
"can be used as a powerful ",
|
||||
"fertilizer."
|
||||
},
|
||||
behavior = {
|
||||
"Bats are mostly harmless, and ",
|
||||
"can be found hanging from ",
|
||||
"trees and cliff ceilings during ",
|
||||
"the day. The only harm they ",
|
||||
"can cause it to property, with ",
|
||||
"guano accumulating ",
|
||||
"underneath them while they ",
|
||||
"rest. Being social creatures, it's ",
|
||||
"not uncommon to see a few ",
|
||||
"hanging from ceilings together ",
|
||||
"or swarming, which often ",
|
||||
"occurs at evening or when a ",
|
||||
"Player approaches."
|
||||
}
|
||||
}
|
||||
},
|
||||
["animalia:bird"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Cannot be tamed.",
|
||||
},
|
||||
behavior = {
|
||||
"Song Birds are found across ",
|
||||
"various biomes, except for ",
|
||||
"biomes too inhospitable like ",
|
||||
"deserts or tundras. They fly in ",
|
||||
"flocks that vary in size from 4 ",
|
||||
"or 5 individuals to large flocks ",
|
||||
"exceeding a dozen individuals. ",
|
||||
"Their calls vary between ",
|
||||
"species, making it easy to tell ",
|
||||
"what kind of birds are around."
|
||||
}
|
||||
}
|
||||
},
|
||||
["animalia:cat"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Unlike Wolves and Horses," ,
|
||||
"which are almost immediately ",
|
||||
"trusting upon being tamed, ",
|
||||
"Cats will remain untrusting ",
|
||||
"until you gain their trust. To do ",
|
||||
"so, you must feed and play ",
|
||||
"with it often. As trust builds ",
|
||||
"the cat will become more ",
|
||||
"comfortable in your presence, ",
|
||||
"and will be more receptive to ",
|
||||
"commands.",
|
||||
},
|
||||
behavior = {
|
||||
"Cats are very annoying ",
|
||||
"animals, to the point that ",
|
||||
"some may even call them a ",
|
||||
"pest. Their behavior in the ",
|
||||
"wild is somehow more tame ",
|
||||
"than their domesticated ",
|
||||
"behavior. They find immense ",
|
||||
"joy in running front of their ",
|
||||
"owner and even destroying ",
|
||||
"glass vessels. Despite this, ",
|
||||
"they are an incredibly popular ",
|
||||
"pet, especially for those who ",
|
||||
"don't often leave their home. ",
|
||||
"Like Wolves, a tamed Cat will ",
|
||||
"follow commands, but only if it ",
|
||||
"highly trusts it's owner."
|
||||
}
|
||||
}
|
||||
},
|
||||
["animalia:chicken"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Chickens are very valuable as a ",
|
||||
"livestock. They're a good ",
|
||||
"source of meat, but also lay ",
|
||||
"eggs. This, paired with their ",
|
||||
"small size, makes them great ",
|
||||
"for farming with limited space."
|
||||
},
|
||||
behavior = {
|
||||
"Chickens, or Jungle Fowl, are ",
|
||||
"most often found in groups. ",
|
||||
"They exhibit gender ",
|
||||
"dimorphism to a high degree, ",
|
||||
"with males having large tail ",
|
||||
"feathers. In the wild, they ",
|
||||
"dwell jungle floors, picking up ",
|
||||
"seeds and insects."
|
||||
}
|
||||
}
|
||||
},
|
||||
["animalia:cow"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Cows are commonplace on ",
|
||||
"farms because of their many ",
|
||||
"uses. They can be slaughtered ",
|
||||
"for beef and leather, and ",
|
||||
"females can be milked. Beef is ",
|
||||
"one of the most valuable ",
|
||||
"meats because of how much ",
|
||||
"satiation it provides, and ",
|
||||
"leather is valuable for crafting ",
|
||||
"various items."
|
||||
},
|
||||
behavior = {
|
||||
"Cows are always found in ",
|
||||
"groups of 3+ individuals. ",
|
||||
"Despite being capable of ",
|
||||
"inflicting damage, they will ",
|
||||
"always choose to flee, even ",
|
||||
"when in a large group. They ",
|
||||
"exhibit gender dimorphism, ",
|
||||
"with females having udders on ",
|
||||
"their belly."
|
||||
},
|
||||
}
|
||||
},
|
||||
["animalia:frog"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Cannot be tamed.",
|
||||
},
|
||||
behavior = {
|
||||
"Frogs are small creatures ",
|
||||
"almost exclusively found near ",
|
||||
"bodies of water. They will flee ",
|
||||
"to nearby water when a Player ",
|
||||
"approaches. They have quite ",
|
||||
"an affinity for water, moving ",
|
||||
"faster while in it and only ",
|
||||
"being able to breed when ",
|
||||
"submerged. They come to land ",
|
||||
"to search for food, which they ",
|
||||
"catch with their long tongue."
|
||||
},
|
||||
}
|
||||
},
|
||||
["animalia:horse"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Horses are one of the most ",
|
||||
"valuable animals to ",
|
||||
"domesticate because of their ",
|
||||
"ability carry Players and ",
|
||||
"maintain speed. They can ",
|
||||
"make traversing the world far ",
|
||||
"faster and easier, but aren't ",
|
||||
"easy to tame. To tame one, ",
|
||||
"you must keep your line of ",
|
||||
"sight lined up with the Horses ",
|
||||
"for a varying period of time. ",
|
||||
"This process is difficult but ",
|
||||
"well worth it."
|
||||
},
|
||||
behavior = {
|
||||
"Horses live in large groups, ",
|
||||
"wandering open grasslands. ",
|
||||
"They have a number of colors ",
|
||||
"and patterns, which are passed ",
|
||||
"down to their offspring, as ",
|
||||
"well as varying jumping and ",
|
||||
"running abilities."
|
||||
},
|
||||
}
|
||||
},
|
||||
["animalia:reindeer"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Cannot be tamed.",
|
||||
},
|
||||
behavior = {
|
||||
"Reindeer are found in large ",
|
||||
"groups in cold regions. They ",
|
||||
"stick tightly togther and move ",
|
||||
"in coordinated directions, even ",
|
||||
"while fleeing. They're also a ",
|
||||
"common food source for those ",
|
||||
"lost in taigas and tundras."
|
||||
}
|
||||
}
|
||||
},
|
||||
["animalia:pig"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Pigs are not quite as versatile ",
|
||||
"as other livestock like Cows or ",
|
||||
"Chickens, with their only ",
|
||||
"valuable resource being pork. ",
|
||||
"But they have a distinct ",
|
||||
"advantage by being able to ",
|
||||
"have more offspring at once ",
|
||||
"than Cows while also being ",
|
||||
"smaller."
|
||||
},
|
||||
behavior = {
|
||||
"Pigs in the wild can be very ",
|
||||
"destructive of ecosystems if ",
|
||||
"not controlled. Their ability to ",
|
||||
"reproduce quickly means ",
|
||||
"keeping populations under ",
|
||||
"control can be an issue. They ",
|
||||
"are known to destroy farmland ",
|
||||
"and will go as far as destroying ",
|
||||
"fences to do so."
|
||||
},
|
||||
}
|
||||
},
|
||||
["animalia:sheep"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Sheep are one of the most ",
|
||||
"useful animals to domesticate. ",
|
||||
"Their wool is a great resource ",
|
||||
"for crafting and building, and is ",
|
||||
"entirely renewable. Their wool ",
|
||||
"can also be dyed, though there ",
|
||||
"is little use for this."
|
||||
},
|
||||
behavior = {
|
||||
"Sheep are well known for ",
|
||||
"living in large groups. In the ",
|
||||
"wild these groups range from 4 ",
|
||||
"to 8 individuals, larger than ",
|
||||
"most other animals."
|
||||
}
|
||||
}
|
||||
},
|
||||
["animalia:tropical_fish"] = {
|
||||
special_models = {
|
||||
[3] = "animalia_angelfish.b3d"
|
||||
},
|
||||
info = {
|
||||
domestication = {
|
||||
"Cannot be tamed."
|
||||
},
|
||||
behavior = {
|
||||
"All varieties of Tropical Fish ",
|
||||
"can be found in schools around ",
|
||||
"reefs. While they don't ",
|
||||
"provide food or any resources, ",
|
||||
"they are a beautiful sight to ",
|
||||
"see while traversing oceans."
|
||||
},
|
||||
}
|
||||
},
|
||||
["animalia:turkey"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Even though Turkeys take up ",
|
||||
"more space than Chickens, ",
|
||||
"they also produce more meat, ",
|
||||
"at the cost of laying less eggs. ",
|
||||
"This makes them a good option ",
|
||||
"for those who don't want to ",
|
||||
"build a farm large enough to ",
|
||||
"support Cows or other large ",
|
||||
"livestock but also don't need ",
|
||||
"many eggs."
|
||||
},
|
||||
behavior = {
|
||||
"Turkeys are similar ",
|
||||
"behaviorally to Chickens, but ",
|
||||
"spawn in colder biomes and ",
|
||||
"are slightly larger. They exhibit ",
|
||||
"gender dimorphism, with ",
|
||||
"males having a large fan of ",
|
||||
"feathers on their tail."
|
||||
}
|
||||
}
|
||||
},
|
||||
["animalia:wolf"] = {
|
||||
info = {
|
||||
domestication = {
|
||||
"Their intelligence allows them ",
|
||||
"not only to form tight bonds ",
|
||||
"with players, but to also obey ",
|
||||
"orders. Once ordered to attack ",
|
||||
"a target, they will pursue it and ",
|
||||
"attack relentlessly, even if ",
|
||||
"death certain."
|
||||
},
|
||||
behavior = {
|
||||
"Wolves are found in packs of ",
|
||||
"up to 3. They hunt down Sheep ",
|
||||
"as a group and can quickly ",
|
||||
"overwhelm their target with ",
|
||||
"numbers. They're also ",
|
||||
"remarkebly intelligent, and ",
|
||||
"will remember players who ",
|
||||
"have harmed them and will ",
|
||||
"attack them on sight."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-- Libri Utilities --
|
||||
|
||||
local function offset_info_text(offset_x, offset_y, tbl)
|
||||
local info_text = {}
|
||||
for i = 1, #tbl do
|
||||
local str = tbl[i]
|
||||
local center_offset = 0
|
||||
if string.len(str) < 30 then
|
||||
center_offset = (30 - string.len(str)) * 0.05
|
||||
end
|
||||
str = minetest.colorize("#383329", str .. "\n")
|
||||
table.insert(info_text, "label[" .. offset_x + center_offset .. "," .. offset_y + i * 0.25 .. ";" .. str .. "]")
|
||||
end
|
||||
return table.concat(info_text, "")
|
||||
end
|
||||
|
||||
local function get_libri_page(mob_name, player_name)
|
||||
local def = minetest.registered_entities[mob_name]
|
||||
local animal_info = libri_animal_info[mob_name]
|
||||
-- Get Inventory Cube and Mob Texture
|
||||
local biome_groups = animalia.registered_biome_groups
|
||||
local biome_group = spawn_biomes[mob_name]
|
||||
local spawn_biome = biome_groups[biome_group].biomes[animalia_libri_info[player_name].biome_idx] or "grassland"
|
||||
local invcube
|
||||
if not minetest.registered_biomes[spawn_biome]
|
||||
or not minetest.registered_biomes[spawn_biome].node_top then
|
||||
invcube = get_inventory_cube("unknown_node.png")
|
||||
else
|
||||
invcube = get_inventory_cube(animal_info.invcube or minetest.registered_biomes[spawn_biome].node_top)
|
||||
end
|
||||
local texture = get_textures(mob_name)[animalia_libri_info[player_name].texture_idx]
|
||||
local mesh = def.mesh
|
||||
if libri_animal_info[mob_name].special_models
|
||||
and libri_animal_info[mob_name].special_models[animalia_libri_info[player_name].texture_idx] then
|
||||
mesh = libri_animal_info[mob_name].special_models[animalia_libri_info[player_name].texture_idx]
|
||||
end
|
||||
-- Create Formspec
|
||||
local form = {
|
||||
-- Background
|
||||
"formspec_version[3]",
|
||||
"size[16,10]",
|
||||
"background[-0.7,-0.5;17.5,11.5;animalia_libri_bg.png]",
|
||||
"image[-0.7,-0.5;17.5,11.5;animalia_libri_info_fg.png]",
|
||||
-- Mesh
|
||||
"model[1.5,1.5;5,5;libri_mesh;" .. mesh .. ";" .. texture .. ";-30,225;false;false;0,0;0]",
|
||||
-- Spawn Biome Group
|
||||
"image[0.825,8.15;1,1;" .. invcube .. "]",
|
||||
"tooltip[0.825,8.15;1,1;" .. correct_name(spawn_biome) .. "]",
|
||||
-- Health
|
||||
"image[2.535,8.15;1,1;animalia_libri_health_fg.png]",
|
||||
"label[3.25,9;x" .. def.max_health / 2 .. "]",
|
||||
-- Net
|
||||
"item_image[4.25,8.15;1,1;animalia:lasso]",
|
||||
"image[4.75,8.75;0.5,0.5;animalia_libri_" .. tostring(def.catch_with_lasso or false) .. "_icon.png]",
|
||||
-- Lasso
|
||||
"item_image[6,8.15;1,1;animalia:net]",
|
||||
"image[6.5,8.75;0.5,0.5;animalia_libri_" .. tostring(def.catch_with_net or false) .. "_icon.png]",
|
||||
-- Labels
|
||||
"label[9.5,7.25;" .. minetest.colorize("#383329", "Drops:") .. "]",
|
||||
"label[14,7.25;" .. minetest.colorize("#383329", "Eats:") .. "]",
|
||||
-- Info Text
|
||||
"label[9.25,1.5;" .. minetest.colorize("#000000", "Domestication:") .. "]",
|
||||
"label[13.5,1.5;" .. minetest.colorize("#000000", "Behavior:") .. "]",
|
||||
}
|
||||
-- Mob Info
|
||||
if libri_animal_info[mob_name] then
|
||||
if libri_animal_info[mob_name].info.domestication then
|
||||
table.insert(form, offset_info_text(8.5, 2, libri_animal_info[mob_name].info.domestication))
|
||||
end
|
||||
if libri_animal_info[mob_name].info.behavior then
|
||||
table.insert(form, offset_info_text(12.5, 2, libri_animal_info[mob_name].info.behavior))
|
||||
end
|
||||
end
|
||||
if def.follow then
|
||||
table.insert(form, animalia.get_item_list(def.follow, 12.35, 8.05))
|
||||
end
|
||||
if def.drops then
|
||||
local drops = {}
|
||||
for i = 1, #def.drops do
|
||||
table.insert(drops, def.drops[i].name)
|
||||
end
|
||||
table.insert(form, animalia.get_item_list(drops, 8, 8.05))
|
||||
end
|
||||
return table.concat(form, "")
|
||||
end
|
||||
|
||||
local function update_libri(player_name, mob_name)
|
||||
if not animalia_libri_info[player_name]
|
||||
or animalia_libri_info[player_name].name ~= mob_name then
|
||||
return
|
||||
end
|
||||
local texture_idx = animalia_libri_info[player_name].texture_idx or 1
|
||||
local biome_idx = animalia_libri_info[player_name].biome_idx or 1
|
||||
if texture_idx >= #get_textures(mob_name) then
|
||||
texture_idx = 1
|
||||
else
|
||||
texture_idx = texture_idx + 1
|
||||
end
|
||||
local wild_biomes = animalia.registered_biome_groups[spawn_biomes[mob_name]].biomes
|
||||
if biome_idx >= #wild_biomes then
|
||||
biome_idx = 1
|
||||
else
|
||||
biome_idx = biome_idx + 1
|
||||
end
|
||||
animalia_libri_info[player_name] = {
|
||||
texture_idx = texture_idx,
|
||||
biome_idx = biome_idx,
|
||||
name = mob_name
|
||||
}
|
||||
minetest.show_formspec(player_name, "animalia:libri_" .. mob_name:split(":")[2], get_libri_page(mob_name, player_name))
|
||||
minetest.after(4, function()
|
||||
update_libri(player_name, mob_name)
|
||||
end)
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local player_name = player:get_player_name()
|
||||
if formname == "animalia:libri_main" then
|
||||
animalia_libri_info[player_name] = {}
|
||||
for i = 1, #animalia.animals do
|
||||
local name = animalia.animals[i]:split(":")[2]
|
||||
if fields["pg_" .. name] then
|
||||
-- Get data for mob and biome visuals
|
||||
animalia_libri_info[player_name] = {
|
||||
texture_idx = 1,
|
||||
biome_idx = 1,
|
||||
name = animalia.animals[i]
|
||||
}
|
||||
update_libri(player_name, animalia.animals[i])
|
||||
break
|
||||
end
|
||||
end
|
||||
if fields["btn_next"] then
|
||||
local pages = animalia.libri_pages[player_name]
|
||||
if pages
|
||||
and #pages > 1 then
|
||||
animalia.show_libri_main_form(player, pages, 2)
|
||||
end
|
||||
end
|
||||
end
|
||||
if formname:match("^animalia:libri_") then
|
||||
if fields.quit or fields.key_enter then
|
||||
animalia_libri_info[player_name] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue