S2ENGINE HD  1.4.6
Official manual about S2Engine HD editor and programming
ScriptFunctions.h File Reference

Script language functions. More...

Go to the source code of this file.

Functions

Casting

Casting functions.

bool Bool (float f)
 This function convert an integer, a float, or a string value into a boolean value. More...
 
bool Bool (int i)
 This function convert an integer, a float, or a string value into a boolean value. More...
 
bool Bool (string s)
 This function convert an integer, a float, or a string value into a boolean value. More...
 
float Float (string s)
 This function convert an integer, or a string value into a float value. More...
 
float Float (int i)
 This function convert an integer, or a string value into a float value. More...
 
int Int (string s)
 This function convert a string value into an integer value. More...
 
int Int (float f)
 This function convert a float value into an integer value. More...
 
string String (float f)
 This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string. More...
 
string String (bool b)
 This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string. More...
 
string String (int i)
 This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string. More...
 
string String (vec3 v3)
 This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string. More...
 
string String (vec4 v4)
 This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string. More...
 
vec3 String2Vec3 (string s)
 This function convert a string into a 3d vector. More...
 
vec4 String2Vec4 (string s)
 This function convert a string into a 4d vector. More...
 
vec3 Vec3 (float x, float y, float z)
 This function returns a 3d vector given 3 float numbers as input. It is useful to build a vec3 from 3 float. More...
 
vec4 Vec4 (float x, float y, float z, float w)
 This function returns a 4d vector given 4 float numbers as input. It is useful to build a vec4 from 4 float. More...
 
GUI

GUI functions.

bool GetSubWidgetFlag (string sw, string flag)
 This function returns the flag value (true or false) of a widget that is a child of this one. More...
 
void CreateWidget (string class, string script, string params, string pos)
 This function creates a GUI element (Widget). A widget can be a button, label, a dialog, a frame, etc. More...
 
void CreateHUD (string script)
 This function creates the HUD main widget. Using CreateHUDWidget() function you can attach new widgets to it. More...
 
void CreateHUDWidget (string class, string script, string params, string pos)
 This function is equal to CreateWidget() function. More...
 
void DestroySubWidget (string widget)
 This function destroys a child widget of this widget, if it exists. More...
 
string GetSubWidgetParam (string widget, string param)
 This function returns a param value of child widget of this widget, if it exists. More...
 
void ResetSubWidgetFlag (string sw, string flags)
 This function resets( sets to false) the flags of a widget that is a child of this one. More...
 
void SetSubWidgetFlag (string sw, string flags)
 This function sets (to true) the flags of a widget that is a child of this one. More...
 
void SetSubWidgetOpacity (string widget, float opacity)
 This function sets the opacity level of the tree starting from the child widget of this widget. More...
 
void SetSubWidgetParam (string widget, string param, string value)
 This function assigns a value to a param of child widget of this widget, if it exists. More...
 
void SetSubWidgetPos (string widget, float x, float y)
 This function assigns a new position to the child widget of this widget. More...
 
void SetWidgetOpacity (float opacity)
 This function sets the opacity level of the tree starting from this widget. More...
 
void ShowCursor (bool show)
 This function shows/hides the GUI cursor. It has effects only into the main GUI widget. More...
 
void ShowParentWidget (bool show)
 This function shows/hides the parent of this widget. More...
 
void ShowSubWidget (string widget, bool show)
 This function shows/hides a child of this widget given its name. More...
 
void ShowWidget (bool show)
 This function shows/hides this widget. More...
 
Physics

Physics functions.

void PhysicsCreateCharacter ()
 This function creates a character into the physics subsystem and associates it to this object. The Characters of the physics subsystem are specifically designed for intergrating the game-like character control with a realistic physical simulation. More...
 
void PhysicsCreateCharacter (float slopeLimit)
 This function creates a character into the physics subsystem and associates it to this object. The Characters of the physics subsystem are specifically designed for intergrating the game-like character control with a realistic physical simulation. More...
 
void PhysicsCreateBody (string coltype, float mass, vec3 props)
 This function creates a physics rigid body and associates it to 'this object'. More...
 
void PhysicsCreateVehicle (string vehicleBody, string frontWheels, string backWheels, string props)
 TThis function creates a vehicle into the physics subsystem and associates it to this object. More...
 
bool PhysicsCollisionTest (float radius, vec3 start, vec3 end)
 This function executes the Collision(Sweep) Test test of a sphere. The sweep test is made by extruding the sphere from a start point to an end point and checking if there is some object inside the extrusion. It returns true if the sweep test has success, false otherwise. More...
 
void PhysicsVehicleControl (float steerAngle, float acc, bool handbrake)
 This function moves this object if it is associated with a physics vehicle. More...
 
void PhysicsApplyForce (vec3 point, vec3 dir, float len)
 This function applies a force to this object if it has a physics object associated. More...
 
void PhysicsApplyForce (vec3 point, string axis, float len)
 This function applies a force to this object if it has a physics object associated. More...
 
void PhysicsApplyDirForceToRagdoll (vec3 dir, float len)
 This function applies a directional force to all the nodes of the Ragdoll associated to this object. Directional means that there is no need for a point of application. More...
 
void PhysicsApplyDirForceToRagdoll (string axis, float len)
 This function applies a directional force to all the nodes of the Ragdoll associated to this object. Directional means that there is no need for a point of application. More...
 
void PhysicsApplyForceToNode (string node, vec3 point, vec3 dir, float len)
 This function applies a force to a node of this object. This function has effect only if the object node has a physics object associated, i.e. in the case of a Ragdoll. More...
 
void PhysicsApplyForceToNode (string node, vec3 point, string axis, float len)
 This function applies a force to a node of this object. This function has effect only if the object node has a physics object associated, i.e. in the case of a Ragdoll. More...
 
void PhysicsApplyForceToObject (string obj, vec3 point, vec3 dir, float len)
 This function applies a force to an object if it has a physics object associated. The object is identified by its name. More...
 
void PhysicsApplyForceToObject (string obj, vec3 point, string axis, float len)
 This function applies a force to an object if it has a physics object associated. The object is identified by its name. More...
 
void PhysicsApplyForceToRagdoll (vec3 point, vec3 dir, float len)
 This function applies a force to an object if it has a physics object associated. The object is identified by its name. More...
 
void PhysicsApplyForceToRagdoll (vec3 point, string axis, float len)
 This function applies a force to all the nodes of the Ragdoll associated to this object. More...
 
void PhysicsApplyGravity (bool apply)
 This function sets to true/false the gravity application on the physics object associated to this object except if it is a character. More...
 
bool PhysicsCharacterCollisionTest (string obj, vec3 start, vec3 end)
 This function executes the Sweep test of an object using the capsule of a physics character associated to it. More...
 
void PhysicsCharacterMove (vec3 dir, float disp)
 This function moves this object if it is associated with a physics character. By default, gravity is applied on the characters movement. You can use PhysicsSetCharacterGravity function to enable/disable the gravity applied on the characters. More...
 
void PhysicsCharacterToRagdoll ()
 This function stops all animation channels, wakeUp the ragdoll associated with This Object, excludes from collision and set to sleeping the physics character associated with this object. In other words this function makes the Ragdoll simulation starting. More...
 
void PhysicsCreateRagdoll ()
 This function creates a Ragdoll basing on this object model format. More...
 
vec3 PhysicsGetCharacterDims ()
 This function returns the dimensions of the capsule of a physics character associated to this object. More...
 
string PhysicsGetCollidedObject ()
 This function returns the name of the object collided in a previous sweep test. More...
 
bool PhysicsGetCollideFlag ()
 This function returns true if the physics object associated with this object can collide, false otherwise. More...
 
vec3 PhysicsGetCollisionNormal ()
 This function returns the collision normal of the object collided in a previous sweep test. More...
 
vec3 PhysicsGetObjectPos ()
 This function returns the position of this object if it is associated to a physics object. More...
 
float PhysicsGetVehicleRPM ()
 This function returns the rotation per minute (RPM) of the engine of physics vehicle associated to this object. More...
 
bool PhysicsNodeCollisionTest (string obj, string node, float radius, vec3 disp)
 This function executes the Sweep test of an object node using a capsule builded from the node and the parent node world positions. More...
 
bool PhysicsObjectIsSleeping ()
 This functions returns true if the state of physics object associated with this object is set to sleeping, otherwise returns false. More...
 
void PhysicsObjectSleep ()
 This functions sets the state of the body associated with this object to sleeping. More...
 
void PhysicsObjectWakeUp ()
 This functions sets the state of the body associated with this object to wake up. More...
 
void PhysicsRagdollSleep ()
 This functions sets the state of a ragdoll associated with this object (i.e. the state the all the ragdoll capsules) to sleeping. More...
 
void PhysicsRagdollWakeUp ()
 This functions sets the state of a ragdoll associated with this object (i.e. the state the all the ragdoll capsules) to wake up. More...
 
void PhysicsResetCollideFlag ()
 This function sets to false the collide flag of physics object associated with this object. More...
 
void PhysicsResetRagdollCollideFlag ()
 This function sets to false the collide flag of all the capsules of a ragdoll associated with this object. More...
 
void PhysicsSetCharacterDims (vec3 dims)
 This function sets the dimensions of the capsule of a physics character associated to this object. More...
 
void PhysicsSetCharacterGravity (float gravity)
 This function sets the amount of the gravity applied on the physics character associated with this object. More...
 
void PhysicsSetCollideFlag ()
 This function sets to true the collide flag of physics object associated with this object. More...
 
void PhysicsSetObjectPos (vec3 pos)
 This function stes the position of this object if it is associated to a physics object. More...
 
void PhysicsSetRagdollCollideFlag ()
 This function sets to true the collide flag of all the capsules of a ragdoll associated with this object. More...
 
Math

Math functions.

float Abs (float scalar)
 This function returns the Absolute value of a given float number. More...
 
float Min (float a, float b)
 This function returns the minimum value between two given float values. More...
 
float Max (float a, float b)
 This function returns the maximum value between two given float values. More...
 
float Clamp (float scalar, float min, float max)
 This function returns the clamped value of an input float number between a nim and a max value. More...
 
vec3 CrossProduct (vec3 v1, vec3 v2)
 This function returns the cross product between two given 3D vectors. More...
 
float DotProduct (vec3 v1, vec3 v2)
 This function returns the Dot product between two given 3D vectors. More...
 
vec3 NormalizeV (vec3 v)
 This function returns a normalized 3d vector. More...
 
float Cos (float angle)
 This function returns the cosine value of a given angle. The angle value is expressed in degrees. More...
 
float Rand (int res)
 This function returns a float random number between 0.0 and 1.0 given the number of all possible choices. More...
 
float ScalarInterpolate (float s1, float s2, float t)
 This function returns the result of the linear interpolation between two input float numbers, given the parameter t. More...
 
vec3 ScreenToWorld (vec3 p)
 This function transforms a point from screen coordinates space to world coordinates space. This function is useful, for example, when you need to check if the user have clicked on a 3d object with the mouse cursor. More...
 
float Sin (float angle)
 This function returns the sine value of a given angle. The angle value is expressed in degrees. More...
 
vec3 VectorInterpolate (vec3 s1, vec3 s2, float t)
 This function returns the result of the linear interpolation between two input 3d Vectors, given the parameter t. More...
 
