Difference between revisions of "SetAnimFrames (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "{| class="wikitable" style="width:100%" |- ! style="text-align:left" | Name !! style="text-align:left" | Type !! style="text-align:left" | By |- | setAnimFrames("ani", n1, n2)...")
 
m
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{| class="wikitable" style="width:100%"
+
{| class="ts" style="width:100%"
 
|-
 
|-
 
! 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
Line 10: Line 10:
 
== 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/>
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("animation_name", 1, 1) -- set active animation animation_name's first frame to 1 & last frame to 1
 
setAnimFrames("animation_name", 1, 1) -- set active animation animation_name's first frame to 1 & last frame to 1
Line 20: Line 20:
 
  getObject("ActiveAnimations[" .. ani .. "]"):setValue(VAnimationFirstFrame, n1)
 
  getObject("ActiveAnimations[" .. ani .. "]"):setValue(VAnimationFirstFrame, n1)
 
  getObject("ActiveAnimations[" .. ani .. "]"):setValue(VAnimationLastFrame, n2)
 
  getObject("ActiveAnimations[" .. ani .. "]"):setValue(VAnimationLastFrame, n2)
 +
end
 +
</syntaxhighlight>
 +
 +
=== Shorthand Version ===
 +
<syntaxhighlight>
 +
function setAnimFrames(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
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 25: Line 34:
  
 
== Syntax Breakdown ==
 
== Syntax Breakdown ==
{| class="wikitable" style="width:100%"
+
{| class="ts" style="width:100%"
 
|-
 
|-
 
! 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
Line 34: 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 21:48, 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 setAnimFrames(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).