mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-04-30 13:11:41 -04:00
Allow overriding the loop flag on player_api.set_animation
This commit is contained in:
parent
70cf7a26fd
commit
50c8814e03
1 changed files with 5 additions and 2 deletions
|
@ -116,7 +116,7 @@ function player_api.set_texture(player, index, texture)
|
||||||
player_api.set_textures(player, textures)
|
player_api.set_textures(player, textures)
|
||||||
end
|
end
|
||||||
|
|
||||||
function player_api.set_animation(player, anim_name, speed)
|
function player_api.set_animation(player, anim_name, speed, loop)
|
||||||
local player_data = get_player_data(player)
|
local player_data = get_player_data(player)
|
||||||
local model = models[player_data.model]
|
local model = models[player_data.model]
|
||||||
if not (model and model.animations[anim_name]) then
|
if not (model and model.animations[anim_name]) then
|
||||||
|
@ -126,6 +126,9 @@ function player_api.set_animation(player, anim_name, speed)
|
||||||
if player_data.animation == anim_name and player_data.animation_speed == speed then
|
if player_data.animation == anim_name and player_data.animation_speed == speed then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if loop == nil then
|
||||||
|
loop = true
|
||||||
|
end
|
||||||
local previous_anim = model.animations[player_data.animation] or {}
|
local previous_anim = model.animations[player_data.animation] or {}
|
||||||
local anim = model.animations[anim_name]
|
local anim = model.animations[anim_name]
|
||||||
player_data.animation = anim_name
|
player_data.animation = anim_name
|
||||||
|
@ -146,7 +149,7 @@ function player_api.set_animation(player, anim_name, speed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Set the animation seen by everyone else
|
-- Set the animation seen by everyone else
|
||||||
player:set_animation(anim, speed, animation_blend)
|
player:set_animation(anim, speed, animation_blend, loop)
|
||||||
-- Update related properties if they changed
|
-- Update related properties if they changed
|
||||||
if anim._equals ~= previous_anim._equals then
|
if anim._equals ~= previous_anim._equals then
|
||||||
player:set_properties({
|
player:set_properties({
|
||||||
|
|
Loading…
Add table
Reference in a new issue