Difference between revisions of "SetAnimFrames (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
|||
Line 3: | Line 3: | ||
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By | ||
|- | |- | ||
− | | setAnimFrames(" | + | | setAnimFrames("anim", f, t) || Definition || AFRLme |
|} | |} | ||
− | This small function allows you to quickly set the | + | This small function allows you to quickly set the frame range of an animation. |
== Instructions == | == Instructions == | ||
Line 12: | Line 12: | ||
2. To use this function you should create an ''execute a script'' action containing... | 2. To use this function you should create an ''execute a script'' action containing... | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | setAnimFrames(" | + | setAnimFrames("example", 1, 1) -- set active animation example's first frame to 1 & last frame to 1 |
</syntaxhighlight> | </syntaxhighlight> | ||
== Main Script == | == Main Script == | ||
− | <syntaxhighlight | + | <syntaxhighlight lang="lua"> |
− | + | function setFrames(anim, f, t) | |
− | + | t = t or f -- fallback in case t equals nil | |
− | + | if f > t then f = t end -- fallback in case f is greater than t | |
− | + | ActiveAnimations[anim].FirstFrame = f -- update from animation frame range | |
− | + | ActiveAnimations[anim].LastFrame = t -- update to animation frame range | |
− | |||
− | |||
− | |||
− | function | ||
− | |||
− | |||
− | |||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
== Syntax Breakdown == | == Syntax Breakdown == | ||
Line 38: | Line 30: | ||
! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:70%" | Description | ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left;width:70%" | Description | ||
|- | |- | ||
− | | | + | | anim || "string" || This should be a "string" value containing the name of the animation you want to affect. |
|- | |- | ||
− | | | + | | f || integer || This should be an integer (number) value which will determine which frame will be the initial (from) frame of the linked animation (anim). |
|- | |- | ||
− | | | + | | t || integer || This should be an integer (number) value which will determine which frame will be the final (to) frame of the linked animation (anim). |
|}{{toc}} | |}{{toc}} |
Revision as of 23:11, 20 August 2022
Name | Type | By |
---|---|---|
setAnimFrames("anim", f, t) | Definition | AFRLme |
This small function allows you to quickly set the frame range of an 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("example", 1, 1) -- set active animation example's first frame to 1 & last frame to 1
Main Script
function setFrames(anim, f, t)
t = t or f -- fallback in case t equals nil
if f > t then f = t end -- fallback in case f is greater than t
ActiveAnimations[anim].FirstFrame = f -- update from animation frame range
ActiveAnimations[anim].LastFrame = t -- update to animation frame range
end
Syntax Breakdown
Name | Type | Description |
---|---|---|
anim | "string" | This should be a "string" value containing the name of the animation you want to affect. |
f | integer | This should be an integer (number) value which will determine which frame will be the initial (from) frame of the linked animation (anim). |
t | integer | This should be an integer (number) value which will determine which frame will be the final (to) frame of the linked animation (anim). |