Skip to content

Commit

Permalink
Allow overriding the loop flag on player_api.set_animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Panquesito7 authored Jan 15, 2024
1 parent 70cf7a2 commit 50c8814
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mods/player_api/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function player_api.set_texture(player, index, texture)
player_api.set_textures(player, textures)
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 model = models[player_data.model]
if not (model and model.animations[anim_name]) then
Expand All @@ -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
return
end
if loop == nil then
loop = true
end
local previous_anim = model.animations[player_data.animation] or {}
local anim = model.animations[anim_name]
player_data.animation = anim_name
Expand All @@ -146,7 +149,7 @@ function player_api.set_animation(player, anim_name, speed)
end
end
-- 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
if anim._equals ~= previous_anim._equals then
player:set_properties({
Expand Down

0 comments on commit 50c8814

Please sign in to comment.