float VectorLen (vec3 v)
 This function returns the Length of a 3d vector. More...
 
vec3 VectorRotate (vec3 v, float angle, vec3 axis)
 This function rotates a 3d vector(also 3d point) given an angle of rotation and an axis of rotation. It is equal to multiply a 3d point with a rotation matrix. More...
 
vec3 VectorToAngles (vec3 v)
 This function returns the orientation of a given 3d vector expressed as the float triple yaw,pitch,roll where: More...
 
vec3 WorldToScreen (vec3 p)
 This function transforms a point from world coordinates space to screen coordinates space.
It is the inverse operation of ScreenToWorld function. This function is useful if you want to put a widget (for example a text label) near the projection on screen of a 3d object. More...
 
Audio

Audio functions.

void CrossFadeMusic (string music, int channel)
 This function play a music on a given channel by fading in it and fading out all mucis playing on the other channels . More...
 
void PlayMusic (string music, int channel)
 This function play a music on a given channel. More...
 
void PlaySound (string sound, bool loop)
 This function plays a sound given its filename. More...
 
void PlaySoundGlobal (string sound, bool loop)
 This function plays a global sound given its filename. More...
 
void SetSource (float gain, float range)
 This function creates a sound source and assign it to this object. More...
 
void SetSourcePitch (float pitch)
 This function sets the sound source pitch. More...
 
void SetSourceRange (float range)
 This function sets the sound source range of influence. More...
 
void SetSourceVolume (float volume)
 This function sets the sound source volume. More...
 
void StopMusic (int channel)
 This function stops a music playing on a given channel. More...
 
void StopSound ()
 This function stops a sound playing on this object source. More...
 
void StopSoundGlobal ()
 This function stops the global sound source. More...
 
bool IsSoundPlaying ()
 This function returns true if the sounde source of this object is still playing a sound. Otherwise returns false. More...
 
AI

AI functions.

void AICreateCharacter (float radius, float height, string maxLinear, string maxAngular)
 This function creates a character for the AI subsystem. More...
 
void AICreateObject (bool isObstacle, bool isOccluder, float radius, float height)
 This function creates an object for the AI subsystem. More...
 
void AIEnableHearing (bool enable, float range)
 This function makes AI subsystem enable Hearing feature for this object AI. More...
 
void AIEnableVision (bool enable, string eyeNode, float range)
 This function makes AI subsystem enable Vision feature for this object AI. More...
 
void FindPath (vec3 target)
 This function computes an AI path from this object position to a given target point. More...
 
vec3 AIGetFurthestCoverPoint (vec3 opponent, vec3 target, float range)
 This function returns the furthest point from a given point( also called the target point) in which the character is covered from another given point, the opponent point. More...
 
vec3 AIGetNearestAllowedPoint (vec3 target, float range)
 This function returns the nearest point (nearest to a given 'target point') toward which the character can move. More...
 
vec3 AIGetNearestCoverPoint (vec3 opponent, vec3 target, float range)
 This function returns the nearest point from a given point( also called the target point) in which the character is covered from another given point, the opponent point. More...
 
string AIGetNearestHeardObject ()
 This function returns the name of the nearest object heard by this object. More...
 
vec3 AIGetNearestTacticalCoverPoint (vec3 opponent, vec3 target, float range, int ID)
 This function returns the nearest point from a given point( also called the target point) in which the character is covered from another given point, the opponent point. More...
 
vec3 AIGetNearestTacticalPatrolPoint (vec3 target, float range, int ID)
 This function returns the nearest point from a given point( also called the target point) in which the character have to patrol. More...
 
string AIGetNearestViewedObject ()
 This function returns the name of the nearest object viewed by this object. More...
 
bool AIObjectIsHeard (string obj)
 This function returns true if an object is heard by this object. More...
 
bool AIObjectIsViewed (string obj)
 This function returns true if an object is viewed by this object. More...
 
bool AIPointIsInsideWaypointArea (vec3 point)
 This function returns true if a give point is inside a WaypointArea. More...
 
void AISetCharacterMaxAngular (float acc, float speed)
 This function sets the maximum angular accelleration and maximum angular velocity of this object if it is associated with an AI character. More...
 
void AISetCharacterMaxLinear (float acc, float speed)
 This function sets the maximum linear accelleration and maximum linear velocity of this object if it is associated with an AI character. More...
 
void AISetSteeringWeight (string steer, float weight)
 This function sets the weight of a steering behavior. Steering behaviors are used for steering AI characters, in the sense of walk, seek, avoid obstacles, follow paths, etc... More...
 
void AISetTargetToFacePos (vec3 target)
 This function sets the target point that AI character must to face using Steering behaviors. More...
 
void AISetTargetToReachPos (vec3 target)
 This function sets the target point that AI character must to reach using Steering behaviors. More...
 
Input

Input functions.

bool GetInputAction (string name)
 This function returns the value of an input action given its identifying name. More...
 
float GetInputAxis (string name)
 This function returns the value of an input axis given its identifying name. Value returned is already scaled basing on the input map configuration. More...
 
bool IsKeyPressed (string key, int mode)
 This function returns true if a keyboard key pressed. Otherwise it returns false. More...
 
vec3 GetMousePos ()
 This function returns a 3d vector containing the mouse position. More...
 
vec3 GetMouseRelPos ()
 This function returns a 3d vector containing the mouse position relative to the previous frame. In other words it returns the displace of the mouse from the previous frame, if mouse doesn't move, it returns a zero vector. More...
 
string GetPressedKey (int mode)
 This function returns the pressed key, if there is one. Otherwise it returns null. There are 3 ways in which the keyboard key pression can be detected: More...
 
System

System functions.

void LOG (string str)
 The function writes the input string into the S2Engine LOG file. More...
 
int GetNumVideoModes ()
 This function returns the number of video modes supported by the hardware system. More...
 
string GetVideoMode (int i)
 This function returns a string containing the description of the supported Video Mode at index i. More...
 
void CloseLevel ()
 This function closes an entire game scene. More...
 
bool LoadLevel (string level)
 This function loads a game scene given its filename. More...
 
void Exit ()
 This function shutdown the engine and exit from the application. More...
 
void EnginePause ()
 This function pauses the simulation or game. More...
 
void EngineResume ()
 This function resumes the simulation (or game) previously paused. More...
 
string GetAudioDevice (int i)
 This function returns a string containing the description of the AudioDevice at index i. More...
 
string GetEngineParam (string param)
 This function returns the value of a specified param of the engine and its subsystems: render, audio, physics. More...
 
string GetLevelParam (string param)
 This function returns the value of a specified param of the current scene. More...
 
int GetNumAudioDevice ()
 This function returns the number of audio devices supported by the hardware system. More...
 
string Load (string path)
 This function loads a text file and returns its content as a string. More...
 
void LoadResource (string resPath, string cache)
 This function loads a resource given its filename. More...
 
void RestartLevel ()
 This function restores the starting state of the game scene without close/reload it. More...
 
void Save (string text, string path)
 This function saves a string into a text file. More...
 
void SetEngineParam (string param, string value)
 This function sets the value of a specified param of the engine and its subsystems: Render, Physics, Audio. More...
 
void SetLevelParam (string param, string value)
 This function sets the value of a specified param of the current scene. More...
 
void SetTimeScale (float timeMul)
 This function sets the simulation time speed multiplier. More...
 
Animation

Animation functions.

int AddAnimationChannel ()
 This function Adds an animation channel to the animation channel list of an entity. More...
 
void AddAnimationToChannel (int channel, string animName)
 This function Adds an animation to a pre-added animation channel of an entity. More...
 
void SetAnimationBlendX (int channel, string animName, float value)
 This function assigns a blend float value to a blended animation in X direction. More...
 
void SetAnimationBlendY (int channel, string animName, float value)
 This function assigns a blend float value to a blended animation in Y direction. More...
 
void AnimationCrossFade (int channel, string animName, float time)
 This function executes a cross fade between a given animation and all others. More...
 
void AnimationChannelFadeIn (int channel, float time)
 This function starts the 'fade in' transition of an animation channel. More...
 
void AnimationChannelFadeOut (int channel, float time)
 This function starts the 'fade Out' transition of an animation channel. More...
 
void BlendAnimationChannel (int channel, float weight)
 This function sets the blend weight value of an animation channel given its ID number. More...
 
void BlendCurrentAnimation (string anim, float weight, int channel)
 This function is the core of animation system, It assigns a channel to an animation and also sets animation weight. More...
 
void PauseAnimation (int channel)
 This function pause an animation channel, i.e. it pauses all the animations of the channel. More...
 
void PlayAnimation (int channel, bool loop)
 This function plays all the animations of a channel. More...
 
void SetAnimationChannelMask (int channel, string maskname)
 This function assigns a mask to a given channel. More...
 
void SetAnimationChannelSpeed (int channel, float speed)
 This function sets the overall speed of an animation channel. More...
 
void StopAnimation (int channel)
 This function stops an animation channel, i.e. it stops all the animations of the channel. More...
 
bool IsAnimationStopped (int channel)
 This function returns true if the specified animation channel isn't playing. Otherwise it returns false. More...
 
Objects

Objects/Scene functions.

void SetParam (string param, string value)
 This function sets the value of a specified param of this object if this is an object script or this widget if this is a widget script. More...
 
string GetParam (string param)
 This function returns the value of a specified param of this object if this is an object script or this widget if this is a widget script. More...
 
void ActiveObject (string objname, vec3 pos, vec3 angles)
 This function activates a stock object. You have also to specify the position and orientation of the object to activate. More...
 
void AttachObject (string obj, string node, vec3 pos, vec3 angles)
 This function activates a stock object and puts it into this object hierarchy (the attached object will move together this object, i.e. Its parent). This action is usually performed at init time, but it is not necessary. More...
 
void SpawnObject (string prefabFilename, vec3 pos, vec3 angles)
 This function creates an object taking its description from a prefab resource. More...
 
void SetObjectFlags (string objname, string flags)
 This function sets to TRUE all input flags of an object. More...
 
void ResetObjectFlags (string objname, string flags)
 This function sets to FALSE all input flags of an object. More...
 
bool GetObjectFlag (string objname, string flag)
 This function returns the value (TRUE or FALSE) of an object flag. More...
 
string GetObjectParam (string objname, string paramname, bool isStock)
 This function returns the value of the parameter of an object as string. Every object has its own parameters depending on its class. More...
 
string SetObjectParam (string objname, string paramname, string paramvalue)
 This function sets the value of the parameter of an object given as string. More...
 
string GetObjectScriptParam (string objname, string paramname, bool isStock)
 This function returns the value of the parameter of the object script as string. More...
 
vec3 GetObjectWorldPos (string objname)
 This function returns the worldspace position of an object. More...
 
vec3 GetObjectWorldAxis (string objname, string axis)
 This function returns one of the 3 axis of object orthonormal basis in worldspace. More...
 
vec3 GetObjectWorldAngles (string objname)
 This function returns the orientation of an object in world space as euler angles. Angles are returned as a vec3 (yaw, pitch, roll). More...
 
vec3 GetWorldAxis (string axis)
 This function returns one of the 3 axis of THIS object (object owning the script) orthonormal basis in worldspace. More...
 
vec3 GetAxis (string axis)
 This function returns one of the 3 axis of THIS object (object owning the script) orthonormal basis in localspace. More...
 
