Documentation for ALPACA's Lua functions

void LoadScene(LuaScene scene {)

Loads a new scene.

This door example expects a Spine point object near the door:

 GoToPoint("cockpit", function () 
    LoadScene("cockpit") 
 end)

void InterruptibleOff({)

Prevent the player from skipping an interaction or walking somewere else

void InterruptibleOn({)

Enable interruption again

void PlayAnimation(Number trackIndex, LuaSpineAnimation newAnimation, bool loop, std::optional<sol::function> callback {)

Play an animation on the calling Spine object
int trackIndex: Spine animation track.
string newAnimation: Name of the animation to play.
bool loop: Whether to loop the animation at the end.
function callback: Function to be called at the end of the animation, also for looped animations.

void AddAnimation(Number trackIndex, LuaSpineAnimation newAnimation, bool loop, Number delay, std::optional<sol::function> callback {)

Adds an animation to the calling Spine object that will be played after the current animation ends.
int trackIndex: Spine animation track.
string newAnimation: Name of the animation to play.
bool loop: Whether to loop the animation at the end.
function callback: Function to be called at the end of the animation, also for looped animations.

void PlayAnimationOn(LuaSpineObject object, Number trackIndex, LuaSpineAnimation newAnimation, bool loop, std::optional<sol::function> callback {)

See PlayAnimation
SpineObject object: ID of the object to affect
int trackIndex: Spine animation track.
string newAnimation: Name of the animation to play.
bool loop: Whether to loop the animation at the end.
function callback: Function to be called at the end of the animation, also for looped animations.

void AddAnimationOn(LuaSpineObject object, Number trackIndex, LuaSpineAnimation newAnimation, bool loop, Number delay, std::optional<sol::function> callback {)

See AddAnimation
SpineObject object: ID of the object to affect
int trackIndex: Spine animation track.
string newAnimation: Name of the animation to play.
bool loop: Whether to loop the animation at the end.
function callback: Function to be called at the end of the animation, also for looped animations.

void SetSkin(LuaSpineSkin skin {)

Set a skin on a Spine object
string skin: The name of the Spine skin

void SetSkinOn(LuaSpineObject object, LuaSpineSkin skin {)

See SetSkin
SpineObject object: ID of the object to affect
string skin: The name of the Spine skin

void SetSkins(std::vector<LuaSpineSkin> skins {)

Set a list of skins on a Spine object
table<string> skin: The name of the Spine skin

void SetSkinsOn(LuaSpineObject object, std::vector<LuaSpineSkin> skins {)

See SetSkins
SpineObject object: ID of the object to affect
table<string> skin: The name of the Spine skin

void PlayDialog(LuaDialog dialogName, std::optional<sol::function> callback {)

Play a dialog by name
string dialogName: The dialog to play.

void RunScript(LuaScript scriptName {)

Run a script by name (without the '.lua' suffix)
string scriptName: The script to play.

void AddToInventory({)

Add the current item to the inventory.
Sets the skin of the item of the item to inventory_default_skin
Move the item from the scene to inventory_items.

void AddToInventoryWithSkin(LuaSpineSkin skin {)

See AddToInventory
string skin: The name of the Spine skin

void AddToInventoryOn(LuaSpineObject object {)

See AddToInventory
SpineObject object: ID of the object to affect
Note: The object must be in the scene, this function does not create new objects. The object can be placed outside the scene view.

void AddToInventoryWithSkinOn(LuaSpineObject object, LuaSpineSkin skin {)

See AddToInventory
SpineObject object: ID of the object to affect
string skin: The name of the Spine skin
Note: See the AddToInventoryOn note.

void RemoveFromInventory({)

DEPRECATED use SetDeleted

void RemoveFromInventoryOn(LuaSpineObject object {)

DEPRECATED use SetDeleted

void SetDeleted({)

Set deleted in the current object.
Objects are only deleted at the end of the frame.

void SetDeletedOn(LuaSpineObject object {)

See SetDeleted
SpineObject object: ID of the object to affect
Note: SetDeleted cannot be called on the last frame of an animation via a Spine event.

returns: a list of points GetPointNames({)

Get all Spine points from this Spine object

returns: a list of positions GetPointNamesOn(LuaSpineObject object {)

See GetPointNames
Lua Example:

SpineObject object: ID of the object to affect
 local points = GetPointNamesOn("inventory_object") 
 for i = 1, #points do 
   print(i, points[i]) 
 end

void GoToPoint(LuaSpinePoNumber point_name, std::optional<sol::function> callback {)

Send the player to the position of a point of this Spine object.
string point_name: Name of the Spine point the player should go to
function callback: Function to be called when the layer reaches the position

void GoToPointOn(LuaSpineObject object, LuaSpinePoNumber point_name, std::optional<sol::function> callback {)

See GoToPoint
SpineObject object: ID of the object to affect
string point_name: Name of the Spine point the player should go to
function callback: Function to be called when the layer reaches the position

void StopWalking({)

Stop the player at this position.

returns: Tupe(x, y) GetPointPosition(LuaSpinePoNumber point_name {)

Debug function to get the position of a Spine point.
string point_name: Name of the Spine point

void SetPositionToPoint(LuaSpinePoNumber point_name {)

Set the position of an object to a Spine point.
string point_name: Name of the Spine point

void SetPositionToPointOn(LuaSpineObject object, LuaSpinePoNumber point_name {)

See SetPositionToPoint
SpineObject object: ID of the object to affect
string point_name: Name of the Spine point

void SetOnToPointFrom(LuaSpineObject object, LuaSpineObject from, LuaSpinePoNumber point_name {)

SpineObject object: ID of the object to affect
string from: Objects ID that provides the point
string point_name: Name of the Spine point

void SetHidden({)

Hide a Spine object.

void SetHiddenOn(LuaSpineObject object {)

See SetHidden
SpineObject object: ID of the object to affect

void SetVisible({)

Make a Spine object visible.

void SetVisibleOn(LuaSpineObject object {)

See SetVisible
SpineObject object: ID of the object to affect

void SetLayer(Number layer {)

Set the render layer of an Object.
It's also possible to make objects non-interactive below a certain layer.
int layer: Number of the layer

void SetLayerOn(LuaSpineObject object, Number layer {)

See SetLayer
SpineObject object: ID of the object to affect

void SetInactivLayerBorder(Number layer {)

Make all objects with a layer below this value non-interactive. Useful for a menu, inventory or intro that plays over a scene.
int layer: The layer number [default: 0].

void AttachToPointer({)

Attachannel the Spine object to the mouse pointer.

void AttachToPointerOn(LuaSpineObject object {)

See AttachToPointer
SpineObject object: ID of the object to affect

void DeattachAllFromPointer({)

Deatatchannel all Spine object from the pointer

void DeattachFromPointer({)

Deatatchannel the Spine object from the pointer

void DeattachFromPointerOn(LuaSpineObject object {)

See DeattachFromPointer
SpineObject object: ID of the object to affect

returns: bool IsAttachedToPointer({)

Is the Spine object attached to the mouse pointer

returns: bool IsAttachedToPointerOn(LuaSpineObject object {)

See IsAttachedToPointer
SpineObject object: ID of the object to affect

returns: bool IsSomethingAttachedToPointer({)

Is something attached to the mouse pointer

void SetRotation(Number rotation {)

Rote a Spine object
float rotation: A number between 0.0 and 365.0

void SetRotationOn(LuaSpineObject object, Number rotation {)

See SetRotation
SpineObject object: ID of the object to affect
float rotation: A number between 0.0 and 365.0

void SetScale(Number scale {)

Scale a Spine object
float: The scale

void SetScaleOn(LuaSpineObject object, Number scale {)

See SetScale
SpineObject object: ID of the object to affect
float: The scale

returns: Number GetTime({)

Returns the time in seconds since the game started.

void SetPlayerMaxSpeed(Number max_speed {)

Set the maximum speed of the player.
Can be set to 0 if the player should not be able to walk.
float speed: value of the maximum speed

void CreateObject(std::string spine_file, std::string id, Number scale {)

Create a game object from a Spine file
string spine_file
string id
float scale

void PlayAudio(LuaAudio file, LuaAudioChannel channel {)

Playing an audio file.
It's muchannel better to use Spine events to trigger the sound to keep it in sync with the animation
string file: The audio file
string channel: music, voice, sounds or ambient

void LoopAudio(LuaAudio file, LuaAudioChannel channel {)

Loop an audio file.
string file: The audio file
string channel: music, voice, sounds or ambient

void StopAudio(LuaAudio file, LuaAudioChannel channel {)

Stop an audio file.
string file: The audio file
string channel: music, voice, sounds or ambient

returns:a bool indication if the audio is playing isAudioPlaying(LuaAudio file, std::string channel {)

Checks if an audio file is playing.
string file: The audio file
string channel: music, voice, sounds or ambient

void setSoundVolume(Number level, std::string channel {)

Set Sound Volume
float level: A value between 0.0 and 1.0
string channel: music, voice, sounds or ambient

returns: the sound volume setSoundVolume(std::string channel {)

Ger Sound Volume
string channel: music, voice, sounds or ambient

returns: the name as string GetID({)

Get the objects ID

void SetPlayerScaleX(Number scale {)

Set the player's x-scale
float: The scale

void SetLanguage(LuaLanguage language {)

Set the language
string: Example 'de' or 'en'

void Exit({)

Exit the game
Not supported on iOS

void SaveGame({)

Write a savegame

void LoadGame({)

Load the savegame

void DeleteSaveGame({)

Delete the savegame file

void SetzBufferMap(std::string file {)

Set the zBufferMap to a file

void RemovezBufferMap({)

Remove the zBufferMap