Skyline Lua API  Version 1.0 RC1
Lua Script Reference for Skyline Game Engine.
anim Class Reference

#include <LUA_API_Anim.h>

Public Member Functions

void loadAnimation (int objID, string animationName, int looped, int enabled)
 This Function allows you to load an animation from a sceneEntity into the engine fr callback later. This Function must be called before you play the animation if the scene entity is spawned from LUA. If you are using a scene entity in the scene with the animations from the properties. then this function does not need to be called. More...
 
void playAnimation (int objID, string animationName, int blendBias, int useBlend)
 Using this function will allow you to switch animations on a specific sceneEntity. If you pass through the arguments for blending, then your animation will smoothly transit from one animation to another. More...
 
void stopAnimation (int objID, string animationName)
 Stop a specific SceneEntity Animation by passing 2 arguments. The Time position and Weight of an animation are set to default. More...
 
void setEnabled (int objID, string animationName, int enabled)
 Set whether an animation is enabled or not. If you don't an animation to play over the other, then setEnable false on the current animation before enabling the new animation. More...
 
void setLooped (int objID, string animationName, int looped)
 Set whether an animation is looped or not. More...
 
void setLength (int objID, string animationName, float length)
 Set the length an animation shall run. The frames are not resampled, so reducing lower than the animations real length will cut the animation off. More...
 
void setTime (int objID, string animationName, float timePosition)
 Set the time position of an animation, this will let you control the starting point of an animation before calling setEnabled() or change the position when running the animation. More...
 
void setWeight (int objID, string animationName, float blendWeight)
 Set the weight of an animation to control the blend. A value of 1 means this animation is fully used. A value of 0 means this animation is not animating, similar to being disabled. When using two enabled animations, if you set the weight of 0 to 1 on one animation and 1 to 0 on another animation, then the two animations will blend. More...
 
void setSpeed (int objID, string animationName, float speedMultiplier)
 Set the speed an animation plays back at. More...
 
int getEnabled (int objID, string animationName)
 Get the value of an animations enabled state. More...
 
int getLooped (int objID, string animationName)
 Get the value of an animations looped state. More...
 
float getLength (int objID, string animationName)
 Get the length of an animation. Returns as a Float. More...
 
float getTime (int objID, string animationName)
 Get the Time position of an animation. Returns as a Float. More...
 
float getWeight (int objID, string animationName)
 Get the Weight of an animation. Returns as a Float. More...
 
float getSpeed (int objID, string animationName)
 Get the Speed multiplier of an animation. Returns as a Float. More...
 
 getCurrentAnims (entityID)
 Get the animation table of an entity. More...
 
float getDuration (objID)
 Get duration. More...
 
 setDuration (objID,"animName", lengthInSeconds)
 Set duration. More...
 
float getBlendMaskEntry (objID,"animName", boneHandle)
 Get the blend mask entry. More...
 
 setBlendMaskEntry (objID,"animName", boneHandle, weight)
 Set the blend mask entry. More...
 
string getFromMap (objID, mapName)
 Get animation from the animation map. More...
 

Detailed Description

This area covers Entity Animation Controls. Skyline Lua can intercept input events a check their current state. You can check to see if
a specified key is held down or detect the left mouse buttom. This does not effect the system events and can be used together with them. Use as anim.function()
Example:

function onInit(objID) obj = objID;

charID = entity.spawn("TechTrooper_6k",0,0,0,1,1,1); anim.loadAnimation(charID, "idle", 1, 1); anim.loadAnimation(charID, "walk", 1, 0); anim.loadAnimation(charID, "run", 1, 0); end

function onKeyDown( key ) –sky.lprint("the value in Key = "..key); if(key=="1") then anim.playAnimation(charID, "idle", 30, 1) end if(key=="2") then anim.playAnimation(charID, "walk", 10, 1) end if(key=="3") then anim.playAnimation(charID, "run", 30, 1) end end

Member Function Documentation

float anim::getBlendMaskEntry ( objID  ,
"animName"  ,
boneHandle   
)

Get the blend mask entry.

function onKeyDown( key )
    blendweight = getBlendMaskEntry(objID, "animName", boneHandle);
    
end
anim::getCurrentAnims ( entityID  )

Get the animation table of an entity.

Parameters
entityID: The ID of the entity that has the animation table attached.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    coming soon
end
float anim::getDuration ( objID  )

Get duration.

Gets animation length, in seconds.

function onKeyDown( key )
    lengthOfAnim = getDuration(objID);
    // or
    lengthOfAnim = getLength(objID);
end
int anim::getEnabled ( int  objID,
string  animationName 
)

Get the value of an animations enabled state.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
Returns
enabled : This is the value of the enabled state. 1 is enabled, 0 is disabled.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    enabled = anim.getEnabled(charID, "walk");
end
string anim::getFromMap ( objID  ,
mapName   
)

Get animation from the animation map.

Parameters
objID: this entity with the animations
mapNamesting mapName is the key to a specific animation String: the actual name of the aniamtion. Get the entities animation from the animation map property editor by using a standard map key to represent respective animations.
function onKeyDown( key )
    myIdleAnim = getFromMap(objID,"Idle1");
    
end
float anim::getLength ( int  objID,
string  animationName 
)

Get the length of an animation. Returns as a Float.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
Returns
length : This is the length returned as a float value.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    length = anim.getLength(charID, "walk");
end
int anim::getLooped ( int  objID,
string  animationName 
)