Messages

Messages functions.

void SendMessageSingle (string dest, string name, string content)
 This function send a message to a single active object given its name. More...
 
void SendMessageSingle (string dest, string name, string content, float delay)
 This function send a message to a single active object given its name. More...
 
void SendMessageBroad (string dest, string name, string content)
 This function send a message to all active objects. More...
 
void SendMessageBroad (string dest, string name, string content, float delay)
 This function send a message to all active objects. More...
 
void SendMessageMulti (string name, string content, float range, string class)
 This function send a message to more than one active object. The receiver objects are choosen basing on a range of influence and a specified class. More...
 
void SendMessageMulti (string name, string content, float range, float delay)
 This function send a message to more than one active object. The receiver objects are choosen basing on a range of influence and a specified class. More...
 
void SendMessageGUI (string name, string content)
 This function sends a message to the main widget of the GUI. More...
 
void SendMessageGUI (string name, string content, float delay)
 This function sends a message to the main Widget of the GUI. More...
 
void SendMessageHUD (string name, string content)
 This function sends a message to the main widget of the HUD. More...
 
void SendMessageHUD (string name, string content, float delay)
 This function sends a message to the main Widget of the HUD. More...
 
bool ReceivedMessage (string msg)
 This is a special function that has effect only inside the Message() main function. It returns true if the message msg has been received. More...
 

Detailed Description

Script language functions.

A comprehensive reference of all built-in S2Engine HD scripting language functions.

Function Documentation

float Abs ( float  scalar)

This function returns the Absolute value of a given float number.

Parameters
scalarthe float number.
See also
Min,Max,Clamp
void ActiveObject ( string  objname,
vec3  pos,
vec3  angles 
)

This function activates a stock object. You have also to specify the position and orientation of the object to activate.

Parameters
objnamename of the stock object to activate.
posposition in which activate the object.
anglesorientation activated object must have.
int AddAnimationChannel ( )

This function Adds an animation channel to the animation channel list of an entity.

Note
This function works only if the script is loaded into an Entity based object.
Returns
the ID number of the animation channel added
See also
AddAnimationToChannel
void AddAnimationToChannel ( int  channel,
string  animName 
)

This function Adds an animation to a pre-added animation channel of an entity.

Note
This function works only if the script is loaded into an Entity based object.
Parameters
channelID of the channel to which add the animation
animNamename of the animation to add
See also
AddAnimationChannel
void AICreateCharacter ( float  radius,
float  height,
string  maxLinear,
string  maxAngular 
)

This function creates a character for the AI subsystem.

Usually it is called during a object initialization when we want AI subsystem manage this object AI as character (or NPC).

Note
The AI object is created by he AI system and associated to this object.
Parameters
radiusradius of the AI character. Used by AI system for obstacle avoidance behavior, for separation behavior and other things.
heightheight of the AI character. Not used for now.
maxLinearstring composed by 2 values separated by a ',' symbol: first value is max linear accelleration of the character, second is max linear speed of the character.
maxAngularstring composed by 2 values separated by a ',' symbol: first value is max angular accelleration of the character, second is max angular speed of the character.
void AICreateObject ( bool  isObstacle,
bool  isOccluder,
float  radius,
float  height 
)

This function creates an object for the AI subsystem.

Usually it is called during a object initialization when we want AI subsystem manage 'this object as obstacle and/or occluder for the characters AI.

Note
The AI object is created by he AI system and associated to this object.
Parameters
isObstacletrue if the AI object must be an obstacle, false otherwise.
isOccludertrue if the AI object must be an occluder, false otherwise.
radiusradius of the AI obstacle.
heightheight of the AI obstacle.
void AIEnableHearing ( bool  enable,
float  range 
)

This function makes AI subsystem enable Hearing feature for this object AI.

Of course it has effects if this object is an AI character.

Parameters
enabletrue if hearing must be enable, false otherwise.
rangemax distance at which the character can hear.
void AIEnableVision ( bool  enable,
string  eyeNode,
float  range 
)

This function makes AI subsystem enable Vision feature for this object AI.

Of course it has effects if this object is an AI character.

Parameters
enabletrue if hearing must be enable, false otherwise.
eyeNodethe node from which the character see the scene (i.e. its eye).
rangemax distance at which the character can view.
vec3 AIGetFurthestCoverPoint ( vec3  opponent,
vec3  target,
float  range 
)

This function returns the furthest point from a given point( also called the target point) in which the character is covered from another given point, the opponent point.

The cover points are choosen inside a given range from this object position, and also they are choosen among points behind obstacles and AI points of type COVER_POINT inserted into the scene by level designers.

Note
this function has effetcs only if an AI character is associated to this object.
Parameters
opponentthe point from which the character want to cover.
targetthe point from which to compute maximum distance.
rangethe range inside which to choose cover points.
See also
AICreateCharacter, AIGetNearestCoverPoint
vec3 AIGetNearestAllowedPoint ( vec3  target,
float  range 
)

This function returns the nearest point (nearest to a given 'target point') toward which the character can move.

This function is used when you want NPC choose a valid point (not inside an obstacle, not inside a forbidden area, etc..) toward which to move.

Note
This function has effetcs only if an AI character is associated to this object.
Parameters
targetthe point from which to compute minimum distance.
rangethe range inside which to choose allowed points.
See also
AICreateCharacter, AIGetFurthestCoverPoint
vec3 AIGetNearestCoverPoint ( vec3  opponent,
vec3  target,
float  range 
)

This function returns the nearest point from a given point( also called the target point) in which the character is covered from another given point, the opponent point.

The cover points are choosen inside a given range from this object position, and also they are choosen among points behind obstacles and AI points of type COVER_POINT inserted into the scene by level designers.

Note
this function has effetcs only if an AI character is associated to this object.
Parameters
opponentthe point from which the character want to cover.
targetthe point from which to compute minimum distance.
rangethe range inside which to choose cover points.
See also
AICreateCharacter, AIGetFurthestCoverPoint
string AIGetNearestHeardObject ( )

This function returns the name of the nearest object heard by this object.

Parameters
opponentthe point from which the character want to cover.
targetthe point from which to compute minimum distance.
rangethe range inside which to choose cover points.
See also
AIGetNearestViewedObject
vec3 AIGetNearestTacticalCoverPoint ( vec3  opponent,
vec3  target,
float  range,
int  ID 
)

This function returns the nearest point from a given point( also called the target point) in which the character is covered from another given point, the opponent point.

Cover points are choosen inside a given range from this object position. This function differs from AIGetNearestCoverPoint function by the fact that cover point are also choosen only among AI points of type COVER_POINT of a specified ID.

Note
this function has effetcs only if an AI character is associated to this object.
Parameters
opponentthe point from which the character want to cover.
targetthe point from which to compute minimum distance.
rangethe range inside which to choose cover points.
IDonly cover point that have ID equal to it are choosen.
See also
AICreateCharacter, AIGetFurthestCoverPoint
vec3 AIGetNearestTacticalPatrolPoint ( vec3  target,
float  range,
int  ID 
)

This function returns the nearest point from a given point( also called the target point) in which the character have to patrol.

Patrol points are choosen inside a given range from this object position. This function differs from AIGetNearestTacticalCoverPoint function by the fact that cover point are also choosen only among AI points of type PATROL_POINT of a specified ID.

Note
This function has effetcs only if an AI character is associated to this object.
Parameters
targetthe point from which to compute minimum distance.
rangethe range inside which to choose patrol points.
IDonly patrol points that have ID equal to it are choosen.
See also
AICreateCharacter, AIGetFurthestCoverPoint
string AIGetNearestViewedObject ( )

This function returns the name of the nearest object viewed by this object.

See also
AIGetNearestHeardObject
bool AIObjectIsHeard ( string  obj)

This function returns true if an object is heard by this object.

Note
That this function works only if this object is associated with an AI character, and Hearing is enabled.
Parameters
objname of the object to check if it's heard.
See also
AICreateCharacter, AIEnableHearing
bool AIObjectIsViewed ( string  obj)

This function returns true if an object is viewed by this object.

Note
That this function works only if this object is associated with an AI character and vision is enabled.
Parameters
objname of the object to check if it's heard.
See also
AICreateCharacter, AIEnableVision
bool AIPointIsInsideWaypointArea ( vec3  point)

This function returns true if a give point is inside a WaypointArea.

Parameters
pointpoint to check if inside waypoint area.
void AISetCharacterMaxAngular ( float  acc,
float  speed 
)

This function sets the maximum angular accelleration and maximum angular velocity of this object if it is associated with an AI character.

These parameters are used when character steering behaviors are performed.

Parameters
accangular accelleration to set.
speedangular speed to set.
See also
AICreateCharacter
void AISetCharacterMaxLinear ( float  acc,
float  speed 
)

This function sets the maximum linear accelleration and maximum linear velocity of this object if it is associated with an AI character.

These parameters are used when character steering behaviors are performed.

Parameters
acclinear accelleration to set.
speedlinear speed to set.
See also
AICreateCharacter
void AISetSteeringWeight ( string  steer,
float  weight 
)

This function sets the weight of a steering behavior. Steering behaviors are used for steering AI characters, in the sense of walk, seek, avoid obstacles, follow paths, etc...

There is a variety of behaviors in S2ENGINE HD AI system, they are can be combined together usign a weighted blending. This means that bigger is the weight of the given behavior, bigger is its influence among the other ones upon the overall behavior of the AI character.

Parameters
steername of the behavior. see Steering behaviors for the complete list of steering behaviors.
weightweight to set.
void AISetTargetToFacePos ( vec3  target)

This function sets the target point that AI character must to face using Steering behaviors.

In S2Engine HD, NPC movements are separated into Reaching and Facing type:

  • Reaching means the character moves to reach a certain position.
  • Facing means that character turns to reach a certain orientation.
Parameters
targettarget point to face.
See also
AISetTargetToReachPos
void AISetTargetToReachPos ( vec3  target)

This function sets the target point that AI character must to reach using Steering behaviors.

In S2Engine HD, NPC movements are separated into Reaching and Facing type:

  • Reaching means the character moves to reach a certain position.
  • Facing means that character turns to reach a certain orientation.
Parameters
targettarget point to reach.
See also
AISetTargetToFacePos
void AnimationChannelFadeIn ( int  channel,
float  time 
)

This function starts the 'fade in' transition of an animation channel.

In other words it make the weight of the channel pass from its current value to 1.0 value. It is used in conjunction with AnimationChannelFadeOut and it is useful when you want to pass to an animation channel with a transition. You can specify the duration, in milliseconds, of the transition.

Parameters
channelID number of the channel
timethe duration (in milliseconds) of the transition
See also
AnimationChannelFadeOut, Animation Channels
void AnimationChannelFadeOut ( int  channel,
float  time 
)

This function starts the 'fade Out' transition of an animation channel.

In other words it make the weight of the channel pass from its current value to 0.0 value (that means tha animation channel disappear). It is used in conjunction with AnimationChannelFadeIn and it is useful when you want to exit from an animation channel with a transition. You can specify the duration, in milliseconds, of the transition.

Parameters
channelID number of the channel
timethe duration (in milliseconds) of the transition
See also
AnimationChannelFadeIn, Animation Channels
void AnimationCrossFade ( int  channel,
string  animName,
float  time 
)

