-- LUA Script - precede every function and global member with lowercase name of script local U = require "scriptbank\\utillib" local aiViewAnims = {} local pressed = false local aiViewAnimsEntity = nil local aiViewAnimsTimer = 0 function entity_viewanimations_init(e) CharacterControlManual(e) SetAnimationSpeed( e, 0.75 ) end function entity_viewanimations_main(e) local ai = aiViewAnims[ e ] if ai == nil then -- first time set up aiViewAnims[ e ] = { from = 0, to = 0, loop = false, looping = false, ff = true } return end if g_Time > aiViewAnimsTimer then -- only process every 50th of a second if aiViewAnimsEntity == e then aiViewAnimsTimer = g_Time + 20 else -- only check for entity change every 1/4 second aiViewAnimsTimer = g_Time + 250 end if U.PlayerLookingNear( e, 200, 90 ) then if aiViewAnimsEntity ~= e then aiViewAnimsEntity = e ai.loop = false ai.looping = false ai.ff = true return end -- if we're still here then we must be the entity the player is looking at CharacterControlManual(e) if g_MouseClick == 0 and g_KeyPressE == 0 then pressed = false end if g_KeyPressE == 1 then if g_KeyPressSHIFT == 1 and not pressed then pressed = true ai.loop = not ai.loop ai.looping = false elseif not pressed then pressed = true ai.ff = not ai.ff end end if g_KeyPressSHIFT == 1 or not pressed then if g_MouseClick == 1 then StopAnimation( e ) ai.looping = false pressed = true if ai.ff then ai.from = ai.from + 1 if ai.from > ai.to then ai.to = ai.from end else ai.to = ai.to + 1 end end end if g_MouseClick == 2 and ai.from > 0 then StopAnimation(e) ai.looping = false pressed = true if ai.ff then ai.from = ai.from - 1 elseif ai.to > ai.from then ai.to = ai.to -1 end end if not ai.loop then ai.looping = false if ai.ff then SetAnimationFrame( e, ai.from ) PromptLocal ( e, "frame= " .. ai.from ) else SetAnimationFrame( e, ai.to ) PromptLocal ( e, "to_frame= " .. ai.to ) end else if not ai.looping then SetAnimation( e ) SetAnimationFrames( ai.from, ai.to ) LoopAnimation( e ) ai.looping = true end PromptLocal (e, "from_frame= " .. ai.from .. " to_frame= " .. ai.to .. " current=" .. GetAnimationFrame( e ) ) end end Prompt("Mouse l/r inc/dec (+shift), E - toggle to/from (+shift to start looping)") end end