Difference between revisions of "SetAnimFrames (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
m
Line 43: Line 43:
 
|-
 
|-
 
| n2 || integer || This should be an integer (number) value which will determine which frame will be the final (to) frame of the linked animation (ani).
 
| n2 || integer || This should be an integer (number) value which will determine which frame will be the final (to) frame of the linked animation (ani).
|}
+
|}{{toc}}

Revision as of 20:47, 8 December 2015

Name Type By
setAnimFrames("ani", n1, n2) Definition AFRLme

This small function allows you to quickly set the first & last frame of an active animation.

Instructions

1. Add the main script to the Visionaire Studio Script Editor & set the script as a definition script.
2. To use this function you should create an execute a script action containing...

setAnimFrames("animation_name", 1, 1) -- set active animation animation_name's first frame to 1 & last frame to 1

Main Script

function setAnimFrames(ani, n1, n2)
 getObject("ActiveAnimations[" .. ani .. "]"):setValue(VAnimationFirstFrame, n1)
 getObject("ActiveAnimations[" .. ani .. "]"):setValue(VAnimationLastFrame, n2)
end

Shorthand Version

function setFrames(ani, n1, n2)
 n2 = n2 or n1 -- fall-back in case n2 = nil (will use same value as n1)
 ActiveAnimations[ani].AnimationFirstFrame = n1
 ActiveAnimations[ani].AnimationLastFrame = n2
end


Syntax Breakdown

Name Type Description
ani "string" This should be a "string" value containing the name of the animation you want to affect.
n1 integer This should be an integer (number) value which will determine which frame will be the initial (from) frame of the linked animation (ani).
n2 integer This should be an integer (number) value which will determine which frame will be the final (to) frame of the linked animation (ani).