This function executes a cross fade between a given animation and all others.

The function works in the following way: animation weight is gradually brought to 1.0 value while all other animations weights are gradually brought to 0.0 value.

Parameters
channelID of the channel to which add the animation
animNamename of the blended animation to set value
timeduration of the transition, in milliseconds
See also
Animation Blending
void AttachObject ( string  obj,
string  node,
vec3  pos,
vec3  angles 
)

This function activates a stock object and puts it into this object hierarchy (the attached object will move together this object, i.e. Its parent). This action is usually performed at init time, but it is not necessary.

Parameters
objnamename of the stock object to activate.
nodename of the node of this object on which to attach the object.
poslocal position the attached object must have.
angleslocal orientation (yaw,pitch,roll triple) the attached object must have.
void BlendAnimationChannel ( int  channel,
float  weight 
)

This function sets the blend weight value of an animation channel given its ID number.

Parameters
channelID number of the channel
weightnew blend weight value
void BlendCurrentAnimation ( string  anim,
float  weight,
int  channel 
)

This function is the core of animation system, It assigns a channel to an animation and also sets animation weight.

Weight can be a value between 0.0 and 1.0. A weight of value 0.0 means that animation has no effects (it is not played), a weight of value 1.0 means that animation is played just like it is. Intermediate values make animation to blend with other animations of the same channel. The max number of channels is limited only by the number of the animations and the fact that an animation can be associated to only one channel at a time.

Note
take in mind that the sum of all animation weights of a channel must be 1.0.
Parameters
animname of the animation.
weightblend weight to assign to animation.
channelchannel ID to assign to animation.
See also
PlayAnimation
bool Bool ( float  f)

This function convert an integer, a float, or a string value into a boolean value.

Warning
NOTE that there are 3 version of this function, one for every input type.
Parameters
fInput float.
bool Bool ( int  i)

This function convert an integer, a float, or a string value into a boolean value.

Warning
NOTE that there are 3 version of this function, one for every input type.
Parameters
iInput integer.
bool Bool ( string  s)

This function convert an integer, a float, or a string value into a boolean value.

Warning
NOTE that there are 3 version of this function, one for every input type.
Parameters
sInput string.
float Clamp ( float  scalar,
float  min,
float  max 
)

This function returns the clamped value of an input float number between a nim and a max value.

Parameters
scalarthe input float number
minthe clamp minimum value
maxthe clamp maximum value
1 /* clamp a number between 0.0 and 1.0 */
2 var float num;
3 num=10.0;
4 num=Clamp(0.0,1.0);
5 LOG("num="+string(num));
6 
7 /* RESULT */
8 num=1.0
See also
Abs,Min,Max
void CloseLevel ( )

This function closes an entire game scene.

float Cos ( float  angle)

This function returns the cosine value of a given angle. The angle value is expressed in degrees.

Parameters
anglevalue of the input angle expressed in degrees.
See also
Sin
void CreateHUD ( string  script)

This function creates the HUD main widget. Using CreateHUDWidget() function you can attach new widgets to it.

Note
Usually it is called inside player script.
Parameters
scriptfilename of the HUD script
void CreateHUDWidget ( string  class,
string  script,
string  params,
string  pos 
)

This function is equal to CreateWidget() function.

The only difference is that the created widget is attached to the main HUD frame, that becomes its parent.

Note
Usually it is called inside the player script.
Parameters
classtype of widget to create (see widgets)
scriptfilename of the script the widget must load when it is initialized. Remember scripts are resources.
paramslist of widgets params, specified inside a string (separated by ',' simbol):
  • name
  • text
  • width
  • height
  • horizontal alignment (-1 left, 0 center, 1 right, 2 free)
  • vertical alignment (-1 top, 0 center, 1 bottom, 2 free)
  • texture filename
  • font filename
  • Text alignment (-1 left, 0 center, 1 right)
poslocal position of the widget (two coordinates). The position is summed to widget alignment.
void CreateWidget ( string  class,
string  script,
string  params,
string  pos 
)

This function creates a GUI element (Widget). A widget can be a button, label, a dialog, a frame, etc.

Attention
When a widget is created inside a script of another widget, (that must belong to Container class) this last automatically becomes its parent. This is the mechanism that lets you to create a hierarchy of widgets. There are two main hierarchies of widget: GUI and HUD:
  • GUI: Is the main interface of the game, from which loading levels, save games, etc..
  • HUD: Is the interface of the player while the game running (energy, points, lives, ammo, etc..).
To set/get any param of the widget you have to use the SetParam, GetParam or SetSubWidgetParam, GetSubWidgetParam functions.
Parameters
classtype of widget to create (see widgets)
scriptfilename of the script the widget must load when it is initialized. Remember scripts are resources.
paramslist of widgets params, specified inside a string (separated by ',' simbol):
  • name
  • text
  • width
  • height
  • horizontal alignment (-1 left, 0 center, 1 right, 2 free)
  • vertical alignment (-1 top, 0 center, 1 bottom, 2 free)
  • texture filename
  • font filename
  • Text alignment (-1 left, 0 center, 1 right)
poslocal position of the widget (two coordinates). The position is summed to widget alignment.
void CrossFadeMusic ( string  music,
int  channel 
)

This function play a music on a given channel by fading in it and fading out all mucis playing on the other channels .

Note
There are up to 4 musics channels, every channel plays music indipendently.
Parameters
musicthe music filename.
channelthe channel index. Must be form 0 to 3.
See also
StopMusic, PlaySound, PlaySoundGlobal, PlayMusic
vec3 CrossProduct ( vec3  v1,
vec3  v2 
)

This function returns the cross product between two given 3D vectors.

Parameters
v1the first vector
v2the second vector
See also
DotProduct,NormalizeV
void DestroySubWidget ( string  widget)

This function destroys a child widget of this widget, if it exists.

Note
the child can also be child of child of child etc... Also be carefull when destroying a widget, be sure it is not used by any other.
Warning
This function can be executed only inside a widget script.
Parameters
widgetname of the child widget to destroy.
float DotProduct ( vec3  v1,
vec3  v2 
)

This function returns the Dot product between two given 3D vectors.

Parameters
v1the first vector
v2the second vector
See also
CrossProduct,NormalizeV
void EnginePause ( )

This function pauses the simulation or game.

In other words all active objects, animations, sound are paused.

void EngineResume ( )

This function resumes the simulation (or game) previously paused.

void Exit ( )

This function shutdown the engine and exit from the application.

void FindPath ( vec3  target)

This function computes an AI path from this object position to a given target point.

Note
After Path-find computation the AI system sends a message to the object: In the case of success it sends a "pathFound" message, otherwise it sends a "PathNotFound" message.
Parameters
targetpath target point.
float Float ( string  s)

This function convert an integer, or a string value into a float value.

Warning
NOTE that there are 2 version of this function, one for every input type.
Parameters
sinput string
float Float ( int  i)

This function convert an integer, or a string value into a float value.

Warning
NOTE that there are 2 version of this function, one for every input type.
Parameters
iinput integer
string GetAudioDevice ( int  i)

This function returns a string containing the description of the AudioDevice at index i.

Parameters
ithe index of the audio device
vec3 GetAxis ( string  axis)

This function returns one of the 3 axis of THIS object (object owning the script) orthonormal basis in localspace.

Parameters
axisname of the object axis to retrieve. Must be "fwd" (forward vector), "rgt" (right vector), "up" (up vector)
string GetEngineParam ( string  param)

This function returns the value of a specified param of the engine and its subsystems: render, audio, physics.

Parameters
paramname of the param to get.
See also
GetParam, SetParam, GetSubWidgetParam, SetSubWidgetParam
bool GetInputAction ( string  name)

This function returns the value of an input action given its identifying name.

Parameters
namea string identifying the input action
See also
GetInputAxis, InputMapping, Input
float GetInputAxis ( string  name)

This function returns the value of an input axis given its identifying name. Value returned is already scaled basing on the input map configuration.

Note
For pad sticks and mouse translations value returned is inside [-1*scaleValue,1*scaleValue] interval, for keyboard value returned is inside [0*scaleValue,1*scaleValue] interval. ScaleValue can be negative.
Parameters
namea string identifying the input axis
See also
GetInputAction, InputMapping, Input
string GetLevelParam ( string  param)

This function returns the value of a specified param of the current scene.

The returned value is always in string form, so it must be cast to the required type.

Parameters
paramname of the param to get.
1 float brightness;
2 brightness=float(GetLevelParam("brightness"));
See also
SetParam, GetSubWidgetParam, SetSubWidgetParam, GetParam
vec3 GetMousePos ( )

This function returns a 3d vector containing the mouse position.

Note
x and y coordinates of the returned vector are equal to the mouse cursor coordinates on screen, while the z coordinate is relative to the mouse wheel.
vec3 GetMouseRelPos ( )

This function returns a 3d vector containing the mouse position relative to the previous frame. In other words it returns the displace of the mouse from the previous frame, if mouse doesn't move, it returns a zero vector.

Note
x and y coordinates of the returned vector are equal to the mouse cursor coordinates on screen, while the z coordinate is relative to the mouse wheel.
int GetNumAudioDevice ( )

This function returns the number of audio devices supported by the hardware system.

int GetNumVideoModes ( )

This function returns the number of video modes supported by the hardware system.

Attention
In S2Engine a video mode is identified by video resolution and frequency, for example 1024x768x60 means a resolution of 1024x768 pixels at 60hz retrace frequency.
bool GetObjectFlag ( string  objname,
string  flag 
)

This function returns the value (TRUE or FALSE) of an object flag.

Parameters
objnamename of the object
flaginput flag. Valid flags are: cast_shadows,visible,collide,clip,moved,died,freezed,sleep.
See also
SetObjectFlags, ResetObjectFlags
bool GetObjectParam ( string  objname,
string  paramname,
bool  isStock 
)

This function returns the value of the parameter of an object as string. Every object has its own parameters depending on its class.

Parameters
objnamename of the object
paramnamename of the parameter to retrieve.
isStockTRUE if object is a stock object, otherwise the object is active
See also
SetObjectParam
bool GetObjectScriptParam ( string  objname,
string  paramname,
bool  isStock 
)

This function returns the value of the parameter of the object script as string.

Parameters
objnamename of the object
paramnamename of the parameter to retrieve.
isStockTRUE if object is a stock object, otherwise the object is active
See also
SetObjectParam, SetObjectScriptParam
vec3 GetObjectWorldAngles ( string  objname)

This function returns the orientation of an object in world space as euler angles. Angles are returned as a vec3 (yaw, pitch, roll).

Parameters
objnamename of the object
vec3 GetObjectWorldAxis ( string  objname,
string  axis 
)

This function returns one of the 3 axis of object orthonormal basis in worldspace.

Parameters
objnamename of the object
axisname of the object axis to retrieve. Must be "fwd" (forward vector), "rgt" (right vector), "up" (up vector)
vec3 GetObjectWorldPos ( string  objname)

This function returns the worldspace position of an object.

Parameters
objnamename of the object
See also
GetObjectLocalPos
string GetParam ( string  param)

This function returns the value of a specified param of this object if this is an object script or this widget if this is a widget script.

Parameters
paramname of the param to get.
See also
SetParam, SetSubWidgetParam
string GetPressedKey ( int  mode)

