Difference between revisions of "SetAnimFrames (CMS)"
From The Official Visionaire Studio: Adventure Game Engine Wiki
Line 7: | Line 7: | ||
This small function allows you to quickly set the frame range of an animation. | This small function allows you to quickly set the frame range of an animation. | ||
+ | |||
== Instructions == | == Instructions == | ||
1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/> | 1. Add the [[#Main_Script|main script]] to the Visionaire Studio Script Editor & set the script as a definition script.<br/> | ||
− | + | 2a. Example #1: forcing an animation to loop a single animation frame, in this case animation frame #1. | |
− | <syntaxhighlight> | + | <syntaxhighlight lang="lua"> |
− | setAnimFrames("example" | + | setAnimFrames("example", 1) |
+ | </syntaxhighlight> | ||
+ | 2b. Example #2: forcing an animation to loop a range of animation frames, in this case between animation frames #3 to #7. | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | setAnimFrames("example", 3, 7) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
== Main Script == | == Main Script == | ||
Line 24: | Line 30: | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
== Syntax Breakdown == | == Syntax Breakdown == |
Revision as of 23:16, 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.
2a. Example #1: forcing an animation to loop a single animation frame, in this case animation frame #1.
setAnimFrames("example", 1)
2b. Example #2: forcing an animation to loop a range of animation frames, in this case between animation frames #3 to #7.
setAnimFrames("example", 3, 7)
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). |