Scripting API

This page is outdated, find the latest API at http://supertuxkart.sourceforge.net/doxygen/group__Scripting.html

This page contains the Scripting API which provides a number of objects, methods, functions and enumberables for implementing player-track interactions with.

The API has been divided into 5 parts for the sake of clarity, the last 4 of which will be discussed on this page.

  1. Callbacks - The entry points to scripting are discussed under the scripting section.
  2. Kart API - The API relevant to kart manipulation
  3. Physics API - API relevant to collisions and physics in general
  4. Track API - API relevant to Track Object manipulation
  5. Misc API - Miscellaneous API that facilitates and augments the others

Contents

Callbacks

Callbacks are the entry points to scripts. They are discussed in detail under http://supertuxkart.sourceforge.net/Scripting.

Kart API

API call Description
void squashKart(int kart_id, float time) Squashes the kart corresponding to kart_id for the given time in seconds.
void teleportKart(int kart_id, Vec3 new_location) Teleports the given kart to the specified location.
void setVelocity(int kart_id, Vec3 velocity) sets the kart's velocity to the specified value.
void jumpKartTo(int kart_id, float x, float y) Attempts to project the given kart to the specified 2-D location (albeit somewhat inaccurately).
Vec3 getKartLocation(int kart_id) Returns the location of the corresponding kart.

Physics API

API call Description
int getCollidingKart1() Kart ID of primary kart involved in collision (either directly or as shooter of item).
int getCollidingKart2() Secondary Kart ID involved in collision (only for KartKartCollisions).
string getCollidingID() Returns the ID of the track object involved in the collision as a string.
string createExplosion(Vec3 location) Creates an explosion animation at the specified location.

Track API

Functions

API call Description
void displayMessage(string message) Displays the message onscreen and pauses the game.
void enableTrigger(string trigger_name) enables the specified action trigger (activates it).
void disableTrigger(string trigger_name) disables the specified action trigger (deactivates it).
void createTrigger(string trigger_name,Vec3 location, float trigger_distance) Creates specified trigger with given name and location, to be triggered with given distance.
string getKeyBinding(int input) returns the key for a particular input (defined using the PA Enum).
void runScript(string trigger_name) runs the specified script.

Enums

Currently the Player Action Enum is the only enum defined. It allows access to the key binding, via the function getKeyBinding (see above). For Example getKeyBinding(PA::ACCEL) would return the keybinding for acceleration (up key on a normal keyboard) as a string.

Registered Enums

Objects

Several Objects, and their corresponding methods have been provided to make scripting logic into the game easier. Objects are provided by special "getter" functions (basically these start with "get") which need to be taken into a script handle variable (starting with an @). The basic track objects have specialized objects tied to them, which are tied to the different types of track objects (animations, lights etc). For example : TrackObject @t_obj = getTrackObject("waterfall"); will create a new track object variable called t_obj. Once this is done, you can access the relevant type of object by using specialized getters. In this case, the object with ID "waterfall" is a particle emitter. so our next line will be ParticleEmitter @waterfallemitter = t_obj.getParticleEmitter(); Now we can use the new particle emitter object to manipulate the in-game emitter. For now I'm just going to move it to (0,2,5) using Vec3 newlocation = Vec3(0,2,5); waterfallemitter.move(newlocation);
TrackObject

Getter call Description
TrackObject @getTrackObject(string track_object_name) Returns a handle to a track object identified by the ID from blender.


API call Description
void setEnable(boolean status) sets the specified track object to enabled or disabled (true = enabled, false = disabled).
PhysicalObject @getPhysicalObject() get Physical Object tied to this track object.
Mesh @getMesh() get Mesh(or Skeletal animation) tied to this track object.
ParticleEmitter @getParticleEmitter() get Particle Emitter tied to this track object.
SoundEmitter @getSoundEmitter() get Sound Emitter tied to this track object.
Animator @getAnimator() get Animator (curve-based) tied to this track object.



PhysicalObject

Getter call Description
PhysicalObject @getPhysicalObject() Returns a handle to the physical object tied to a particular track object.


API call Description
bool isFlattener() returns true or false depending on whether karts that come in contact with this object are flattened (true = flattened, false = not).
void disable() disables this Physical Object (removes the physical interaction component from the track object)



Mesh

Getter call Description
Mesh @getMesh() Returns a handle to the mesh object/skeletal animation tied to a particular track object.


API call Description
void setLoop(int start_frame, int end_frame) sets the loop of the skeletal animation to be between the specified frames.
int getCurrentFrame() returns the index of the current frame of the animation.
void setCurrentFrame(int frame) sets the index of the active frame of the animation to a particular value.
void move(Vec3 location) moves the animation to the specified location


Particle Emitter

Getter call Description
ParticleEmitter @getParticleEmitter() Returns a handle to the Particle Emitter tied to a particular track object.


API call Description
void move(Vec3 location) moves the particle emitter to the specified location



Sound Emitter

Getter call Description
SoundEmitter @getSoundEmitter() Returns a handle to the Sound Emitter tied to a particular track object.


API call Description
void stop() stops the sound.
void playOnce() plays the sound once.
void playLoop() plays the sound continuously.
void move(Vec3 location) moves the sound effect to the specified location

Misc API

Retrieved from "http://supertuxkart.sourceforge.net/Scripting_API"

User Tools