This function returns the pressed key, if there is one. Otherwise it returns null. There are 3 ways in which the keyboard key pression can be detected:

- \p 0 the keyboard key is detected as pressed until the user do not leave it.
- \p 1 the keyboard key is detected as pressed only the first time the user click the button and not if the button remains pressed.
- \p 2 the keyboard key is detected as pressed one time user leaves the button. 
Warning
To know what is the format of the returned key string refer to the detailed table of key strings in IsKeyPressed.
Parameters
modepression detection mode.
See also
IsKeyPressed
bool GetSubWidgetFlag ( string  sw,
string  flag 
)

This function returns the flag value (true or false) of a widget that is a child of this one.

Parameters
swthe name of the subwidget
flagthe name of the flag to obtain value
string GetSubWidgetParam ( string  widget,
string  param 
)

This function returns a param value of child widget of this widget, if it exists.

The param is identified by its name. The value returned is always a string, you have to cast it to type you need.

Note
The child can also be child of child of child etc...
Warning
This function can be executed only inside a widget script.
Parameters
widgetname of the child widget to destroy.
paramname od the param to get
string GetVideoMode ( int  i)

This function returns a string containing the description of the supported Video Mode at index i.

Video modes are represented in the following format: widthXheightXherz, where

  • width is the resolution width in pixels
  • height is the resolution height in pixels
  • herz is the vertical retrace frequency

Example: 1024X768X60.

Parameters
ithe index of the video mode.
vec3 GetWorldAxis ( string  axis)

This function returns one of the 3 axis of THIS object (object owning the script) orthonormal basis in worldspace.

Parameters
axisname of the object axis to retrieve. Must be "fwd" (forward vector), "rgt" (right vector), "up" (up vector)
int Int ( string  s)

This function convert a string value into an integer value.

Warning
NOTE that there are 2 version of this function, one for every input type.
Parameters
sinput string
int Int ( float  f)

This function convert a float value into an integer value.

Warning
NOTE that there are 2 version of this function, one for every input type.
Parameters
finput float
bool IsAnimationStopped ( int  channel)

This function returns true if the specified animation channel isn't playing. Otherwise it returns false.

Parameters
channelthe ID of the channel you want check if is stopped
See also
PlayAnimation, PauseAnimation, StopAnimation
bool IsKeyPressed ( string  key,
int  mode 
)

This function returns true if a keyboard key pressed. Otherwise it returns false.

Parameters
keythe identifing name of the key to detect.
modedetection mode.

There are 3 ways in which the keyboard key pression can be detected:

  • 0: the keyboard key is detected as pressed until the user do not leave it.
  • 1: the keyboard key is detected as pressed only the first time the user click the button and not if the button remains pressed.
  • 2: the keyboard key is detected as pressed one time user leaves the button.

The keys of the keyboard are identified by strings containing the respective character. For expample the key 'a' is identified by the string "a", the key 'b' is identified by string "b", the key '1' is identified by string "1", etc... However there are some special keyborad keys that are identified with special strings preceded by symbol @:

Key String
BACKSPACE "@backspace"
RETURN "@return"
LCONTROL "@lcontrol"
RCONTROL "@rcontrol"
LSHIFT "@lshift"
RSHIFT "@rshift"
CAPSLOCK "@capslock"
NUMLOCK "@numlock"
TAB "@tab"
ESC "@esc"
F1 "@f1"
F2 "@f2"
F3 "@f3"
F4 "@f4"
F5 "@f5"
F6 "@f6"
F7 "@f7"
F8 "@f8"
F9 "@f9"
F10 "@f10"
F11 "@f11"
F12 "@f12"
NUMPAD0 "@numpad0"
NUMPAD1 "@numpad1"
NUMPAD2 "@numpad2"
NUMPAD3 "@numpad3"
NUMPAD4 "@numpad4"
NUMPAD5 "@numpad5"
NUMPAD6 "@numpad6"
NUMPAD7 "@numpad7"
NUMPAD8 "@numpad8"
NUMPAD9 "@numpad9"
UP "@up"
DOWN "@down"
RIGHT "@right"
LEFT "@left"
INS "@ins"
PGDOWN "@pgdown"
PGUP "@pgup"
DEL "@del"
HOME "@home"
NUMPADADD "@add"
NUMPADSUB "@sub"
NUMPADDIV "@div"
NUMPADDEC "@dec"
NUMPADENTER "@enter"
RALT "@ralt"
LALT "@lalt"
SCROLL "@scroll"
END "@end"


bool IsSoundPlaying ( )

This function returns true if the sounde source of this object is still playing a sound. Otherwise returns false.

See also
PlayMusic, PlaySound, PlaySoundGlobal
string Load ( string  path)

This function loads a text file and returns its content as a string.

Usually this function is used in conjunction with string manipulation functions, such as GetToken(), for parsing the returned string.

Parameters
paththe path of the file to load
See also
Save, GetToken, GetNumTokens
bool LoadLevel ( string  level)

This function loads a game scene given its filename.

Note
It is asynchronous, this means that the function returns instantly but scene isn't loaded in the moment function is called. When scene is loaded successfully a message named LevelDidLoaded is sent to the GUI MainFrame widget.
See also
Widgets.
Parameters
levelfilename of the game scene to load
void LoadResource ( string  resPath,
string  cache 
)

This function loads a resource given its filename.

The filename must include also the relative path. Resource are loaded, stored and released by the Resource Manager. Resource manager stores resources into 3 different types of cache memory:

  • Level: all resources stored in this cache are released when a level is closed
  • Static: all resources stored in this cache are released when engine shutdown
  • Temporary: all resources stored in this cache are released when ClearTemporaryCache() function is called.

In S2Engine HD resources are:

  • texture
  • material
  • model
  • script
  • modelscript
  • sound
  • animation

Every resource type has its directory: textures are in 'Textures' directory, materials in 'Materials', etc... Basing on the file extension S2Engine HD automatically recognizes the type of resource to load and puts the file pointer into the right resource type directory. So when you insert the resource filename to load you haven't to specify the main resource directory, only subdirectories if exist. When a resource is loaded it is stored inside a cache by Resource Manager. So, when the system require a resource, for example a sound to play with PlaySound function, the resource manager haven't to load the resource again. So the LoadResource function is useful to avoid loading a resource just when strictly required but also at initialization time, to speed things up.

Parameters
resPathfilename (and relative path) of the resource to load
cachestring identifying the cache in which store the resource. It can be: 'level', 'static', 'temp'
1 /* this is the RIGHT example for loading the texture prova.tga that is inside S2EngineHD/Textures/Pippo directory and storing inside level cache*/
2 LoadResource("Pippo/prova.tga","level");
3 
4 /* this is the WRONG example */
5 LoadResource("Texture/Pippo/prova.tga","level");
6 
7 /* this is also WRONG */
8 LoadResource("S2EngineHD/Texture/Pippo/prova.tga","level");
void LOG ( string  str)

The function writes the input string into the S2Engine LOG file.

Attention
The LOG file can be viewed also inside the editor.
Parameters
strthe string to write into the LOG file.
float Max ( float  a,
float  b 
)

This function returns the maximum value between two given float values.

Parameters
athe first float value
bthe second float value
See also
Abs,Min,Clamp
float Min ( float  a,
float  b 
)

This function returns the minimum value between two given float values.

Parameters
athe first float value
bthe second float value
See also
Abs,Max,Clamp
vec3 NormalizeV ( vec3  v)

This function returns a normalized 3d vector.

Parameters
vInput vector
See also
VectorInterpolate,VectorLen,DotProduct,CrossProduct,VectorRotate,VectorToAngles
void PauseAnimation ( int  channel)

This function pause an animation channel, i.e. it pauses all the animations of the channel.

It differs from StopAnmiation function because It doesn't rewind the animations and it leaves weights unchanged.

Parameters
channelanimation channel ID to pause.
See also
PlayAnimation, StopAnimation
void PhysicsApplyDirForceToRagdoll ( vec3  dir,
float  len 
)

This function applies a directional force to all the nodes of the Ragdoll associated to this object. Directional means that there is no need for a point of application.

Note
This function has effects only if a physics ragdoll is previously created for this object.
Attention
This function has two different versions.
Parameters
dirforce direction normalize vector.
lenintensity of the force
axisname of the axis to use as force direction:
  • "fwd": this object forward axis.
  • "rgt": this objectright axis.
  • "up": this objectup axis.
  • "camfwd": camera forward axis.
  • "camrgt": camera right axis.
  • "camup": camera up axis.
void PhysicsApplyDirForceToRagdoll ( string  axis,
float  len 
)

This function applies a directional force to all the nodes of the Ragdoll associated to this object. Directional means that there is no need for a point of application.

Note
This function has effects only if a physics ragdoll is previously created for this object.
Attention
This function has two different versions.
Parameters
lenintensity of the force
axisname of the axis to use as force direction:
  • "fwd": this object forward axis.
  • "rgt": this objectright axis.
  • "up": this objectup axis.
  • "camfwd": camera forward axis.
  • "camrgt": camera right axis.
  • "camup": camera up axis.
void PhysicsApplyForce ( vec3  point,
vec3  dir,
float  len 
)

This function applies a force to this object if it has a physics object associated.

Note
If this function is applied on characters, the point of application is ignored.
Attention
This function has two different versions.
Parameters
pointpoint of application of the force.
dirforce direction normalize vector.
lenintensity of the force
void PhysicsApplyForce ( vec3  point,
string  axis,
float  len 
)

This function applies a force to this object if it has a physics object associated.

Note
If this function is applied on characters, the point of application is ignored.
Attention
This function has two different versions.
Parameters
pointpoint of application of the force.
lenintensity of the force
axisname of the axis to use as force direction:
  • "fwd": this object forward axis.
  • "rgt": this object right axis.
  • "up": this object up axis.
  • "camfwd": camera forward axis.
  • "camrgt": camera right axis.
  • "camup": camera up axis.
void PhysicsApplyForceToNode ( string  node,
vec3  point,
vec3  dir,
float  len 
)

This function applies a force to a node of this object. This function has effect only if the object node has a physics object associated, i.e. in the case of a Ragdoll.

Note
If this function is applied on characters, the point of application is ignored.
Attention
This function has two different versions.
Parameters
nodename of the node on which to apply force.
pointpoint of application of the force.
dirforce direction normalize vector.
lenintensity of the force
void PhysicsApplyForceToNode ( string  node,
vec3  point,
string  axis,
float  len 
)

This function applies a force to a node of this object. This function has effect only if the object node has a physics object associated, i.e. in the case of a Ragdoll.

Note
If this function is applied on characters, the point of application is ignored.
Attention
This function has two different versions.
Parameters
nodename of the node on which to apply force.
pointpoint of application of the force.
lenintensity of the force
axisname of the axis to use as force direction:
  • "camfwd" camera forward axis.
  • "camrgt" camera right axis.
  • "camup" camera up axis.
void PhysicsApplyForceToObject ( string  obj,
vec3  point,
vec3  dir,
float  len 
)

This function applies a force to an object if it has a physics object associated. The object is identified by its name.

Note
If this function is applied on characters, the point of application is ignored.
Attention
This function has two different versions.
Parameters
objname of the object to which apply force.
pointpoint of application of the force.
dirforce direction normalize vector.
lenintensity of the force
void PhysicsApplyForceToObject ( string  obj,
vec3  point,
string  axis,
float  len 
)

This function applies a force to an object if it has a physics object associated. The object is identified by its name.

Note
If this function is applied on characters, the point of application is ignored.
Attention
This function has two different versions.
Parameters
objname of the object to which apply force.
pointpoint of application of the force.
lenintensity of the force
axisname of the axis to use as force direction:
  • "fwd": this object forward axis.
  • "rgt": this object right axis.
  • "up": this object up axis.
  • "camfwd": camera forward axis.
  • "camrgt": camera right axis.
  • "camup": camera up axis.
void PhysicsApplyForceToRagdoll ( vec3  point,
vec3  dir,
float  len 
)

This function applies a force to an object if it has a physics object associated. The object is identified by its name.

Note
If this function is applied on characters, the point of application is ignored.
Attention
This function has two different versions.
Parameters
pointpoint of application of the force.
dirforce direction normalize vector.
lenintensity of the force
See also
PhysicsCreateRagdoll, PhysicsApplyDirForceToRagdoll
void PhysicsApplyForceToRagdoll ( vec3  point,
string  axis,
float  len 
)

This function applies a force to all the nodes of the Ragdoll associated to this object.

Note
This function has effects only if a physics ragdoll is previously created for this object.
This function has two different versions.
Parameters
pointpoint of application of the force.
lenintensity of the force
axisname of the axis to use as force direction:
  • "fwd": this object forward axis.
  • "rgt": this objectright axis.
  • "up": this objectup axis.
  • "camfwd": camera forward axis.
  • "camrgt": camera right axis.
  • "camup": camera up axis.
See also
PhysicsCreateRagdoll, PhysicsApplyDirForceToRagdoll
void PhysicsApplyGravity ( bool  apply)

This function sets to true/false the gravity application on the physics object associated to this object except if it is a character.

By default, gravity is applied.

Parameters
applytrue if you want to apply gravity, false otherwise.
bool PhysicsCharacterCollisionTest ( string  obj,
vec3  start,
vec3  end 
)

This function executes the Sweep test of an object using the capsule of a physics character associated to it.

The sweep test is made by extruding the character capsule from a start point to an end point and checking if there is some object inside the extrusion. It returns true if the sweep test has success, false otherwise.

Note
the object must have a physics character associated with it (using PhysicsCreateCharacter function).
Parameters
nameof the object that has a physics character associated.
startstart point.
endend point.
void PhysicsCharacterMove ( vec3  dir,
float  disp 
)

This function moves this object if it is associated with a physics character. By default, gravity is applied on the characters movement. You can use PhysicsSetCharacterGravity function to enable/disable the gravity applied on the characters.

Note
This function must be called inside Update() script callback function.
Parameters
dirnormalized direction of the movement
dispamount of movement displacement
void PhysicsCharacterToRagdoll ( )

This function stops all animation channels, wakeUp the ragdoll associated with This Object, excludes from collision and set to sleeping the physics character associated with this object. In other words this function makes the Ragdoll simulation starting.

Note
this function has effects only if this object is associated with a physics character and has a ragdoll. This can be achieved by calling PhysicsCreateCharacter and PhysicsCreateRagdoll functions at object initialization time.
See also
PhysicsCreateCharacter, PhysicsCreateRagdoll, PhysicsObjectWakeUp, PhysicsObjectSleep, PhysicsRagdollWakeUp
void PhysicsCollisionTest ( float  radius,
vec3  start,
vec3  end 
)

This function executes the Collision(Sweep) Test test of a sphere. The sweep test is made by extruding the sphere from a start point to an end point and checking if there is some object inside the extrusion. It returns true if the sweep test has success, false otherwise.

Parameters
radiussphere radius.
startstart point.
endend point.
void PhysicsCreateBody ( string  coltype,
float  mass,
vec3  props 
)

This function creates a physics rigid body and associates it to 'this object'.

Note
This object must belongs to class Entity.
Parameters
coltypetype of collider. For now 4 types of collider can be specified:
  • box: the box dimensions are taken from the coordinates of object dims param.
  • cylinder: the cylinder dimensions are taken from the first(radius) and second(height) coodinate of object dims param.
  • sphere: the sphere radius is taken from the first coodinate of object dims param.
  • mesh: the mesh file is taken from the colmesh object param.
massmass of the body. If it is 0.0 the body is considered static (like it happens for MeshObjects).
props(optional)is a vector containing 3 scalars representing 3 physical props of the body:
  • 0 = restitution
  • 1 = static friction
  • 2 = dynamic friction
void PhysicsCreateCharacter ( )

This function creates a character into the physics subsystem and associates it to this object. The Characters of the physics subsystem are specifically designed for intergrating the game-like character control with a realistic physical simulation.

Note
This object must belongs to class Entity.
void PhysicsCreateCharacter ( float  slopeLimit)

This function creates a character into the physics subsystem and associates it to this object. The Characters of the physics subsystem are specifically designed for intergrating the game-like character control with a realistic physical simulation.

Note
This object must belongs to class Entity.
Parameters
slopeLimit:Themaximum slope which the character can walk up. From 0.0 (planar slope) to 1.0 (maximum slope, 180 degree). The limit is expressed as the cosine of desired limit angle. A value of 0.0 disables this feature. Default value is 0.707 ( cos(45) )
void PhysicsCreateRagdoll ( )

This function creates a Ragdoll basing on this object model format.

It associates the created ragdoll to this object.

void PhysicsCreateVehicle ( string  vehicleBody,
string  frontWheels,
string  backWheels,
string  props 
)

TThis function creates a vehicle into the physics subsystem and associates it to this object.

The Vehicles of the physics subsystem are specifically designed for easly simulating physical vehicle behavior.

Note
This object must belongs to class Entity.
Parameters
vechicleBodyname of the node of this object containing the body of the vehicle.
frontWheelsstring containing the list of names of the nodes of this object containing vehicle front wheels. the names must be separated by symbol ',' .
backWheelsstring containing the list of names of the nodes of this object containing vehicle back wheels. the names must be separated by symbol ',' .
propsstring containing the list of properties of the vehicle, the properties must be separated by symbol ',':
  • mass: mass of the vehicle.
  • minRpm: minimum rotations per minute of the vehicle engine.
  • maxRpm: maximum rotations per minute of the vehicle engine.
  • suspension: amount of wheels suspension.
  • lateralFriction: lateral frictional force applied to the wheels.
  • frontFriction: front frictional force applied to wheels.
  • COM_Height: height of vehicle center of mass. It is responsible of vehicle stabilty. A lower COM, a better stability.

Example

1 /* Create a phytsics vehicle: wheel01,wheel02 are front wheels, wheel03 and wheel04 are back wheel, COM Height is at -95 */
2 PhysicsCreateVehicle("carBody","wheel01,wheel02","wheel03,wheel04","200,11000,5000,7,0.05,10,-95");
vec3 PhysicsGetCharacterDims ( )

This function returns the dimensions of the capsule of a physics character associated to this object.

string PhysicsGetCollidedObject ( )

This function returns the name of the object collided in a previous sweep test.

If no object has collided it returns "null" string.

Note
This function must be called after calling PhysicsCollisionTest function.
See also
PhysicsGetCollisionNormal
bool PhysicsGetCollideFlag ( )

This function returns true if the physics object associated with this object can collide, false otherwise.

The function has effects on all type of physics objects:

vec3 PhysicsGetCollisionNormal ( )

This function returns the collision normal of the object collided in a previous sweep test.

Note
This function must be called after calling PhysicsCollisionTest function.
vec3 PhysicsGetObjectPos ( )

This function returns the position of this object if it is associated to a physics object.

This function is useful to know the position of this object when it is controlled by physics simulation.

float PhysicsGetVehicleRPM ( )

This function returns the rotation per minute (RPM) of the engine of physics vehicle associated to this object.

This function is useful, for example, when you want to set the pitch of vechicle engine sound in relation with its velocity.

bool PhysicsNodeCollisionTest ( string  obj,
string  node,
float  radius,
vec3  disp 
)

This function executes the Sweep test of an object node using a capsule builded from the node and the parent node world positions.

The sweep test is made by extruding the capsule, created from node and parent node positions, along a displace 3d vector checking if there is some object inside the extrusion. It returns true if the sweep test has success, false otherwise.

Note
this function can be applied to all objects that have a hierarchy, even if they haven't a physics object associated.
Parameters
objname of the object containing the node you want to execute the seep test.
nodename of the node you want to execute sweep test
radiusradius of the capsule of the sweep test.
disp3d vector containing the displace of the capsule.
bool PhysicsObjectIsSleeping ( )

This functions returns true if the state of physics object associated with this object is set to sleeping, otherwise returns false.

When a body does not move for a period of time, it is assumed that it will remain immobile until an external force throws it out of equilibrium, in this case we say the body is sleeping. Usually physics system does it automatically but sometime it is possible you would to force it. This function lets you to know the sleeping state of the body.

See also
PhysicsObjectSleep, PhysicsObjectWakeUp
void PhysicsObjectSleep ( )

This functions sets the state of the body associated with this object to sleeping.

When a body does not move for a period of time, it is assumed that it will remain immobile until an external force throws it out of equilibrium, in this case we say the body is sleeping. Usually physics system does it automatically but sometime it is possible you would to force it. This function lets you to force the state of the body to sleep.

See also
PhysicsObjectWakeUp
void PhysicsObjectWakeUp ( )

This functions sets the state of the body associated with this object to wake up.

You can use it when you want to wake up a sleeping body.

See also
PhysicsObjectSleep
void PhysicsRagdollSleep ( )

This functions sets the state of a ragdoll associated with this object (i.e. the state the all the ragdoll capsules) to sleeping.

See also
PhysicsObjectWakeUp, PhysicsObjectSleep, PhysicsRagdollWakeUp
void PhysicsRagdollWakeUp ( )

This functions sets the state of a ragdoll associated with this object (i.e. the state the all the ragdoll capsules) to wake up.

See also
PhysicsObjectWakeUp, PhysicsObjectSleep, PhysicsRagdollSleep
void PhysicsResetCollideFlag ( )

This function sets to false the collide flag of physics object associated with this object.

So, calling this function, the object doesn't collide with others. The function has effects on all type of physics objects:

void PhysicsResetRagdollCollideFlag ( )

This function sets to false the collide flag of all the capsules of a ragdoll associated with this object.

So, calling this function, the ragdoll doesn't collide with other objects.

Note
This function has effect only if this object has a ragdoll associated with it.
void PhysicsSetCharacterDims ( vec3  dims)

This function sets the dimensions of the capsule of a physics character associated to this object.

Note
The first coordinate is the capsule radius, the second is the height of the capsule. This function is often used to change the character height, for example to make character crouch.
Parameters
dimsdimensions to set.
void PhysicsSetCharacterGravity ( float  gravity)

This function sets the amount of the gravity applied on the physics character associated with this object.

By default, gravity has the same value of gravity applied on all the other physics objects.

Note
this function has effects only if this object is associated to a physics character.
Parameters
gravitythe amount of gravity to apply to character.
See also
PhysicsCreateCharacter
void PhysicsSetCollideFlag ( )

This function sets to true the collide flag of physics object associated with this object.

So, calling this function, the object collide with others. The function has effects on all type of physics objects:

void PhysicsSetObjectPos ( vec3  pos)

This function stes the position of this object if it is associated to a physics object.

This function is useful to ses the position of this object when it is controlled by physics simulation.

Parameters
posnew position to set.
void PhysicsSetRagdollCollideFlag ( )

This function sets to true the collide flag of all the capsules of a ragdoll associated with this object.

So, calling this function, the ragdoll will collide with the other objects.

Note
This function has effect only if this object has a ragdoll associated with it.
void PhysicsVehicleControl ( float  steerAngle,
float  acc,
bool  handbrake 
)

This function moves this object if it is associated with a physics vehicle.

Note
This function must be called inside Update() script callback function.
Parameters
steerAnglethe rotation angle, expressed in degree, of the steering wheel. Negative values mean turning left, positive values mean turning right.
accamount of accelleration pedal or brake pedal pression. Values can be into the interval [-1.0,1.0]. Negative values mean brake pedal pression, positive values mean accelleration pedal pression.
Note
If the vehicle starts from zero, negative values mean reverse gear.
Parameters
handbraketrue if hadbrake is pressed, false otherwise.
void PlayAnimation ( int  channel,
bool  loop 
)

This function plays all the animations of a channel.

Usually It is used in conjunction of BlendCurrentAnimation that sets the weight factor of an animation and assigns it to a channel.

Parameters
channelthe id of the channel animation belong.
looptrue if the animaion must loop, false otherwise.
1 /* Assign 'idle' animation to channel 0 and set its weight to 1.0 (max) */
2 BlendCurrentAnimation("idle",1.0,0);
3 
4 /* Play channel 0 animations in loop, in this case only 'idle' */
5 PlayAnimation(true,0);
See also
StopAnimation, PauseAnimation, BlendCurrentAnimation
void PlayMusic ( string  music,
int  channel 
)

This function play a music on a given channel.

Note
There are up to 4 musics channels, every channel plays music indipendently.
Parameters
musicthe music filename.
channelthe channel index. Must be form 0 to 3.
See also
StopMusic, PlaySound, PlaySoundGlobal
void PlaySound ( string  sound,
bool  loop 
)

This function plays a sound given its filename.

Note
To play a sound an object must have a sound source created with the SetSource function.
Every object can have only one sound source.
Parameters
soundthe sound filename.
looptrue if the sound must loop. Otherwise false.
See also
SetSource, SetSourceVolume, SetSourcePitch, SetSourceRange, StopSound, PlaySoundGlobal
void PlaySoundGlobal ( string  sound,
bool  loop 
)

This function plays a global sound given its filename.

Note
Global sounds do not need to have a source into an object, they are global in the sense that, unlike normal sounds, they can be heard in every place of the scene. There is only one global sound source.
Parameters
soundthe sound filename.
looptrue if the sound must loop. Otherwise false.
See also
SetSource, SetSourceVolume, SetSourcePitch, SetSourceRange, StopSound
float Rand ( int  res)

This function returns a float random number between 0.0 and 1.0 given the number of all possible choices.

Parameters
resmax number of all possible choices
1 /* return a random number between 0.0 and 1.0 choosed among 5000 possibilities */
2 var float a;
3 a=Rand(5000);
bool ReceivedMessage ( string  msg)

This is a special function that has effect only inside the Message() main function. It returns true if the message msg has been received.

Parameters
msgname of the message.
void ResetObjectFlags ( string  objname,
string  flags 
)

This function sets to FALSE all input flags of an object.

Parameters
objnamename of the object
flagsinput flags list, it is composed by name of the flags to set separated by symbol '|'. Valid flags are: cast_shadows,visible,collide,clip,moved,died,freezed,sleep.
void ResetSubWidgetFlag ( string  sw,
string  flags 
)

This function resets( sets to false) the flags of a widget that is a child of this one.

The flags must be composed into a string of names separated by '|' symbol (for example: "flag1|flag2|flag3").

Parameters
swthe name of the subwidget
flagslist of the flags to reset
1 /* set to false the flag grayed of subwidget button01 */
2 ResetSubWidgetFlags("button01","w_grayed");
See also
GetFlag, GetSubWidgetFlag, SetSubWidgetFlags
void RestartLevel ( )

This function restores the starting state of the game scene without close/reload it.

Useful to make player restarting quickly the current game scene.

void Save ( string  text,
string  path 
)

This function saves a string into a text file.

Parameters
textthe string to save
paththe path of the file in which to save
See also
Load, GetToken, GetNumTokens
float ScalarInterpolate ( float  s1,
float  s2,
float  t 
)

This function returns the result of the linear interpolation between two input float numbers, given the parameter t.

Parameters
s1first scalar
s2second scalar
tInterpolation parameter. It must be between 0.0 and 1.0.
See also
VectorInterpolate
vec3 ScreenToWorld ( vec3  p)

This function transforms a point from screen coordinates space to world coordinates space. This function is useful, for example, when you need to check if the user have clicked on a 3d object with the mouse cursor.

Note
Since the screen is a 2d plane but world is a 3d space, you have to specify also the 3th coordinate of the input point that into the resulting point remains unchanged.
Parameters
pthe input point
1 /* we want to know if mouse has picked some object of the scene */
2 var vec3 p0;
3 var vec3 p1;
4 p0=GetMousePos();
5 
6 p0.z=0.0; /* this point is near the screen */
7 p1=p0;
8 p1.z=99999.0 /* this point is very far from screen */
9 
10 /* project these two points into 3d world space */
11 p0=ScreenToWorld(p0);
12 p1=ScreenToWorld(p1);
13 
14 /* ray cast */
15 RayPick(p0,p1-p0,1.0);
16 
17 /* Get picked object */
18 var string pickObj;
19 pickObj=GetPickObject();
See also
WorldToScreen
void SendMessageBroad ( string  dest,
string  name,
string  content 
)

This function send a message to all active objects.

Note
the sender is this object or this widget.
Parameters
destis the destination object name
nameis the name of the message
contentis the content of the message
void SendMessageBroad ( string  dest,
string  name,
string  content,
float  delay 
)

This function send a message to all active objects.

Note
the sender is this object or this widget.
Parameters
destis the destination object name
nameis the name of the message
contentis the content of the message
delayis the time delay you want message must be sent. It is expressed in milliseconds. A value < 0.0 means that message is sent in immediate mode (i.e. just it is a normal function), A value equal to 0.0 means the message is sent in the next message processing phase (this is the default value and it is just as if delay param is omitted)
void SendMessageGUI ( string  name,
string  content 
)

This function sends a message to the main widget of the GUI.

Note
the sender is this object or this widget.
Parameters
nameis the name of the message
contentis the content of the message
void SendMessageGUI ( string  name,
string  content,
float  delay 
)

This function sends a message to the main Widget of the GUI.

Note
the sender is this object or this widget.
Parameters
nameis the name of the message
contentis the content of the message
delay(availablefrom 1.03.01) is the time delay you want message must be sent. It is expressed in milliseconds. A value < 0.0 means that message is sent in immediate mode (i.e. just it is a normal function), A value equal to 0.0 means the message is sent in the next message processing phase (this is the default value and it is just as if delay param is omitted)
void SendMessageHUD ( string  name,
string  content 
)

This function sends a message to the main widget of the HUD.

Note
the sender is this object or this widget.
Parameters
nameis the name of the message
contentis the content of the message
void SendMessageHUD ( string  name,
string  content,
float  delay 
)

This function sends a message to the main Widget of the HUD.

Note
the sender is this object or this widget.
Parameters
nameis the name of the message
contentis the content of the message
delay(availablefrom 1.03.01) is the time delay you want message must be sent. It is expressed in milliseconds. A value < 0.0 means that message is sent in immediate mode (i.e. just it is a normal function), A value equal to 0.0 means the message is sent in the next message processing phase (this is the default value and it is just as if delay param is omitted)
void SendMessageMulti ( string  name,
string  content,
float  range,
string  class 
)

This function send a message to more than one active object. The receiver objects are choosen basing on a range of influence and a specified class.

Note
the sender is this object or this widget.
Parameters
nameis the name of the message
contentis the content of the message
rangeis the range of influence. If 0.0 the range is considered infinite.
classis the class of the receivers. If NULL is specified, all objects are considered. If delay is specified class is automatically set to null
void SendMessageMulti ( string  name,
string  content,
float  range,
float  delay 
)

This function send a message to more than one active object. The receiver objects are choosen basing on a range of influence and a specified class.

Note
the sender is this object or this widget.
Parameters
nameis the name of the message
contentis the content of the message
rangeis the range of influence. If 0.0 the range is considered infinite.
classis the class of the receivers. If NULL is specified, all objects are considered. If delay is specified class is automatically set to null
delayis the time delay you want message must be sent. It is expressed in milliseconds. A value < 0.0 means that message is sent in immediate mode (i.e. just it is a normal function), A value equal to 0.0 means the message is sent in the next message processing phase (this is the default value and it is just as if delay param is omitted)
void SendMessageSingle ( string  dest,
string  name,
string  content 
)

This function send a message to a single active object given its name.

Note
the sender is this object or this widget.
Parameters
destis the destination object name
nameis the name of the message
contentis the content of the message
void SendMessageSingle ( string  dest,
string  name,
string  content,
float  delay 
)

This function send a message to a single active object given its name.

Note
the sender is this object or this widget.
Parameters
destis the destination object name
nameis the name of the message
contentis the content of the message
delayis the time delay you want message must be sent. It is expressed in milliseconds. A value < 0.0 means that message is sent in immediate mode (i.e. just it is a normal function), A value equal to 0.0 means the message is sent in the next message processing phase (this is the default value and it is just as if delay param is omitted)
void SetAnimationBlendX ( int  channel,
string  animName,
float  value 
)

This function assigns a blend float value to a blended animation in X direction.

This means that if blended animation is 1D it affects to the blending of source animations, if blended animation is 2D it affects the blending of source animations of a row of 2D blending table.

Parameters
channelID of the channel to which add the animation
animNamename of the blended animation to set value
valuefloat value to set ranging from 0 to 1
See also
SetAnimationBlendY, 1D/2D Blended animations
void SetAnimationBlendY ( int  channel,
string  animName,
float  value 
)

This function assigns a blend float value to a blended animation in Y direction.

This means that if blended animation is 1D it DOESN'T affects to the blending of source animations, if blended animation is 2D it affects the blending of source animations of a column of 2D blending table.

Parameters
channelID of the channel to which add the animation
animNamename of the blended animation to set value
valuefloat value to set ranging from 0 to 1
See also
SetAnimationBlendX, 1D/2D Blended animations
void SetAnimationChannelMask ( int  channel,
string  maskname 
)

This function assigns a mask to a given channel.

The mask is identified by its name. Animation channel masks are described inside modelscript files.

Parameters
channelanimation channel ID to pause.
masknamename of the mask to assign.
See also
BlendAnimationChannel, SetAnimationChannelSpeed, AnimationChannelFadeIn, AnimationChannelFadeOut
void SetAnimationChannelSpeed ( int  channel,
float  speed 
)

This function sets the overall speed of an animation channel.

Parameters
channelthe id of the channel.
speednew speed value.
void SetEngineParam ( string  param,
string  value 
)

This function sets the value of a specified param of the engine and its subsystems: Render, Physics, Audio.

Parameters
paramname of the param to set.
valuevalue to set.
See also
GetParam, SetParam, GetSubWidgetParam, SetSubWidgetParam
void SetLevelParam ( string  param,
string  value 
)

This function sets the value of a specified param of the current scene.

Parameters
paramname of the param to set.
valuevalue to set.
See also
GetParam, SetParam, GetSubWidgetParam, SetSubWidgetParam
void SetObjectFlags ( string  objname,
string  flags 
)

This function sets to TRUE all input flags of an object.

Parameters
objnamename of the object
flagsinput flags list, it is composed by name of the flags to set separated by symbol '|'. Valid flags are: cast_shadows,visible,collide,clip,moved,died,freezed,sleep.
bool SetObjectParam ( string  objname,
string  paramname,
string  paramvalue 
)

This function sets the value of the parameter of an object given as string.

Parameters
objnamename of the object
paramnamename of the parameter to retrieve.
paramvaluevalue of the parameter to set (must be a string)
See also
GetObjectParam
void SetParam ( string  param,
string  value 
)

This function sets the value of a specified param of this object if this is an object script or this widget if this is a widget script.

Parameters
paramname of the param to set.
valuevalue to set.
See also
GetParam, GetSubWidgetParam
void SetSource ( float  gain,
float  range 
)

This function creates a sound source and assign it to this object.

Note
Every object can have only one sound source.
Every operation that requires a source, like SetSourcePitch, SetSourceRange, SetSourceVolume, PlaySound, StopSound, requires also first the SetSource function calling.
Parameters
gainsound source volume
rangesound source range of influence
See also
PlaySound, SetSourceVolume, SetSourcePitch, SetSourceRange, StopSound
void SetSourcePitch ( float  pitch)

This function sets the sound source pitch.

Useful to simulate the noise of a car engine that accellerates.

Note
The sound source must be the one associated with this object.
Parameters
pitchsound source pitch.
See also
SetSourceVolume, SetSource, SetSourceRange
void SetSourceRange ( float  range)

This function sets the sound source range of influence.

Note
The sound source must be the one associated with this object.
Parameters
rangesound source range of influence.
See also
SetSourceVolume, SetSource, SetSourcePitch
void SetSourceVolume ( float  volume)

This function sets the sound source volume.

Note
The sound source must be the one associated with this object.
Parameters
volumesound source volume.
See also
SetSourceRange, SetSource, SetSourcePitch
void SetSubWidgetFlag ( string  sw,
string  flags 
)

This function sets (to true) the flags of a widget that is a child of this one.

The flags must be composed into a string of names separated by '|' symbol (for example: "flag1|flag2|flag3").

Parameters
swthe name of the subwidget
flagslist of the flags to set
1 /* set to true the flag grayed of subwidget button01 */
2 SetSubWidgetFlags("button01","w_grayed");
See also
GetFlag, GetSubWidgetFlag, ResetSubWidgetFlags
void SetSubWidgetOpacity ( string  widget,
float  opacity 
)

This function sets the opacity level of the tree starting from the child widget of this widget.

The Opacity of a widget can be set also with SetParam() and param "opacity", but in this case only the widget opacity is modified, not the opacity of whole subtree.

Note
The child can also be child of child of child etc...
This function can be executed only inside a widget script.
Parameters
widgetname of the child widget to change opacity.
opacityopacity value to set
See also
GetFlag, GetSubWidgetFlag, ResetSubWidgetFlags
void SetSubWidgetParam ( string  widget,
string  param,
string  value 
)

This function assigns a value to a param of child widget of this widget, if it exists.

The param is identified by its name. The value must be always a string so it must be converted before assign it.

Note
The child can also be child of child of child etc...
Warning
this function can be executed only inside a widget script.
Parameters
widgetname of the child widget to destroy.
paramname of the param to set
valuevalue to assign to the param
void SetSubWidgetPos ( string  widget,
float  x,
float  y 
)

This function assigns a new position to the child widget of this widget.

Calling It is equivalent to call the SetSubWidgetParam and specify the pos param. Take in mind that the position of the child widget is always relative to the position of parent widget.

Note
The child can also be child of child of child etc...
Warning
this function can be executed only inside a widget script.
Parameters
widgetname of the child widget to assign position.
xvalue of the new x coordinate
yvalue of the new y coordinate
void SetTimeScale ( float  timeMul)

This function sets the simulation time speed multiplier.

Note
In S2Engine HD is possible accelerating or slowing the overall time of simulation.
Parameters
timeMulthe time multiplier.
1 /* Make the simulation running at double speed */
2 SetTimeScale(2.0);
void SetWidgetOpacity ( float  opacity)

This function sets the opacity level of the tree starting from this widget.

The Opacity of a widget can be set also with SetParam() and param "opacity", but in this case only the widget opacity is modified, not the opacity of whole subtree.

Note
This function can be executed only inside a widget script.
Parameters
opacityopacity value to set
void ShowCursor ( bool  show)

This function shows/hides the GUI cursor. It has effects only into the main GUI widget.

Parameters
showtrue if you want to show the cursor, false otherwise.
void ShowParentWidget ( bool  show)

This function shows/hides the parent of this widget.

Note
This function can be executed only inside a widget script.
Parameters
showtrue if you want to show the widget, false otherwise.
See also
ShowSubWidget, ShowWidget, ShowCursor
void ShowSubWidget ( string  widget,
bool  show 
)

This function shows/hides a child of this widget given its name.

Take in mind that this function has effect on the whole subtree of the widget, if it is a composed widget.

Note
the child can also be child of child of child etc...
Warning
this function can be executed only inside a widget script.
Parameters
widgetname of the widget to show/hide.
showtrue if you want to show the widget, false otherwise.
See also
ShowParentWidget , ShowWidget, ShowCursor
void ShowWidget ( bool  show)

This function shows/hides this widget.

If this widget is composed by other widgets, this function has effect also on them, i.e. on all this widget subtree.

Warning
It can be called only inside widget script.
Parameters
showtrue if you want to show the widget, false otherwise.
See also
ShowSubWidget , ShowParentWidget, ShowCursor
float Sin ( float  angle)

This function returns the sine value of a given angle. The angle value is expressed in degrees.

Parameters
anglevalue of the input angle expressed in degrees.
See also
Cos
void SpawnObject ( string  prefabFilename,
vec3  pos,
vec3  angles 
)

This function creates an object taking its description from a prefab resource.

Parameters
prefabFilenameprefab asset filename
posposition the spawned object must have.
anglesorientation (yaw,pitch,roll triple) the spawned object must have.
void StopAnimation ( int  channel)

This function stops an animation channel, i.e. it stops all the animations of the channel.

It also rewinds all channel animations and sets all channel animation weights to 0.0.

Parameters
channelanimation channel ID to stop.
See also
PlayAnimation, PauseAnimation
void StopMusic ( int  channel)

This function stops a music playing on a given channel.

Parameters
channelthe music channel. From 0 to 3.
See also
PlayMusic, StopSound
void StopSound ( )

This function stops a sound playing on this object source.

See also
PlayMusic, PlaySound
void StopSoundGlobal ( )

This function stops the global sound source.

See also
PlayMusic, PlaySound, PlaySoundGlobal
string String ( float  f)

This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string.

Warning
NOTE that there are 5 version of this function, one for every input type.
Parameters
finput float
string String ( bool  b)

This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string.

Warning
NOTE that there are 5 version of this function, one for every input type.
Parameters
binput boolean
string String ( int  i)

This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string.

Warning
NOTE that there are 5 version of this function, one for every input type.
Parameters
iinput integer
string String ( vec3  v3)

This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string.

Warning
NOTE that there are 5 version of this function, one for every input type.
Parameters
v3input 3d vector
string String ( vec4  v4)

This function convert an integer, a float, a boolean, a 3d vector or a 4d vector value into a string.

Warning
NOTE that there are 5 version of this function, one for every input type.
Parameters
v4input 4d vector
vec3 String2Vec3 ( string  s)

This function convert a string into a 3d vector.

Note
The format of the input string must be the following: "x,y,z" where x,y,z are numbers.
Parameters
sinput string
1 /* convert a string into a vector of coordinates: x=0.0, y=1.0, z=0.0 */
2 var vec3 v;
3 var string s;
4 s="0.0,1.0,0.0";
5 v=string2vec3(s);
vec4 String2Vec4 ( string  s)

This function convert a string into a 4d vector.

Note
The format of the input string must be the following: "x,y,z,w" where x,y,z,w are numbers.
Parameters
sinput string
1 /* convert a string into a vector of coordinates: x=0.0, y=1.0, z=10.0, w=5.0 */
2 var vec4 v;
3 var string s;
4 s="0.0,1.0,10.0,5.0";
5 v=string2vec4(s);
vec3 Vec3 ( float  x,
float  y,
float  z 
)

This function returns a 3d vector given 3 float numbers as input. It is useful to build a vec3 from 3 float.

Parameters
xx coordinate
yy coordinate
zz coordinate
vec4 Vec4 ( float  x,
float  y,
float  z,
float  w 
)

This function returns a 4d vector given 4 float numbers as input. It is useful to build a vec4 from 4 float.

Parameters
xx coordinate
yy coordinate
zz coordinate
ww coordinate
vec3 VectorInterpolate ( vec3  s1,
vec3  s2,
float  t 
)

This function returns the result of the linear interpolation between two input 3d Vectors, given the parameter t.

Parameters
s1first vector
s2second vector
tInterpolation parameter. It must be between 0.0 and 1.0.
See also
ScalarInterpolate, DotProduct, CrossProduct, VectorLen, VectorRotate, VectorToAngles
float VectorLen ( vec3  v)

This function returns the Length of a 3d vector.

Parameters
vInput vector
See also
VectorInterpolate, DotProduct, CrossProduct, VectorRotate, VectorToAngles
vec3 VectorRotate ( vec3  v,
float  angle,
vec3  axis 
)

This function rotates a 3d vector(also 3d point) given an angle of rotation and an axis of rotation. It is equal to multiply a 3d point with a rotation matrix.

Parameters
v3d point to rotate
angleangle of rotation
axisaxis of rotation
See also
VectorInterpolate, DotProduct, CrossProduct, VectorToAngles, VectorLen
vec3 VectorToAngles ( vec3  v)

This function returns the orientation of a given 3d vector expressed as the float triple yaw,pitch,roll where:

  • yaw is the angle around Y axis
  • pitch is the angle around X axis
  • roll is the angle around Z axis
Note
The triple is of type vec3.
Parameters
vthe input 3d vector
See also
VectorInterpolate, DotProduct, CrossProduct, VectorToAngles, VectorRotate
vec3 WorldToScreen ( vec3  p)

This function transforms a point from world coordinates space to screen coordinates space.
It is the inverse operation of ScreenToWorld function. This function is useful if you want to put a widget (for example a text label) near the projection on screen of a 3d object.

Note
The result has only 2 of the 3 corrdinates useful (the screen is a 2d plane).
Parameters
pthe input point
1 /* NOTE: This is a Widget script */ /* Get Object Pippo World Pos */
2 var vec3 pos;
3 pos=GetObjectWorldPos("pippo");
4 
5 /* Compute screen pos of pippo world pos */
6 var vec3 screenPos;
7 screenPos=WorldToScreen(pos);
8 
9 /* Set widget pos */
10 SetParam("pos",screenPos);
See also
ScreenToWorld