Improve minetest.after checks

This commit is contained in:
Wuzzy 2018-06-03 16:17:55 +02:00
parent 201c2bf170
commit 2132cdacc5
1 changed files with 8 additions and 6 deletions

View File

@ -151,11 +151,12 @@ function mobs.attach(entity, player)
}
})
minetest.after(0.2, function(player)
if player:is_player() then
minetest.after(0.2, function(name)
local player = minetest.get_player_by_name(name)
if player then
mcl_player.player_set_animation(player, "sit" , 30)
end
end, player)
end, player:get_player_name())
player:set_look_horizontal(entity.object:get_yaw() - rot_view)
end
@ -171,11 +172,12 @@ function mobs.detach(player, offset)
pos = {x = pos.x + offset.x, y = pos.y + 0.2 + offset.y, z = pos.z + offset.z}
minetest.after(0.1, function(player, pos)
if player:is_player() then
minetest.after(0.1, function(name, pos)
local player = minetest.get_player_by_name(name)
if player then
player:set_pos(pos)
end
end, player, pos)
end, player:get_player_name(), pos)
end