added animations for the wolf

This commit is contained in:
cale 2016-03-08 15:47:00 +01:00
parent 79ad4dab59
commit 0b006d84ac
2 changed files with 20 additions and 0 deletions

View File

@ -25,6 +25,7 @@ function pets.register_pet(name, def)
speed = 0,
pl = nil,
is_pet = false,
anim = "stand",
on_rightclick = function(self, clicker)
if not clicker or not clicker:is_player() then
@ -63,8 +64,20 @@ function pets.register_pet(name, def)
yaw = yaw+math.pi
end
self.object:setyaw(yaw)
if def.animations then
if self.anim ~= "walk" then
self.anim = "walk"
self.object:set_animation({x=def.animations.walk.x,y=def.animations.walk.y}, 30, 0)
end
end
else
self.object:setvelocity({x=0, y=0, z=0})
if def.animations then
if self.anim ~= "stand" then
self.anim = "stand"
self.object:set_animation({x=def.animations.sit.x,y=def.animations.sit.y}, 30, 0)
end
end
end
if vector.distance(self.object:getpos(), self.pl:getpos()) > 15 then
local vec = self.pl:getpos()
@ -89,6 +102,9 @@ function pets.register_pet(name, def)
yaw = yaw+math.pi
end
self.object:setyaw(yaw)
if def.animations then
self.object:set_animation({x=def.animations.walk.x,y=def.animations.walk.y}, 30, 0)
end
end
end
end,

View File

@ -4,4 +4,8 @@ pets.register_pet("wolf:wolf", {
collisionbox = {-0.3,-0.5,-0.3, 0.3,0.1,0.3},
mesh = "wolf_wolf.x",
textures = {"wolf_black.png",},
animations = {
walk = {x=80, y=100},
sit = {x=0, y=80}
},
})