Get the value of an animations looped state.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
Returns
looped : This is the value of the looped state. 1 is looped, 0 is disabled.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    looped = anim.getLooped(charID, "walk");
end
float anim::getSpeed ( int  objID,
string  animationName 
)

Get the Speed multiplier of an animation. Returns as a Float.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
Returns
weight : This is the speed returned as a float value.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    speed = anim.getWeight(charID, "walk");
end
float anim::getTime ( int  objID,
string  animationName 
)

Get the Time position of an animation. Returns as a Float.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
Returns
length : This is the Time position returned as a float value.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    timePos = anim.getTime(charID, "walk");
end
float anim::getWeight ( int  objID,
string  animationName 
)

Get the Weight of an animation. Returns as a Float.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
Returns
weight : This is the Weight returned as a float value.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    weight = anim.getWeight(charID, "walk");
end
void anim::loadAnimation ( int  objID,
string  animationName,
int  looped,
int  enabled 
)

This Function allows you to load an animation from a sceneEntity into the engine fr callback later. This Function must be called before you play the animation if the scene entity is spawned from LUA. If you are using a scene entity in the scene with the animations from the properties. then this function does not need to be called.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you wish to extract into the engine
looped: Set whether this animation will be looped or not. Saves time instead of calling anim.setLooped().
enabled: Set whether this animation is enabled. Saves time instead of calling anim.setEnabled().

Here is a Small Example of how to use this function:

function onInit(objID)
    charID = entity.spawn("TechTrooper_6k",0,0,0,1,1,1);
    anim.loadAnimation(charID, "idle", 1, 1);
end
void anim::playAnimation ( int  objID,
string  animationName,
int  blendBias,
int  useBlend 
)

Using this function will allow you to switch animations on a specific sceneEntity. If you pass through the arguments for blending, then your animation will smoothly transit from one animation to another.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
blendBias: This value will allow you to speed up or slow down the blend time between animations. Default value is 30. If you pass a value of 300, then this will blend quicker than passing 30.
useBlend: If you send through the value 1, then the animation will blend into the next using the blendbias to control the blending time. if 0 is passed through, the current animation is stopped and the new animation is enabled. No blending involved.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    -- Using Blend
    anim.playAnimation(charID, "walk", 30, 1);

    -- Not Using Blend
    anim.playAnimation(charID, "walk", 0, 0);
end
anim::setBlendMaskEntry ( objID  ,
"animName"  ,
boneHandle  ,
weight   
)

Set the blend mask entry.

function onKeyDown( key )
    setBlendMaskEntry(objID, "animName", boneHandle, weight);
    
end
anim::setDuration ( objID  ,
"animName"  ,
lengthInSeconds   
)

Set duration.

Set animation length, in seconds.

function onKeyDown( key )
    setDuration(objID, "animName", lengthInSeconds);
    
end
void anim::setEnabled ( int  objID,
string  animationName,
int  enabled 
)

Set whether an animation is enabled or not. If you don't an animation to play over the other, then setEnable false on the current animation before enabling the new animation.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
enabled: Set the value of 1 to enable and 0 to disable the animation.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    anim.setEnabled(charID, "walk", 1);
end
void anim::setLength ( int  objID,
string  animationName,
float  length 
)

Set the length an animation shall run. The frames are not resampled, so reducing lower than the animations real length will cut the animation off.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
length: Set the length of an anim in seconds.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    anim.setLength(charID, "walk", 5.997);
end
void anim::setLooped ( int  objID,
string  animationName,
int  looped 
)

Set whether an animation is looped or not.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
looped: Set the value of 1 to loop and 0 to not loop the animation.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    anim.setLooped(charID, "walk", 1);
end
void anim::setSpeed ( int  objID,
string  animationName,
float  speedMultiplier 
)

Set the speed an animation plays back at.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
speedMultiplier: This value is a multiplier, default is 1, 2 is twice as fast, 0.5 is half as slow.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    anim.setSpeed(charID, "walk", 2);
end
void anim::setTime ( int  objID,
string  animationName,
float  timePosition 
)

Set the time position of an animation, this will let you control the starting point of an animation before calling setEnabled() or change the position when running the animation.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
timePosition: Set the time position of an anim in seconds.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    anim.setTime(charID, "walk", 1.2);
end
void anim::setWeight ( int  objID,
string  animationName,
float  blendWeight 
)

Set the weight of an animation to control the blend. A value of 1 means this animation is fully used. A value of 0 means this animation is not animating, similar to being disabled. When using two enabled animations, if you set the weight of 0 to 1 on one animation and 1 to 0 on another animation, then the two animations will blend.

When the two animations have reached their respective end, then set the animation with 0 weight to be disabled.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.
blendWeight: Set the weight of an animation between the 0 to 1 range

Here is a Small Example of how to use this function:

blendValue = 0;
function onUpdate( timeDelta )
    if(blendValue >= 1)then
        anim.setEnabled(charID, "run", 0);
    else
        blendValue = blendValue + 30*(timeDelta/1000); -- returns 0.03 or there abouts depending on framerate.
        anim.setWeight(charID, "walk", 0+blendValue); -- send this to 1 to set walk as main anim.
        anim.setWeight(charID, "run", 1-blendValue);    
    end
end
void anim::stopAnimation ( int  objID,
string  animationName 
)

Stop a specific SceneEntity Animation by passing 2 arguments. The Time position and Weight of an animation are set to default.

Parameters
objID: The scene entity id to grab the animation data from.
animationName: The animation name you set the value to.

Here is a Small Example of how to use this function:

function onKeyDown( key )
    anim.stopAnimation(charID, "walk");
end

The documentation for this class was generated from the following file: