mirror of
https://codeberg.org/tenplus1/mobs_animal.git
synced 2024-12-22 17:00:26 +01:00
tidy code, add special kitten spawn
This commit is contained in:
parent
9c00204154
commit
f8ed1c08b6
36
kitten.lua
36
kitten.lua
@ -2,6 +2,12 @@
|
|||||||
local S = mobs.intllib_animal
|
local S = mobs.intllib_animal
|
||||||
local hairball = minetest.settings:get("mobs_hairball")
|
local hairball = minetest.settings:get("mobs_hairball")
|
||||||
|
|
||||||
|
local kitten_types = {
|
||||||
|
|
||||||
|
{ nodes = {"farming:jackolantern_on"},
|
||||||
|
skins = {"mobs_kitten_black.png"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
-- Kitten by Jordach / BFD
|
-- Kitten by Jordach / BFD
|
||||||
|
|
||||||
@ -59,6 +65,28 @@ mobs:register_mob("mobs_animal:kitten", {
|
|||||||
},
|
},
|
||||||
view_range = 8,
|
view_range = 8,
|
||||||
|
|
||||||
|
-- check surrounding nodes and spawn a specific kitten
|
||||||
|
on_spawn = function(self)
|
||||||
|
|
||||||
|
local pos = self.object:get_pos() ; pos.y = pos.y - 1
|
||||||
|
local tmp
|
||||||
|
|
||||||
|
for n = 1, #kitten_types do
|
||||||
|
|
||||||
|
tmp = kitten_types[n]
|
||||||
|
|
||||||
|
if minetest.find_node_near(pos, 1, tmp.nodes) then
|
||||||
|
|
||||||
|
self.base_texture = tmp.skins
|
||||||
|
self.object:set_properties({textures = tmp.skins})
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true -- run only once, false/nil runs every activation
|
||||||
|
end,
|
||||||
|
|
||||||
on_rightclick = function(self, clicker)
|
on_rightclick = function(self, clicker)
|
||||||
|
|
||||||
if mobs:feed_tame(self, clicker, 4, true, true) then return end
|
if mobs:feed_tame(self, clicker, 4, true, true) then return end
|
||||||
@ -92,8 +120,7 @@ mobs:register_mob("mobs_animal:kitten", {
|
|||||||
end
|
end
|
||||||
self.hairball_timer = 0
|
self.hairball_timer = 0
|
||||||
|
|
||||||
if self.child
|
if self.child or math.random(250) > 1 then
|
||||||
or math.random(250) > 1 then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -102,10 +129,7 @@ mobs:register_mob("mobs_animal:kitten", {
|
|||||||
minetest.add_item(pos, "mobs:hairball")
|
minetest.add_item(pos, "mobs:hairball")
|
||||||
|
|
||||||
minetest.sound_play("default_dig_snappy", {
|
minetest.sound_play("default_dig_snappy", {
|
||||||
pos = pos,
|
pos = pos, gain = 1.0, max_hear_distance = 5}, true)
|
||||||
gain = 1.0,
|
|
||||||
max_hear_distance = 5
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user