Function reference for v1.5.0

Get this HTML file.
Asset.Get( assetPath, assetType, errorIfAssetNotFound ) Alias of CraftStudio.FindAsset( assetPath[, assetType] ).
Asset.GetId( asset ) Returns the asset's internal unique identifier.
Asset.GetName( asset ) Returns the name of the provided asset.
Asset.GetPath( asset ) Returns the path of the provided asset.
Camera.GetBaseDistance( camera ) Returns the perspective camera's base distance.
Camera.GetFOV( camera ) Returns the FOV of the provided perspective camera (rounded to the second digit after the coma).
Camera.GetPixelsToUnits( camera ) Returns the pixels to scene units factor.
Camera.GetUnitsToPixels( camera ) Returns the scene units to pixels factor.
Camera.IsPositionInFrustum( camera, position ) Tell whether the provided position is inside the camera's frustum.
Camera.Project( camera, position ) Projects a 3D space position to a 2D screen position.
Camera.Set( camera, params ) Apply the content of the params argument to the provided camera.
Camera.SetProjectionMode( camera, projectionMode ) Sets the camera projection mode.
Camera.WorldToScreenPoint( camera, position ) Translate a position in the scene to an on-screen position.
Color.GetHSV( color ) Return the Hue, Saturation and Value of the provided color.
Color.GetHex( color ) Return the color's hexadecimal representation.
Color.GetName( color ) Return the name of the color, provided it can be found in the `Color.colorsByName` object.
Color.GetRandom( pattern ) Returns a random color, optional of the provided pattern.
Color.HexToRGB( hex ) Convert an hexadecimal color into its RGB components.
Color.New( r, g, b ) Create a new color object.
Color.RGBToHex( r, g, b ) Return the hexadecimal representation of the provided color or r, g, b components.
Color.SetHex( color, hex ) Set the color from an hexadecimal representation.
Color.ToArray( color ) Convert the provided color object to an array.
Color.ToRGB( color ) Convert the provided color object to a table with "r", "g", "b" keys.
Color.ToString( color ) Returns a string representation of the color's components, each component being separated y a space.
Color.ToVector3( color ) Convert the provided color object to a Vector3.
Color.__add( a, b ) Allow to add two Color objects by using the + operator.
Color.__div( a, b ) Allow to divide two Color objects or a Color object and a number by using the / operator.
Color.__eq( a, b ) Allow to check for the equality between two Color objects using the == comparison operator.
Color.__mul( a, b ) Allow to multiply two Color object or a Color object and a number by using the * operator.
Color.__sub( a, b ) Allow to subtract two Color objects by using the - operator.
Component.Destroy( component ) Destroy the provided component, removing it from the game object.
Component.GetId( component ) Returns the component's internal unique identifier.
Component.Set( component, params ) Apply the content of the params argument to the provided component.
CraftStudio.Destroy( object ) Removes the specified game object (and all of its descendants) or the specified component from its game object.
CraftStudio.Input.GetMouseDelta( ) Return the mouse delta (the variation of position) since the last frame.
CraftStudio.Input.GetMousePosition( ) Return the mouse position on screen coordinates {x, y}
CraftStudio.Input.ToggleMouseLock( ) Toggle the locked state of the mouse, which can be accessed via the CraftStudio.Input.isMouseLocked property.
CraftStudio.LoadScene( sceneNameOrAsset ) Schedules loading the specified scene after the current tick (1/60th of a second) has completed.
CraftStudio.Screen.GetSize( ) Return the size of the screen, in pixels.
CraftStudio.Screen.SetSize( x, y ) Sets the size of the screen, in pixels.
CraftStudio.Storage.Load( identifier, defaultValue, callback ) Load data stored locally on the computer under the provided identifier.
CraftStudio.Storage.Save( identifier, data, callback ) Store locally on the computer the provided data under the provided identifier.
Daneel.Debug.CheckArgType( argument, argumentName, expectedArgumentTypes, p_errorHead ) Check the provided argument's type against the provided type(s) and display error if they don't match.
Daneel.Debug.CheckArgValue( argument, argumentName, expectedArgumentValues, p_errorHead, defaultValue ) Check if the provided argument's value is in the provided expected value(s).
Daneel.Debug.CheckOptionalArgType( argument, argumentName, expectedArgumentTypes, p_errorHead, defaultValue ) If the provided argument is not nil, check the provided argument's type against the provided type(s) and display error if they don't match.
Daneel.Debug.Disable( info ) Disable the debug from this point onward.
Daneel.Debug.GetNameFromValue( value ) Returns the name as a string of the global variable (including nested tables) whose value is provided.
Daneel.Debug.RegisterFunction( name, argsData ) Overload a function to call debug functions before and after it is itself called.
Daneel.Debug.RegisterObject( object ) Register all functions of an object to be included in the stacktrace.
Daneel.Debug.RegisterScript( script ) Register all functions of a scripted behavior to be included in the stacktrace.
Daneel.Debug.StackTrace.BeginFunction( functionName, ... ) Register a function call in the stack trace.
Daneel.Debug.StackTrace.EndFunction( ) Closes a successful function call, removing it from the stacktrace.
Daneel.Debug.StackTrace.Print( ) Prints the StackTrace.
Daneel.Debug.ToRawString( data ) Bypass the __tostring() function that may exists on the data's metatable.
Daneel.Debug.Try( _function ) Allow to test out a piece of code without killing the script if the code throws an error.
Daneel.DefaultConfig( ) Config, loading
Daneel.Event.AddEventListener( object, eventName, listener ) Add a listener function for the specified local event on this object.
Daneel.Event.Fire( object, eventName, ... ) Fire the provided event at the provided object or the one that listen to it, transmitting along all subsequent arguments if some exists.
Daneel.Event.Listen( eventName, functionOrObject, isPersistent ) Make the provided function or object listen to the provided event(s).
Daneel.Event.RemoveEventListener( object, eventName, listener ) Remove the specified listener for the specified local event on this object
Daneel.Event.StopListen( eventName, functionOrObject ) Make the provided function or object to stop listen to the provided event(s).
Daneel.Utilities.AllowDynamicGettersAndSetters( Object, ancestors ) Allow to call getters and setters as if they were variable on the instance of the provided object.
Daneel.Utilities.ButtonExists( buttonName ) Tell whether the provided button name exists amongst the Game Controls, or not.
Daneel.Utilities.GetId( object ) Returns an integer greater than 0 and incremented by 1 from the last time the function was called.
Daneel.Utilities.ReplaceInString( string, replacements ) Replace placeholders in the provided string with their corresponding provided replacements.
Draw.CircleRenderer.Draw( circle ) Draw the circle renderer.
Draw.CircleRenderer.GetModel( circle ) Returns the circle renderer's segment's model.
Draw.CircleRenderer.GetOpacity( circle ) Returns the circle renderer's segments' opacity.
Draw.CircleRenderer.GetRadius( circle ) Returns the circle renderer's radius.
Draw.CircleRenderer.GetSegmentCount( circle ) Returns the circle renderer's number of segments.
Draw.CircleRenderer.GetWidth( circle ) Returns the circle renderer's segment's width (and height).
Draw.CircleRenderer.New( gameObject, params ) Creates a new circle renderer component.
Draw.CircleRenderer.Set( circle, params ) Apply the content of the params argument to the provided circle renderer.
Draw.CircleRenderer.SetModel( circle, model ) Sets the circle renderer segment's model.
Draw.CircleRenderer.SetOpacity( circle, opacity ) Sets the circle renderer segments' opacity.
Draw.CircleRenderer.SetRadius( circle, radius, draw ) Sets the circle renderer's radius.
Draw.CircleRenderer.SetSegmentCount( circle, count, draw ) Sets the circle renderer's segment count.
Draw.CircleRenderer.SetWidth( circle, width ) Sets the circle renderer segment's width.
Draw.LineRenderer.Draw( line ) Draw the line renderer.
Draw.LineRenderer.GetDirection( line ) Returns the line renderer's direction.
Draw.LineRenderer.GetEndPosition( line ) Returns the line renderer's end position.
Draw.LineRenderer.GetLength( line ) Returns the line renderer's length.
Draw.LineRenderer.GetWidth( line ) Returns the line renderer's width.
Draw.LineRenderer.New( gameObject, params ) Creates a new LineRenderer component.
Draw.LineRenderer.Set( line, params ) Apply the content of the params argument to the provided line renderer.
Draw.LineRenderer.SetDirection( line, direction, useDirectionAsLength, draw ) Set the line renderer's direction.
Draw.LineRenderer.SetEndPosition( line, endPosition, draw ) Set the line renderer's end position.
Draw.LineRenderer.SetLength( line, length, draw ) Set the line renderer's length.
Draw.LineRenderer.SetWidth( line, width, draw ) Set the line renderer's width (and height).
GUI.Hud.CreateOriginGO( gameObject ) Creates a "Hud Origin" child used for positioning hud components.
GUI.Hud.GetLayer( hud ) Get the gameObject's layer.
GUI.Hud.GetLocalLayer( hud ) Get the gameObject's local layer.
GUI.Hud.GetLocalPosition( hud ) Get the local position (relative to its parent) of the gameObject on screen.
GUI.Hud.GetPosition( hud ) Get the position of the provided hud on the screen.
GUI.Hud.New( gameObject, params ) Creates a new Hud component instance.
GUI.Hud.SetLayer( hud, layer ) Set the gameObject's layer.
GUI.Hud.SetLocalLayer( hud, layer ) Set the huds's local layer.
GUI.Hud.SetLocalPosition( hud, position ) Sets the local position (relative to its parent) of the gameObject on screen .
GUI.Hud.SetPosition( hud, position ) Sets the position of the gameObject on screen.
GUI.Input.Focus( input, focus ) Set the focused state of the input.
GUI.Input.New( gameObject, params ) Creates a new GUI.Input.
GUI.Input.Update( input, text, replaceText ) Update the text of the input.
GUI.Input.UpdateCursor( input ) Update the position and opacity of the input's cursor.
GUI.ProgressBar.GetHeight( progressBar ) Get the height of the progress bar (the local scale's y component).
GUI.ProgressBar.GetValue( progressBar, getAsPercentage ) Get the current value of the progress bar.
GUI.ProgressBar.New( gameObject, params ) Creates a new GUI.ProgressBar.
GUI.ProgressBar.Set( progressBar, params ) Apply the content of the params argument to the provided progressBar.
GUI.ProgressBar.SetHeight( progressBar, height ) Set the height of the progress bar.
GUI.ProgressBar.SetValue( progressBar, value ) Set the value of the progress bar, adjusting its length.
GUI.ProgressBar.UpdateValue( progressBar, value, fireEvent ) Set the value of the progress bar, adjusting its length.
GUI.Slider.GetValue( slider, getAsPercentage ) Get the current slider's value.
GUI.Slider.New( gameObject, params ) Creates a new GUI.Slider.
GUI.Slider.Set( slider, params ) Apply the content of the params argument to the provided slider.
GUI.Slider.SetValue( slider, value ) Set the value of the slider, adjusting its position.
GUI.TextArea.AddLine( textArea, line, prepend ) Add a line to the text area's text.
GUI.TextArea.GetAlignment( textArea ) Get the component's horizontal alignment.
GUI.TextArea.GetAreaWidth( textArea ) Get the component's area width.
GUI.TextArea.GetFont( textArea ) Get the component's font used to render the text.
GUI.TextArea.GetLineHeight( textArea ) Get the component's line height.
GUI.TextArea.GetNewLine( textArea ) Get the component's newLine string.
GUI.TextArea.GetOpacity( textArea ) Get the component's opacity.
GUI.TextArea.GetText( textArea ) Get the component's text.
GUI.TextArea.GetVerticalAlignment( textArea ) Get the component's vertical alignment property.
GUI.TextArea.GetWordWrap( textArea ) Get the component's wordWrap property.
GUI.TextArea.New( gameObject, params ) Creates a new TextArea component.
GUI.TextArea.Set( textArea, params ) Apply the content of the params argument to the provided textArea.
GUI.TextArea.SetAlignment( textArea, alignment ) Set the component's alignment.
GUI.TextArea.SetAreaWidth( textArea, areaWidth ) Set the component's area width (maximum line length).
GUI.TextArea.SetFont( textArea, font ) Set the component's font used to renderer the text.
GUI.TextArea.SetLineHeight( textArea, lineHeight ) Set the component's line height.
GUI.TextArea.SetNewLine( textArea, newLine ) Set the component's newLine string used by SetText() to split the input text in several lines.
GUI.TextArea.SetOpacity( textArea, opacity ) Set the component's opacity.
GUI.TextArea.SetText( textArea, text ) Set the component's text.
GUI.TextArea.SetVerticalAlignment( textArea, verticalAlignment ) Set the component's vertical alignment.
GUI.TextArea.SetWordWrap( textArea, wordWrap ) Set the component's wordWrap property.
GUI.ToPixel( value, screenSide, camera ) Convert the provided value (a length) in a number expressed in screen pixel.
GUI.ToSceneUnit( value, camera ) Convert the provided value (a length) in a number expressed in scene unit.
GUI.Toggle.Check( toggle, state, forceUpdate ) Check or uncheck the provided toggle and fire the OnUpdate event.
GUI.Toggle.GetGroup( toggle ) Get the toggle's group.
GUI.Toggle.GetText( toggle ) Get the provided toggle's text.
GUI.Toggle.New( gameObject, params ) Creates a new Toggle component.
GUI.Toggle.Set( toggle, params ) Apply the content of the params argument to the provided toggle.
GUI.Toggle.SetGroup( toggle, group ) Set the toggle's group.
GUI.Toggle.SetText( toggle, text ) Set the provided toggle's text.
GameObject.AddComponent( gameObject, componentType, params ) Add a component to the game object and optionally initialize it.
GameObject.AddEventListener( gameObject, eventName, listener ) Add a listener function for the specified local event on this game object.
GameObject.AddTag( gameObject, tag ) Add the provided tag(s) to the provided game object.
GameObject.Animate( gameObject, property, endValue, duration, onCompleteCallback, params ) Creates an animation (a tweener) with the provided parameters.
GameObject.Destroy( gameObject ) Destroy the game object at the end of this frame.
GameObject.Display( gameObject, value, forceUseLocalPosition ) Display or hide the game object.
GameObject.FireEvent( gameObject, eventName, ... ) Fire an event at the provided game object.
GameObject.Get( name, errorIfGameObjectNotFound ) Alias of CraftStudio.FindGameObject(name).
GameObject.GetChild( gameObject, name, recursive ) Alias of GameObject.FindChild().
GameObject.GetChildren( gameObject, recursive, includeSelf ) Get all descendants of the game object.
GameObject.GetComponent( gameObject, componentType ) Get the first component of the provided type attached to the game object.
GameObject.GetId( gameObject ) Returns the game object's internal unique identifier.
GameObject.GetInAncestors( gameObject, searchFunction ) Search the ancestors of the provided game object.
GameObject.GetScriptedBehavior( gameObject, scriptNameOrAsset ) Get the provided scripted behavior instance attached to the game object.
GameObject.GetTags( gameObject ) Returns the tag(s) of the provided game object.
GameObject.GetWithTag( tag ) Returns the game object(s) that have all the provided tag(s).
GameObject.HasTag( gameObject, tag, atLeastOneTag ) Tell whether the provided game object has all (or at least one of) the provided tag(s).
GameObject.Instantiate( name, sceneNameOrAsset, params ) Create a new game object with the content of the provided scene and optionally initialize it.
GameObject.New( name, params ) Create a new game object and optionally initialize it.
GameObject.RemoveEventListener( gameObject, eventName, listener ) Remove the specified listener for the specified local event on this game object
GameObject.RemoveTag( gameObject, tag ) Remove the provided tag(s) from the provided game object.
GameObject.SendMessage( gameObject, functionName, data ) Tries to call a method with the provided name on all the scriptedBehaviors attached to the game object.
GameObject.Set( gameObject, params ) Apply the content of the params argument to the provided game object.
GameObject.SetParent( gameObject, parentNameOrInstance, keepLocalTransform ) Set the game object's parent.
Lang.Get( key, replacements ) Get the localized line identified by the provided key.
Lang.RegisterForUpdate( gameObject, key, replacements ) Register a game object to update its text renderer whenever the language will be updated by Lang.Update().
Lang.Update( language ) Update the current language and the text of all game objects that have registered via Lang.RegisterForUpdate().
Map.GetBlockIDAt( map, x, y, z ) Returns A block ID between 0-254 if a block exists at the given location (all valid block IDs are in the range 0-254), otherwise f there is no block at the given location then it will return Map.EmptyBlockID (which has a value of 255).
Map.GetBlockOrientationAt( map, x, y, z ) Returns The block orientation of the block at the specified location, otherwise if there is no block at the given location it will return Map.BlockOrientation.North.
Map.SetBlockAt( map, x, y, z, id, orientation ) Sets a block's ID and block orientation at the given location on the map.
MapRenderer.LoadNewMap( mapRenderer, callback ) Dynamically loads a new version of the provided map renderer's map and sets it as the map renderer new map.
MapRenderer.Set( mapRenderer, params ) Apply the content of the params argument to the provided map renderer.
MapRenderer.SetMap( mapRenderer, mapNameOrAsset, replaceTileSet ) Attach the provided map to the provided map renderer.
MapRenderer.SetTileSet( mapRenderer, tileSetNameOrAsset ) Set the specified tileSet for the mapRenderer's map.
ModelRenderer.GetColor( modelRenderer ) Get the color of the provided model renderer.
ModelRenderer.Set( modelRenderer, params ) Apply the content of the params argument to the provided model renderer.
ModelRenderer.SetAnimation( modelRenderer, animationNameOrAsset ) Set the specified animation for the modelRenderer's current model.
ModelRenderer.SetColor( modelRenderer, color ) Set the color of the provided model renderer.
ModelRenderer.SetModel( modelRenderer, modelNameOrAsset ) Attach the provided model to the provided modelRenderer.
MouseInput.GetTags( mouseInput ) Return the tag(s) of the game objects the component works with.
MouseInput.New( gameObject, params ) Create a new MouseInput component.
MouseInput.SetTags( mouseInput, tags ) Set tag(s) of the game objects the component works with.
MouseInput.Update( mouseInput ) Update the specified MouseInput component or update all components when no argument is passed.
Ray.Cast( ray, gameObjects, sortByDistance ) Check the collision of the ray against the provided set of game objects.
Ray.IntersectsGameObject( ray, gameObjectNameOrInstance ) Check if the ray intersects the specified game object.
RaycastHit.New( params ) Create a new RaycastHit
Scene.Append( sceneNameOrAsset, parentNameOrInstance ) Alias of CraftStudio.AppendScene().
Scene.Load( sceneNameOrAsset ) Alias of CraftStudio.LoadScene().
Sound.Play( soundAssetOrPath, volume, pitch, pan ) Play the specified sound.
TextRenderer.GetColor( textRenderer ) Get the color of the provided text renderer.
TextRenderer.SetAlignment( textRenderer, alignment ) Set the text's alignment.
TextRenderer.SetColor( textRenderer, color ) Set the color of the provided text renderer.
TextRenderer.SetFont( textRenderer, fontNameOrAsset ) Set the provided font to the provided text renderer.
TextRenderer.SetTextWidth( textRenderer, width ) Update the game object's scale to make the text appear the provided width.
Transform.GetScale( transform ) Get the transform's global scale.
Transform.LocalToWorld( transform, position ) Transform a position local to this transform to a global position.
Transform.SetLocalScale( transform, scale ) Set the transform's local scale.
Transform.SetScale( transform, scale ) Set the transform's global scale.
Transform.WorldToLocal( transform, position ) Transform a global position to a position local to this transform.
Trigger.GetGameObjectsInRange( trigger ) Get the gameObjects that are within range of that trigger.
Trigger.GetRange( trigger ) Get the range of the trigger.
Trigger.GetTags( trigger ) Return the tag(s) of the game objects the component works with.
Trigger.GetUpdateInterval( trigger ) Get the interval (in frames) at which the trigger is automatically updated.
Trigger.IsGameObjectInRange( trigger, gameObject, triggerPosition ) Tell whether the provided game object is in range of the trigger.
Trigger.New( gameObject, params ) Create a new Trigger component.
Trigger.SetRange( trigger, range ) Set the range of the trigger.
Trigger.SetTags( trigger, tags ) Set tag(s) of the game objects the component works with.
Trigger.SetUpdateInterval( trigger, updateInterval ) Set the interval (in frames) at which the trigger is automatically updated.
Tween.Timer.New( duration, callback, isInfiniteLoop, params ) Creates a new tweener via one of the two allowed constructors :
Timer.New(duration, OnCompleteCallback[, params])
Timer.New(duration, OnLoopCompleteCallback, true[, params])
Tween.Tweener.Complete( tweener ) Complete the tweener fire the OnComple event.
Tween.Tweener.Destroy( tweener ) Destroy the tweener.
Tween.Tweener.New( target, property, endValue, duration, onCompleteCallback, params ) Creates a new tweener via one of the three allowed constructors :
Tweener.New(target, property, endValue, duration[, params])
Tweener.New(startValue, endValue, duration[, params])
Tweener.New(params)
Tween.Tweener.Pause( tweener ) Pause the tweener and fire the OnPause event.
Tween.Tweener.Play( tweener ) Unpause the tweener and fire the OnPlay event.
Tween.Tweener.Restart( tweener ) Completely restart the tweener.
Tween.Tweener.Update( tweener, deltaDuration ) Update the tweener's value based on the tweener's elapsed property.
Vector2.GetLength( vector ) Return the length of the vector.
Vector2.GetSqrLength( vector ) Return the squared length of the vector.
Vector2.New( x, y ) Creates a new Vector2 intance.
Vector2.Normalize( vector ) Normalize the provided vector in place (makes its length equal to 1).
Vector2.Normalized( vector ) Return a copy of the provided vector, normalized.
Vector2.ToPixel( vector, camera ) Make sure that the components of the provided Vector2 are numbers and in pixel, instead of strings or in percentage or relative to the screensize.
Vector2.ToString( vector ) Returns a string representation of the vector's component's values.
Vector2.__add( a, b ) Allow to add two Vector2 by using the + operator.
Vector2.__div( a, b ) Allow to divide two Vector2 or a Vector2 and a number by using the / operator.
Vector2.__eq( a, b ) Allow to check for the equality between two Vector2 using the == comparison operator.
Vector2.__mul( a, b ) Allow to multiply two Vector2 or a Vector2 and a number by using the * operator.
Vector2.__pow( vector, exp ) Allow to raise a Vector2 to a power using the ^ operator.
Vector2.__sub( a, b ) Allow to substract two Vector2 by using the - operator.
Vector2.__unm( vector ) Allow to inverse a vector2 using the - operator.
Vector3.GetLength( vector ) Returns the length of the provided vector
Vector3.GetSqrLength( vector ) Return the squared length of the vector.
Vector3.New( x, y, z, z2 ) Returns a new Vector3.
Vector3.ToString( vector ) Returns a string representation of the vector's component's values.
error( message, doNotPrintStacktrace ) Print the stackTrace unless told otherwise then the provided error in the console.
math.clamp( value, min, max ) Return the value clamped between min and max.
math.isinteger( number ) Tell whether the provided number is an integer.
math.lerp( a, b, factor, easing ) Returns the value resulting of the linear interpolation between value a and b by the specified factor.
math.round( value, decimal ) Round the value to the closest integer or decimal.
math.truncate( value, decimal ) Trucate the value to the provided decimal.
math.warpangle( angle ) Wrap the provided angle between -180 and 180.
string.endswith( s, chunk ) Tell whether the provided string ends by the provided chunk or not.
string.fixcase( s, set ) Make sure that the case of the provided string is correct by checking it against the values in the provided set.
string.lcfirst( s ) Turn the first letter of the string lowercase.
string.reverse( s ) Reverse the order of the characters in a string ("abcd" becomes "dcba").
string.split( s, delimiter, delimiterIsPattern ) Some Lua functions are overridden here with some Daneel-specific stuffs
string.split( s, delimiter, delimiterIsPattern ) Some Lua functions are overridden here with some Daneel-specific stuffs
string.startswith( s, chunk ) Tell whether the provided string begins by the provided chunk or not.
string.tocolor( sColor ) Convert a string representation of a color component's values to a Color object.
string.totable( s ) Turn a string into a table, one character per index.
string.tovector( sVector ) Convert a string representation of a vector component's values to a Vector3 or a Vector2.
string.trim( s ) Removes the white spaces at the beginning and the end of the provided string.
string.trimend( s ) Removes the white spaces at the end of the provided string.
string.trimstart( s ) Removes the white spaces at the beginning of the provided string.
string.ucfirst( s ) Turn the first letter of the string uppercase.
table.combine( keys, values ) Create an associative table with the provided keys and values tables.
table.containsvalue( t, value, ignoreCase ) Tell whether the provided value is found within the provided table.
table.copy( t, recursive ) Return a copy of the provided table.
table.getkey( t, value ) Get the key associated with the first occurrence of the provided value.
table.getkeys( t ) Return all the keys of the provided table.
table.getlength( t, keyType ) Returns the length of a table, which is the numbers of keys of the provided type (or of any type), for which the value is not nil.
table.getvalue( t, keys ) Safely search several levels down inside nested tables.
table.getvalues( t ) Return all the values of the provided table.
table.havesamecontent( table1, table2 ) Compare table1 and table2.
table.insertonce( t, index, value ) Insert the provided value at the end of the provided table (or at the provided index) but only if the value is not already found in the table.
table.isarray( t, strict ) Tell whether he provided table is an array (has only integer keys).
table.merge( ..., recursive ) Merge two or more tables into one new table.
table.mergein( ..., recursive ) Merge two or more tables in place, into the first provided table.
table.print( t ) Print all key/value pairs within the provided table.
table.printr( t, maxLevel, reprint, currentLevel ) Recursively print all key/value pairs within the provided table.
table.reindex( t ) Turn the provided table (with only integer keys) in a proper sequence (with consecutive integer key beginning at 1).
table.removevalue( t, value, maxRemoveCount ) Remove the provided value from the provided table.
table.reverse( t ) Reverse the order of the provided table's values.
table.setvalue( t, keys, value ) Safely set a value several levels down inside nested tables.
table.shift( t, returnKey ) Remove and returns the first value found in the table.
table.sortby( t, property, orderBy ) Sort a list of table using one of the tables property as criteria.
tonumber2( data ) A more flexible version of tonumber().

Asset.Get( assetPath, assetType, errorIfAssetNotFound )

Alias of CraftStudio.FindAsset( assetPath[, assetType] ). Get the asset of the specified name and type. The first argument may be an asset object, so that you can check if a variable was an asset object or name (and get the corresponding object).

Parameters:
  • assetPath (string or any asset type) The fully-qualified asset name or asset object.
  • assetType [optional] (string) The asset type as a case-insensitive string.
  • errorIfAssetNotFound [default=false] Throw an error if the asset was not found (instead of returning nil).
Return value:
    (One of the asset type) The asset, or nil if none is found.

Asset.GetId( asset )

Returns the asset's internal unique identifier.

Parameters:
  • asset (any asset type) The asset.
Return value:
    (number) The id.

Asset.GetName( asset )

Returns the name of the provided asset.

Parameters:
  • asset (any asset type) The asset instance.
Return value:
    (string) The name (the last segment of the fully-qualified path).

Asset.GetPath( asset )

Returns the path of the provided asset. Alias of Map.GetPathInPackage().

Parameters:
  • asset (any asset type) The asset instance.
Return value:
    (string) The fully-qualified asset path.

Camera.GetBaseDistance( camera )

Returns the perspective camera's base distance. The base distance is the distance from the camera at which 1 scene unit has the size of the smallest side of the screen. Only works for perspective cameras. Returns nil for orthographic cameras.

Parameters:
  • camera (Camera) The camera component.
Return value:
    (number) The camera's base distance.

Camera.GetFOV( camera )

Returns the FOV of the provided perspective camera (rounded to the second digit after the coma).

Parameters:
  • camera (Camera) The Camera component.
Return value:
    (number) The FOV

Camera.GetPixelsToUnits( camera )

Returns the pixels to scene units factor.

Parameters:
  • camera
Return value:
    (number) The camera's PixelsToUnits ratio.

Camera.GetUnitsToPixels( camera )

Returns the scene units to pixels factor.

Parameters:
  • camera
Return value:
    (number) The camera's UnitsToPixels ratio.

Camera.IsPositionInFrustum( camera, position )

Tell whether the provided position is inside the camera's frustum.

Parameters:
  • camera (Camera) The camera component.
  • position (Vector3) The position.
Return value:
    (boolean) True if the position is inside the camera's frustum.

Camera.Project( camera, position )

Projects a 3D space position to a 2D screen position.

Parameters:
  • camera (Camera) The camera component.
  • position (Vector3) The position.
Return value:
    (Vector2) The projected screen coordinates.

Camera.Set( camera, params )

Apply the content of the params argument to the provided camera.

Parameters:
  • camera (Camera) The camera.
  • params (table) A table of parameters to set the component with.

Camera.SetProjectionMode( camera, projectionMode )

Sets the camera projection mode.

Parameters:
  • camera (Camera) The camera.
  • projectionMode (string or Camera.ProjectionMode) The projection mode. Possible values are "perspective", "orthographic" (as a case-insensitive string), Camera.ProjectionMode.Perspective or Camera.ProjectionMode.Orthographic.

Camera.WorldToScreenPoint( camera, position )

Translate a position in the scene to an on-screen position. The Z component of the returned Vector3 represent the distance from the camera to the position's plane. It's inferior to zero when the position is in front of the camera. Note that when the object is behind the camera, the returned screen coordinates are not the same as the ones given by Camera.Project().

Parameters:
  • camera (Camera) The camera component.
  • position (Vector3) The position.
Return value:
    (Vector3) A Vector3 where X and Y are the screen position and Z the distance to the position's plane.

Color.GetHSV( color )

Return the Hue, Saturation and Value of the provided color.

Parameters:
  • color (Color) The color object.
Return values:
  1. (number) The hue of the color (between 0 and 1).
  2. (number) The saturation of the color (between 0 and 1).
  3. (number) The value of the color (between 0 and 1).

Color.GetHex( color )

Return the color's hexadecimal representation. Only return the 6 characters of the component's values, so you may want to prefix it with "#" or "0x" yourself.

Parameters:
  • color (Color) The color object.
Return value:
    (string) The color's hexadecimal representation.

Color.GetName( color )

Return the name of the color, provided it can be found in the `Color.colorsByName` object.

Parameters:
  • color (Color) The color object.
Return value:
    (string) The color's name or nil.

Color.GetRandom( pattern )

Returns a random color, optional of the provided pattern.

Parameters:
  • pattern (number or Color.Patterns) [optional] The color pattern.
Return value:
    (Color) The color.

Color.HexToRGB( hex )

Convert an hexadecimal color into its RGB components.

Parameters:
  • hex (string) The hexadecimal color. May be prefixed by "#", "0x", "0X" or nothing.
Return values:
  1. (number) The color's red component.
  2. (number) The color's green component.
  3. (number) The color's blue component.

Color.New( r, g, b )

Create a new color object.

Parameters:
  • r (number, Color, table, Vector3 or string) The color's red component or a table with r,g,b / x,y,z / 1,2,3 components, or a color name or an hexadecimal color.
  • g (number) [optional] The color's green component.
  • b (number) [optional] The color's blue component.
Return value:
    (Color) The color object.

Color.RGBToHex( r, g, b )

Return the hexadecimal representation of the provided color or r, g, b components. Only return the 6 characters of the component's values, so you may want to prefix it with "#" or "0x" yourself.

Parameters:
  • r (number, Color, table, Vector3 or string) The color's red component or a table with r,g,b / x,y,z / 1,2,3 components, or a color name or an hexadecimal color.
  • g (number) [optional] The color's green component.
  • b (number) [optional] The color's blue component.

Color.SetHex( color, hex )

Set the color from an hexadecimal representation.

Parameters:
  • color (Color) The color object.
  • hex (string) The color's hexadecimal representation.

Color.ToArray( color )

Convert the provided color object to an array. Allow to loop on the color's components in order.

Parameters:
  • color (Color) The color object.
Return value:
    (table) The color as array.

Color.ToRGB( color )

Convert the provided color object to a table with "r", "g", "b" keys. Allow to loop on the color's components.

Parameters:
  • color (Color) The color object.
Return value:
    (table) The color as table with "r", "g", "b" keys.

Color.ToString( color )

Returns a string representation of the color's components, each component being separated y a space. ie: For a color { 10, 250, 128 }, the returned string would be "10 250 128". Such string can be converted back to a color object with string.tocolor()

Parameters:
  • color (Color) The color object.
Return value:
    (string) The string.

Color.ToVector3( color )

Convert the provided color object to a Vector3. This can be needed because the component's values of a Vector3 are not clamped between 0 and 255.

Parameters:
  • color (Color) The color object.
Return value:
    (Vector3) The color as a Vector3 with "x", "y", "z" keys.

Color.__add( a, b )

Allow to add two Color objects by using the + operator. Ie : color1 + color2

Parameters:
  • a (Color) The left member.
  • b (Color) The right member.
Return value:
    (Color) The new color object.

Color.__div( a, b )

Allow to divide two Color objects or a Color object and a number by using the / operator.

Parameters:
  • a (Color or number) The numerator.
  • b (Color or number) The denominator. Can't be equal to 0.
Return value:
    (Color) The new color object.

Color.__eq( a, b )

Allow to check for the equality between two Color objects using the == comparison operator.

Parameters:
  • a (Color) The left member.
  • b (Color) The right member.
Return value:
    (boolean) True if the same components of the two colors are equal (a.r=b.r, a.g=b.g and a.b=b.b)

Color.__mul( a, b )

Allow to multiply two Color object or a Color object and a number by using the * operator.

Parameters:
  • a (Color or number) The left member.
  • b (Color or number) The right member.
Return value:
    (Color) The new color object.

Color.__sub( a, b )

Allow to subtract two Color objects by using the - operator. Ie : color1 - color2

Parameters:
  • a (Color) The left member.
  • b (Color) The right member.
Return value:
    (Color) The new color object.

Component.Destroy( component )

Destroy the provided component, removing it from the game object. Note that the component is removed only at the end of the current frame.

Parameters:
  • component (any component type) The component.

Component.GetId( component )

Returns the component's internal unique identifier.

Parameters:
  • component (any component type) The component.
Return value:
    (number) The id.

Component.Set( component, params )

Apply the content of the params argument to the provided component.

Parameters:
  • component (any component type) The component.
  • params (table) A table of parameters to set the component with.

CraftStudio.Destroy( object )

Removes the specified game object (and all of its descendants) or the specified component from its game object. You can also optionally specify a dynamically loaded asset for unloading (See Map.LoadFromPackage ). Sets the 'isDestroyed' property to 'true' and fires the 'OnDestroy' event on the object.

Parameters:
  • object (GameObject, a component or a dynamically loaded asset) The game object, component or a dynamically loaded asset (like a map loaded with Map.LoadFromPackage).

CraftStudio.Input.GetMouseDelta( )

Return the mouse delta (the variation of position) since the last frame. Positive x is right, positive y is bottom.

Return value:
    (Vector2) The position's delta.

CraftStudio.Input.GetMousePosition( )

Return the mouse position on screen coordinates {x, y}

Return value:
    (Vector2) The on-screen mouse position.

CraftStudio.Input.ToggleMouseLock( )

Toggle the locked state of the mouse, which can be accessed via the CraftStudio.Input.isMouseLocked property.


CraftStudio.LoadScene( sceneNameOrAsset )

Schedules loading the specified scene after the current tick (1/60th of a second) has completed. When the new scene is loaded, all of the current scene's game objects will be removed. Calling this function doesn't immediately stops the calling function. As such, you might want to add a return statement afterwards.

Parameters:
  • sceneNameOrAsset (string or Scene) The scene name or asset.

CraftStudio.Screen.GetSize( )

Return the size of the screen, in pixels.

Return value:
    (Vector2) The screen's size.

CraftStudio.Screen.SetSize( x, y )

Sets the size of the screen, in pixels.

Parameters:
  • x (number or table) The width of the screen or a table containing the width and height as x and and y components.
  • y (number) [optional] The height of the screen (has no effect when the "x" argument is a table).

CraftStudio.Storage.Load( identifier, defaultValue, callback )

Load data stored locally on the computer under the provided identifier. The load operation may not be instantaneous.

Parameters:
  • identifier (string) The identifier of the data.
  • defaultValue (mixed) [optional] The value that is returned if no data (and no error) is found.
  • callback (function) The function called when the data is loaded. The the potential error (nil if no error) and data (of mixed type) are passed as first and second argument, respectively.

CraftStudio.Storage.Save( identifier, data, callback )

Store locally on the computer the provided data under the provided identifier.

Parameters:
  • identifier (string) The identifier of the data.
  • data (mixed) The data to store. May be nil.
  • callback (function) [optional] The function called when the save has completed. The potential error (as a string) is passed to the callback first and only argument (nil if no error).

Daneel.Debug.CheckArgType( argument, argumentName, expectedArgumentTypes, p_errorHead )

Check the provided argument's type against the provided type(s) and display error if they don't match.

Parameters:
  • argument (mixed) The argument to check.
  • argumentName (string) The argument name.
  • expectedArgumentTypes (string or table) The expected argument type(s).
  • p_errorHead [optional] (string) The beginning of the error message.
Return value:
    (mixed) The argument's type.

Daneel.Debug.CheckArgValue( argument, argumentName, expectedArgumentValues, p_errorHead, defaultValue )

Check if the provided argument's value is in the provided expected value(s). When that's not the case, return the value of the 'defaultValue' argument, or throws an error when it is nil. Arguments of type string are considered case-insensitive. The case will be corrected but no error will be thrown. When 'expectedArgumentValues' is of type table, it is always considered as a table of several expected values.

Parameters:
  • argument (mixed) The argument to check.
  • argumentName (string) The argument name.
  • expectedArgumentValues (mixed) The expected argument values(s).
  • p_errorHead [optional] (string) The beginning of the error message.
  • defaultValue [optional] (mixed) The optional default value.
Return value:
    (mixed) The argument's value (one of the expected argument values or default value)

Daneel.Debug.CheckOptionalArgType( argument, argumentName, expectedArgumentTypes, p_errorHead, defaultValue )

If the provided argument is not nil, check the provided argument's type against the provided type(s) and display error if they don't match.

Parameters:
  • argument (mixed) The argument to check.
  • argumentName (string) The argument name.
  • expectedArgumentTypes (string or table) The expected argument type(s).
  • p_errorHead [optional] (string) The beginning of the error message.
  • defaultValue [optional] (mixed) The default value to return if 'argument' is nil.
Return value:
    (mixed) The value of 'argument' if it's non-nil, or the value of 'defaultValue'.

Daneel.Debug.Disable( info )

Disable the debug from this point onward.

Parameters:
  • info [optional] (string) Some info about why or where you disabled the debug. Will be printed in the Runtime Report.

Daneel.Debug.GetNameFromValue( value )

Returns the name as a string of the global variable (including nested tables) whose value is provided. This only works if the value of the variable is a table or a function. When the variable is nested in one or several tables (like GUI.Hud), it must have been set in the 'objects' table in the config.

Parameters:
  • value (table or function) Any global variable, any object from CraftStudio or Daneel or objects whose name is set in 'userObjects' in the Daneel.Config.
Return value:
    (string) The name, or nil.

Daneel.Debug.RegisterFunction( name, argsData )

Overload a function to call debug functions before and after it is itself called. Do not call before Daneel is loaded as it won't run even if debug is enabled in the user config.

Parameters:
  • name (string) The function name
  • argsData (table) The parameters of the functions.

Daneel.Debug.RegisterObject( object )

Register all functions of an object to be included in the stacktrace. The following function name are always excluded from the stacktrace and debug : "Load", "DefaultConfig", "UserConfig", "Awake", "Start", "Update", "New", "inner", "GetId", "GetName" Plus function names that begins by "__" or "o".

Parameters:
  • object (table or string) The object, or object's name.

Daneel.Debug.RegisterScript( script )

Register all functions of a scripted behavior to be included in the stacktrace. Within a script, the 'Behavior' variable is the script asset.

Parameters:
  • script (Script) The script asset.

Daneel.Debug.StackTrace.BeginFunction( functionName, ... )

Register a function call in the stack trace.

Parameters:
  • functionName (string) The function name.
  • ... [optional] (mixed) Arguments received by the function.

Daneel.Debug.StackTrace.EndFunction( )

Closes a successful function call, removing it from the stacktrace.


Daneel.Debug.StackTrace.Print( )

Prints the StackTrace.


Daneel.Debug.ToRawString( data )

Bypass the __tostring() function that may exists on the data's metatable.

Parameters:
  • data (mixed) The data to be converted to string.
Return value:
    (string) The string.

Daneel.Debug.Try( _function )

Allow to test out a piece of code without killing the script if the code throws an error. If the code throw an error, it will be printed in the Runtime Report but it won't kill the script that calls Daneel.Debug.Try(). Does not protect against exceptions thrown by CraftStudio.

Parameters:
  • _function (function or userdata) The function containing the code to try out.
Return value:
    (boolean) True if the code runs without errors, false otherwise.

Daneel.DefaultConfig( )

Config, loading


Daneel.Event.AddEventListener( object, eventName, listener )

Add a listener function for the specified local event on this object.

Parameters:
  • object (table) The object.
  • eventName (string) The name of the event to listen to.
  • listener (function or userdata) The listener function.

Daneel.Event.Fire( object, eventName, ... )

Fire the provided event at the provided object or the one that listen to it, transmitting along all subsequent arguments if some exists.
Allowed set of arguments are :
(eventName[, ...])
(object, eventName[, ...])


Parameters:
  • object [optional] (table) The object to which fire the event at. If nil or abscent, will send the event to its listeners.
  • eventName (string) The event name.
  • ... [optional] Some arguments to pass along.

Daneel.Event.Listen( eventName, functionOrObject, isPersistent )

Make the provided function or object listen to the provided event(s). The function will be called whenever the provided event will be fired.

Parameters:
  • eventName (string or table) The event name (or names in a table).
  • functionOrObject (function or table) The function (not the function name) or the object.
  • isPersistent (boolean) [default=false] Tell whether the listener automatically stops to listen to any event when a new scene is loaded. Always false when the listener is a game object or a component.

Daneel.Event.RemoveEventListener( object, eventName, listener )

Remove the specified listener for the specified local event on this object

Parameters:
  • object (table) The object.
  • eventName (string) The name of the event.
  • listener (function or userdata) [optional] The listener function to remove. If nil, all listeners will be removed for the specified event.

Daneel.Event.StopListen( eventName, functionOrObject )

Make the provided function or object to stop listen to the provided event(s).

Parameters:
  • eventName (string or table) [optional] The event name or names in a table or nil to stop listen to every events.
  • functionOrObject (function, string or GameObject) The function, or the game object name or instance.

Daneel.Utilities.AllowDynamicGettersAndSetters( Object, ancestors )

Allow to call getters and setters as if they were variable on the instance of the provided object. The instances are tables that have the provided object as metatable. Optionally allow to search in a ancestry of objects.

Parameters:
  • Object (mixed) The object.
  • ancestors (table) [optional] A table with one or several objects the Object "inherits" from.

Daneel.Utilities.ButtonExists( buttonName )

Tell whether the provided button name exists amongst the Game Controls, or not. If the button name does not exists, it will print an error in the Runtime Report but it won't kill the script that called the function. CS.Input.ButtonExists is an alias of Daneel.Utilities.ButtonExists.

Parameters:
  • buttonName (string) The button name.
Return value:
    (boolean) True if the button name exists, false otherwise.

Daneel.Utilities.GetId( object )

Returns an integer greater than 0 and incremented by 1 from the last time the function was called. If an object is provided, returns the object's id (if no id is found, it is set).

Parameters:
  • object (table) [optional] An object.
Return value:
    (number) The id.

Daneel.Utilities.ReplaceInString( string, replacements )

Replace placeholders in the provided string with their corresponding provided replacements. The placeholders are any piece of string prefixed by a semicolon.

Parameters:
  • string (string) The string.
  • replacements (table) The placeholders and their replacements ( { placeholder = "replacement", ... } ).
Return value:
    (string) The string.

Draw.CircleRenderer.Draw( circle )

Draw the circle renderer. Updates the game object based on the circle renderer's properties. Fires the OnDraw event at the circle renderer.

Parameters:
  • circle (CircleRenderer) The circle renderer.

Draw.CircleRenderer.GetModel( circle )

Returns the circle renderer's segment's model.

Parameters:
  • circle (CircleRenderer) The circle renderer.
Return value:
    (Model) The model asset.

Draw.CircleRenderer.GetOpacity( circle )

Returns the circle renderer's segments' opacity.

Parameters:
  • circle (CircleRenderer) The circle renderer.
Return value:
    (number) The opacity (nil if the circle renderer has no segment).

Draw.CircleRenderer.GetRadius( circle )

Returns the circle renderer's radius.

Parameters:
  • circle (CircleRenderer) The circle renderer.
Return value:
    (number) The radius (in scene units).

Draw.CircleRenderer.GetSegmentCount( circle )

Returns the circle renderer's number of segments.

Parameters:
  • circle (CircleRenderer) The circle renderer.
Return value:
    (number) The segment count.

Draw.CircleRenderer.GetWidth( circle )

Returns the circle renderer's segment's width (and height).

Parameters:
  • circle (CircleRenderer) The circle renderer.
Return value:
    (number) The width (in scene units).

Draw.CircleRenderer.New( gameObject, params )

Creates a new circle renderer component.

Parameters:
  • gameObject (GameObject) The game object.
  • params (table) [optional] A table of parameters.
Return value:
    (CircleRenderer) The new component.

Draw.CircleRenderer.Set( circle, params )

Apply the content of the params argument to the provided circle renderer. Overwrite Component.Set().

Parameters:
  • circle (CircleRenderer) The circle renderer.
  • params (table) A table of parameters.

Draw.CircleRenderer.SetModel( circle, model )

Sets the circle renderer segment's model.

Parameters:
  • circle (CircleRenderer) The circle renderer.
  • model (string or Model) [optional] The segment's model name or asset, or nil.

Draw.CircleRenderer.SetOpacity( circle, opacity )

Sets the circle renderer segments' opacity.

Parameters:
  • circle (CircleRenderer) The circle renderer.
  • opacity (number) The opacity.

Draw.CircleRenderer.SetRadius( circle, radius, draw )

Sets the circle renderer's radius.

Parameters:
  • circle (CircleRenderer) The circle renderer.
  • radius (number) The radius (in scene units).
  • draw (boolean) [default=true] Tell whether to re-draw immediately the circle renderer.

Draw.CircleRenderer.SetSegmentCount( circle, count, draw )

Sets the circle renderer's segment count.

Parameters:
  • circle (CircleRenderer) The circle renderer.
  • count (number) The segment count (can't be lower than 3).
  • draw (boolean) [default=true] Tell whether to re-draw immediately the circle renderer.

Draw.CircleRenderer.SetWidth( circle, width )

Sets the circle renderer segment's width.

Parameters:
  • circle (CircleRenderer) The circle renderer.
  • width (number) The segment's width (and height).

Draw.LineRenderer.Draw( line )

Draw the line renderer. Updates the game object based on the line renderer's properties. Fires the OnDraw event on the line renderer.

Parameters:
  • line (LineRenderer) The line renderer.

Draw.LineRenderer.GetDirection( line )

Returns the line renderer's direction.

Parameters:
  • line (LineRenderer) The line renderer.
Return value:
    (Vector3) The direction.

Draw.LineRenderer.GetEndPosition( line )

Returns the line renderer's end position.

Parameters:
  • line (LineRenderer) The line renderer.
Return value:
    (Vector3) The end position.

Draw.LineRenderer.GetLength( line )

Returns the line renderer's length.

Parameters:
  • line (LineRenderer) The line renderer.
Return value:
    (number) The length (in scene units).

Draw.LineRenderer.GetWidth( line )

Returns the line renderer's width.

Parameters:
  • line (LineRenderer) The line renderer.
Return value:
    (number) The width.

Draw.LineRenderer.New( gameObject, params )

Creates a new LineRenderer component.

Parameters:
  • gameObject (GameObject) The game object.
  • params (table) [optional] A table of parameters.
Return value:
    (LineRenderer) The new component.

Draw.LineRenderer.Set( line, params )

Apply the content of the params argument to the provided line renderer. Overwrite Component.Set().

Parameters:
  • line (LineRenderer) The line renderer.
  • params (table) A table of parameters.

Draw.LineRenderer.SetDirection( line, direction, useDirectionAsLength, draw )

Set the line renderer's direction. It also updates line renderer's end position.

Parameters:
  • line (LineRenderer) The line renderer.
  • direction (Vector3) The direction.
  • useDirectionAsLength (boolean) [default=false] Tell whether to update the line renderer's length based on the provided direction's vector length.
  • draw (boolean) [default=true] Tell whether to re-draw immediately the line renderer.

Draw.LineRenderer.SetEndPosition( line, endPosition, draw )

Set the line renderer's end position. It also updates the line renderer's direction and length.

Parameters:
  • line (LineRenderer) The line renderer.
  • endPosition (Vector3) The end position.
  • draw (boolean) [default=true] Tell whether to re-draw immediately the line renderer.

Draw.LineRenderer.SetLength( line, length, draw )

Set the line renderer's length. It also updates line renderer's end position.

Parameters:
  • line (LineRenderer) The line renderer.
  • length (number) The length (in scene units).
  • draw (boolean) [default=true] Tell whether to re-draw immediately the line renderer.

Draw.LineRenderer.SetWidth( line, width, draw )

Set the line renderer's width (and height).

Parameters:
  • line (LineRenderer) The line renderer.
  • width (number) The width (in scene units).
  • draw (boolean) [default=true] Tell whether to re-draw immediately the line renderer.

GUI.Hud.CreateOriginGO( gameObject )

Creates a "Hud Origin" child used for positioning hud components.

Parameters:
  • gameObject (GameObject) The game object with a camera component.

GUI.Hud.GetLayer( hud )

Get the gameObject's layer.

Parameters:
  • hud (Hud) The hud component.
Return value:
    (number) The layer (with one decimal).

GUI.Hud.GetLocalLayer( hud )

Get the gameObject's local layer.

Parameters:
  • hud (Hud) The hud component.
Return value:
    (number) The layer (with one decimal).

GUI.Hud.GetLocalPosition( hud )

Get the local position (relative to its parent) of the gameObject on screen.

Parameters:
  • hud (Hud) The hud component.
Return value:
    (Vector2) The position.

GUI.Hud.GetPosition( hud )

Get the position of the provided hud on the screen.

Parameters:
  • hud (Hud) The hud component.
Return value:
    (Vector2) The position.

GUI.Hud.New( gameObject, params )

Creates a new Hud component instance.

Parameters:
  • gameObject (GameObject) The gameObject to add to the component to.
  • params (table) [optional] A table of parameters.
Return value:
    (Hud) The hud component.

GUI.Hud.SetLayer( hud, layer )

Set the gameObject's layer.

Parameters:
  • hud (Hud) The hud component.
  • layer (number) The layer (a postive number).

GUI.Hud.SetLocalLayer( hud, layer )

Set the huds's local layer.

Parameters:
  • hud (Hud) The hud component.
  • layer (number) The layer (a postiv number).

GUI.Hud.SetLocalPosition( hud, position )

Sets the local position (relative to its parent) of the gameObject on screen .

Parameters:
  • hud (Hud) The hud component.
  • position (Vector2) The position as a Vector2.

GUI.Hud.SetPosition( hud, position )

Sets the position of the gameObject on screen. With the top-left corner of the screen as origin.

Parameters:
  • hud (Hud) The hud component.
  • position (Vector2) The position as a Vector2.

GUI.Input.Focus( input, focus )

Set the focused state of the input.

Parameters:
  • input (Input) The input component.
  • focus (boolean) [default=true] The new focus.

GUI.Input.New( gameObject, params )

Creates a new GUI.Input.

Parameters:
  • gameObject (GameObject) The component gameObject.
  • params (table) [optional] A table of parameters.
Return value:
    (Input) The new component.

GUI.Input.Update( input, text, replaceText )

Update the text of the input.

Parameters:
  • input (Input) The input component.
  • text (string) The text (often just one character) to add to the current text.
  • replaceText (boolean) [default=false] Tell whether the provided text should be added (false) or replace (true) the current text.

GUI.Input.UpdateCursor( input )

Update the position and opacity of the input's cursor.

Parameters:
  • input (Input) The input component.

GUI.ProgressBar.GetHeight( progressBar )

Get the height of the progress bar (the local scale's y component).

Parameters:
  • progressBar (ProgressBar) The progressBar.
Return value:
    (number) The height.

GUI.ProgressBar.GetValue( progressBar, getAsPercentage )

Get the current value of the progress bar.

Parameters:
  • progressBar (ProgressBar) The progressBar.
  • getAsPercentage (boolean) [default=false] Get the value as a percentage (between 0 and 100) instead of an absolute value.
Return value:
    (number) The value.

GUI.ProgressBar.New( gameObject, params )

Creates a new GUI.ProgressBar.

Parameters:
  • gameObject (GameObject) The component gameObject.
  • params (table) [optional] A table of parameters.
Return value:
    (ProgressBar) The new component.

GUI.ProgressBar.Set( progressBar, params )

Apply the content of the params argument to the provided progressBar. Overwrite Component.Set() from CraftStudio module.

Parameters:
  • progressBar (ProgressBar) The progressBar.
  • params (table) A table of parameters to set the component with.

GUI.ProgressBar.SetHeight( progressBar, height )

Set the height of the progress bar.

Parameters:
  • progressBar (ProgressBar) The progressBar.
  • height (number or string) Get the height in pixel or scene unit.

GUI.ProgressBar.SetValue( progressBar, value )

Set the value of the progress bar, adjusting its length. Fires the 'OnUpdate' event.

Parameters:
  • progressBar (ProgressBar) The progressBar.
  • value (number or string) The value as a number (between minVal and maxVal) or as a string and a percentage (between "0%" and "100%").

GUI.ProgressBar.UpdateValue( progressBar, value, fireEvent )

Set the value of the progress bar, adjusting its length. Does the same things as SetProgress() by does it faster. Unlike SetProgress(), does not fire the 'OnUpdate' event by default. Should be used when the value is updated regularly (ie : from a Behavior:Update() function).

Parameters:
  • progressBar (ProgressBar) The progressBar.
  • value (number or string) The value as a number (between minVal and maxVal) or as a string and a percentage (between "0%" and "100%").
  • fireEvent (boolean) [default=false] Tell whether to fire the 'OnUpdate' event (true) or not (false).

GUI.Slider.GetValue( slider, getAsPercentage )

Get the current slider's value.

Parameters:
  • slider (Slider) The slider.
  • getAsPercentage (boolean) [default=false] Get the value as a percentage (between 0 and 100) instead of an absolute value.
Return value:
    (number) The value.

GUI.Slider.New( gameObject, params )

Creates a new GUI.Slider.

Parameters:
  • gameObject (GameObject) The component gameObject.
  • params (table) [optional] A table of parameters.
Return value:
    (Slider) The new component.

GUI.Slider.Set( slider, params )

Apply the content of the params argument to the provided slider. Overwrite Component.Set() from the core.

Parameters:
  • slider (Slider) The slider.
  • params (table) A table of parameters to set the component with.

GUI.Slider.SetValue( slider, value )

Set the value of the slider, adjusting its position.

Parameters:
  • slider (Slider) The slider.
  • value (number or string) The value as a number (between minVal and maxVal) or as a string and a percentage (between "0%" and "100%").

GUI.TextArea.AddLine( textArea, line, prepend )

Add a line to the text area's text.

Parameters:
  • textArea (TextArea) The textArea component.
  • line (string) The line to add.
  • prepend (boolean) [default=false] If true, prepend the line to the text. Otherwise, append the line to the text.

GUI.TextArea.GetAlignment( textArea )

Get the component's horizontal alignment.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (TextRenderer.Alignment or number) The alignment (of type number in the webplayer).

GUI.TextArea.GetAreaWidth( textArea )

Get the component's area width.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (number) The area width in scene units.

GUI.TextArea.GetFont( textArea )

Get the component's font used to render the text.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (Font) The font.

GUI.TextArea.GetLineHeight( textArea )

Get the component's line height.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (number) The line height in scene units.

GUI.TextArea.GetNewLine( textArea )

Get the component's newLine string.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (string) The newLine string.

GUI.TextArea.GetOpacity( textArea )

Get the component's opacity.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (number) The opacity between 0.0 and 1.0.

GUI.TextArea.GetText( textArea )

Get the component's text.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (string) The component's text.

GUI.TextArea.GetVerticalAlignment( textArea )

Get the component's vertical alignment property.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (string) The vertical alignment.

GUI.TextArea.GetWordWrap( textArea )

Get the component's wordWrap property.

Parameters:
  • textArea (TextArea) The textArea component.
Return value:
    (boolean) True or false.

GUI.TextArea.New( gameObject, params )

Creates a new TextArea component.

Parameters:
  • gameObject (GameObject) The game object.
  • params (table) [optional] A table of parameters.
Return value:
    (TextArea) The new component.

GUI.TextArea.Set( textArea, params )

Apply the content of the params argument to the provided textArea. Overwrite Component.Set() from the core.

Parameters:
  • textArea (TextArea) The textArea.
  • params (table) A table of parameters to set the component with.

GUI.TextArea.SetAlignment( textArea, alignment )

Set the component's alignment. Works like a TextRenderer alignment.

Parameters:
  • textArea (TextArea) The textArea component.
  • alignment (TextRenderer.Alignment or string) One of the values in the 'TextRenderer.Alignment' enum (Left, Center or Right) or the same values as case-insensitive string ("left", "center" or "right").

GUI.TextArea.SetAreaWidth( textArea, areaWidth )

Set the component's area width (maximum line length). Must be strictly positive to have an effect. Set as a negative value, 0 or nil to remove the limitation.

Parameters:
  • textArea (TextArea) The textArea component.
  • areaWidth (number or string) [default=0] The area width in scene units or in pixels as a string suffixed with "px".

GUI.TextArea.SetFont( textArea, font )

Set the component's font used to renderer the text.

Parameters:
  • textArea (TextArea) The textArea component.
  • font (Font or string) The font asset or fully-qualified path.

GUI.TextArea.SetLineHeight( textArea, lineHeight )

Set the component's line height.

Parameters:
  • textArea (TextArea) The textArea component.
  • lineHeight (number or string) The line height in scene units or in pixels as a string suffixed with "px".

GUI.TextArea.SetNewLine( textArea, newLine )

Set the component's newLine string used by SetText() to split the input text in several lines.

Parameters:
  • textArea (TextArea) The textArea component.
  • newLine (string) The newLine string (one or several character long). Set "\n" to split multiline strings.

GUI.TextArea.SetOpacity( textArea, opacity )

Set the component's opacity.

Parameters:
  • textArea (TextArea) The textArea component.
  • opacity (number) The opacity between 0.0 and 1.0.

GUI.TextArea.SetText( textArea, text )

Set the component's text.

Parameters:
  • textArea (TextArea) The textArea component.
  • text (string) The text to display.

GUI.TextArea.SetVerticalAlignment( textArea, verticalAlignment )

Set the component's vertical alignment.

Parameters:
  • textArea (TextArea) The textArea component.
  • verticalAlignment (string) "top", "middle" or "bottom". Case-insensitive.

GUI.TextArea.SetWordWrap( textArea, wordWrap )

Set the component's wordWrap property. Define what happens when the lines are longer then the area width.

Parameters:
  • textArea (TextArea) The textArea component.
  • wordWrap (boolean) [default=false] Cut the line when false, or creates new additional lines with the remaining text when true.

GUI.ToPixel( value, screenSide, camera )

Convert the provided value (a length) in a number expressed in screen pixel. The provided value may be suffixed with "px" or be expressed in percentage (ie: "10%") or be relative (ie: "s" or "s-10") to the specified screen side size (in which case the 'screenSide' argument is mandatory).

Parameters:
  • value (string or number) The value to convert.
  • screenSide (string) [optional] "x" (width) or "y" (height)
  • camera (Camera) [optional] The reference camera used to convert from pixels to units. Only needed when the value is in units.
Return value:
    (number) The converted value, expressed in pixels.

GUI.ToSceneUnit( value, camera )

Convert the provided value (a length) in a number expressed in scene unit. The provided value may be suffixed with "px" (pixels) or "u" (scene units).

Parameters:
  • value (string or number) The value to convert.
  • camera (Camera or GameObject) [optional] The reference camera used to convert from pixels to units. Only needed when the value is in pixels.
Return value:
    (number) The converted value, expressed in scene units.

GUI.Toggle.Check( toggle, state, forceUpdate )

Check or uncheck the provided toggle and fire the OnUpdate event. You can get the toggle's state via toggle.isChecked.

Parameters:
  • toggle (Toggle) The toggle component.
  • state (boolean) [default=true] The new state of the toggle.
  • forceUpdate (boolean) [default=false] Tell whether to force the updating of the state.

GUI.Toggle.GetGroup( toggle )

Get the toggle's group.

Parameters:
  • toggle (Toggle) The toggle component.
Return value:
    (string) The group, or nil.

GUI.Toggle.GetText( toggle )

Get the provided toggle's text. Actually get the text of the TextRenderer component on the same gameObject but without the check mark.

Parameters:
  • toggle (Toggle) The toggle component.
Return value:
    (string) The text.

GUI.Toggle.New( gameObject, params )

Creates a new Toggle component.

Parameters:
  • gameObject (GameObject) The component gameObject.
  • params (table) [optional] A table of parameters.
Return value:
    (Toggle) The new component.

GUI.Toggle.Set( toggle, params )

Apply the content of the params argument to the provided toggle. Overwrite Component.Set() from Daneel's CraftStudio file.

Parameters:
  • toggle (Toggle) The toggle component.
  • params (table) A table of parameters to set the component with.

GUI.Toggle.SetGroup( toggle, group )

Set the toggle's group. If the toggle was already in a group it will be removed from it.

Parameters:
  • toggle (Toggle) The toggle component.
  • group (string) [optional] The new group, or nil to remove the toggle from its group.

GUI.Toggle.SetText( toggle, text )

Set the provided toggle's text. Actually set the text of the TextRenderer component on the same gameObject, but add the correct check mark in front of the provided text.

Parameters:
  • toggle (Toggle) The toggle component.
  • text (string) The text to display.

GameObject.AddComponent( gameObject, componentType, params )

Add a component to the game object and optionally initialize it.

Parameters:
  • gameObject (GameObject) The game object.
  • componentType (string or Script) The component type, or script asset or path (can't be Transform or ScriptedBehavior).
  • params (string, Script or table) [optional] A table of parameters to initialize the new component with or, if componentType is 'ScriptedBehavior', the mandatory script name or asset.
Return value:
    (mixed) The component.

GameObject.AddEventListener( gameObject, eventName, listener )

Add a listener function for the specified local event on this game object. Alias of Daneel.Event.AddEventListener().

Parameters:
  • gameObject (GameObject) The game object.
  • eventName (string) The name of the event to listen to.
  • listener (function or userdata) The listener function.

GameObject.AddTag( gameObject, tag )

Add the provided tag(s) to the provided game object.

Parameters:
  • gameObject (GameObject) The game object.
  • tag (string or table) One or several tag(s) (as a string or table of strings).

GameObject.Animate( gameObject, property, endValue, duration, onCompleteCallback, params )

Creates an animation (a tweener) with the provided parameters.

Parameters:
  • gameObject (GameObject) The game object.
  • property (string) The name of the property to animate.
  • endValue (number, Vector2, Vector3 or string) The value the property should have at the end of the duration.
  • duration (number) The time (in seconds) or frame it should take for the property to reach endValue.
  • onCompleteCallback (function) [optional] The function to execute when the tweener has completed.
  • params (table) [optional] A table of parameters.
Return value:
    (Tweener) The tweener.

GameObject.Destroy( gameObject )

Destroy the game object at the end of this frame.

Parameters:
  • gameObject (GameObject) The game object.

GameObject.Display( gameObject, value, forceUseLocalPosition )

Display or hide the game object. Act on the renderer's opacity or the transform's local position. Sets the "isDisplayed" property to true or false and fire the "OnDisplay" event on the game object.

Parameters:
  • gameObject (GameObject) The game object.
  • value (boolean, number or Vector3) [default=true] Tell whether to display or hide the game object (as a boolean), or the opacity (as a number) or the local position (as a Vector3).
  • forceUseLocalPosition (boolean) [default=false] Tell whether to force to axt on the game object's local position even when it possess a renderer.

GameObject.FireEvent( gameObject, eventName, ... )

Fire an event at the provided game object.

Parameters:
  • gameObject (GameObject) The game object.
  • eventName (string) The event name.
  • ... [optional] Some arguments to pass along.

GameObject.Get( name, errorIfGameObjectNotFound )

Alias of CraftStudio.FindGameObject(name). Get the first game object with the provided name.

Parameters:
  • name (string) The game object name.
  • errorIfGameObjectNotFound (boolean) [default=false] Throw an error if the game object was not found (instead of returning nil).
Return value:
    (GameObject) The game object or nil if none is found.

GameObject.GetChild( gameObject, name, recursive )

Alias of GameObject.FindChild(). Find the first game object's child with the provided name. If the name is not provided, it returns the first child.

Parameters:
  • gameObject (GameObject) The game object.
  • name (string) [optional] The child name (may be hyerarchy of names separated by dots).
  • recursive (boolean) [default=false] Search for the child in all descendants instead of just the first generation.
Return value:
    (GameObject) The child or nil if none is found.

GameObject.GetChildren( gameObject, recursive, includeSelf )

Get all descendants of the game object.

Parameters:
  • gameObject (GameObject) The game object.
  • recursive (boolean) [default=false] Look for all descendants instead of just the first generation.
  • includeSelf (boolean) [default=false] Include the game object in the children.
Return value:
    (table) The children.

GameObject.GetComponent( gameObject, componentType )

Get the first component of the provided type attached to the game object.

Parameters:
  • gameObject (GameObject) The game object.
  • componentType (string or Script) The component type, or script asset or path.
Return value:
    (One of the component types) The component instance, or nil if none is found.

GameObject.GetId( gameObject )

Returns the game object's internal unique identifier.

Parameters:
  • gameObject (GameObject) The game object.
Return value:
    (number) The id.

GameObject.GetInAncestors( gameObject, searchFunction )

Search the ancestors of the provided game object. It returns the game object that match the condition in the search function. The search function receive a game object as the only argument. The search function must return true in order for GetInAncestors() to return the searched game object.

Parameters:
  • gameObject (GameObject) The game object.
  • searchFunction (function) The search function.
Return value:
    (GameObject) The searched game object, or nil.

GameObject.GetScriptedBehavior( gameObject, scriptNameOrAsset )

Get the provided scripted behavior instance attached to the game object.

Parameters:
  • gameObject (GameObject) The game object.
  • scriptNameOrAsset (string or Script) The script name or asset.
Return value:
    (ScriptedBehavior) The ScriptedBehavior instance.

GameObject.GetTags( gameObject )

Returns the tag(s) of the provided game object.

Parameters:
  • gameObject (GameObject) The game object.
Return value:
    (table) The tag(s) (empty if the game object has no tag).

GameObject.GetWithTag( tag )

Returns the game object(s) that have all the provided tag(s).

Parameters:
  • tag (string or table) One or several tag(s) (as a string or table of strings).
Return value:
    (table) The game object(s) (empty if none is found).

GameObject.HasTag( gameObject, tag, atLeastOneTag )

Tell whether the provided game object has all (or at least one of) the provided tag(s).

Parameters:
  • gameObject (GameObject) The game object.
  • tag (string or table) One or several tag (as a string or table of strings).
  • atLeastOneTag (boolean) [default=false] If true, returns true if the game object has AT LEAST one of the tag (instead of ALL the tag).
Return value:
    (boolean) True

GameObject.Instantiate( name, sceneNameOrAsset, params )

Create a new game object with the content of the provided scene and optionally initialize it.

Parameters:
  • name (string) The game object name.
  • sceneNameOrAsset (string or Scene) The scene name or scene asset.
  • params (table or GameObject) [optional] A table with parameters to initialize the new game object with, or the parent gameO object to attach to..
Return value:
    (GameObject) The new game object.

GameObject.New( name, params )

Create a new game object and optionally initialize it.

Parameters:
  • name (string) The game object name.
  • params (table or GameObject) [optional] A table with parameters to initialize the new game object with, or the parent gameO object to attach to.
Return value:
    (GameObject) The new game object.

GameObject.RemoveEventListener( gameObject, eventName, listener )

Remove the specified listener for the specified local event on this game object

Parameters:
  • gameObject (table) The game object.
  • eventName (string) The name of the event.
  • listener (function or userdata) [optional] The listener function to remove. If nil, all listeners will be removed for the specified event.

GameObject.RemoveTag( gameObject, tag )

Remove the provided tag(s) from the provided game object. If the 'tag' argument is not provided, all tag of the game object will be removed.

Parameters:
  • gameObject (GameObject) The game object.
  • tag (string or table) [optional] One or several tag(s) (as a string or table of strings).

GameObject.SendMessage( gameObject, functionName, data )

Tries to call a method with the provided name on all the scriptedBehaviors attached to the game object. The data argument can be nil or a table you want the method to receive as its first (and only) argument. If none of the scripteBehaviors attached to the game object or its children have a method matching the provided name, nothing happens.

Parameters:
  • gameObject (GameObject) The game object.
  • functionName (string) The method name.
  • data (table) [optional] The data to pass along the method call.

GameObject.Set( gameObject, params )

Apply the content of the params argument to the provided game object.

Parameters:
  • gameObject (GameObject) The game object.
  • params (table) A table of parameters to set the game object with.

GameObject.SetParent( gameObject, parentNameOrInstance, keepLocalTransform )

Set the game object's parent. Optionaly carry over the game object's local transform instead of the global one.

Parameters:
  • gameObject (GameObject) The game object.
  • parentNameOrInstance (string or GameObject) [optional] The parent name or game object (or nil to remove the parent).
  • keepLocalTransform (boolean) [default=false] Carry over the game object's local transform instead of the global one.

Lang.Get( key, replacements )

Get the localized line identified by the provided key.

Parameters:
  • key (string) The language key.
  • replacements (table) [optional] The placeholders and their replacements.
Return value:
    (string) The line.

Lang.RegisterForUpdate( gameObject, key, replacements )

Register a game object to update its text renderer whenever the language will be updated by Lang.Update().

Parameters:
  • gameObject (GameObject) The gameObject.
  • key (string) The language key.
  • replacements (table) [optional] The placeholders and their replacements.

Lang.Update( language )

Update the current language and the text of all game objects that have registered via Lang.RegisterForUpdate().
Fire the OnLangUpdate event.

Parameters:
  • language (string) The new current language.

Map.GetBlockIDAt( map, x, y, z )

Returns A block ID between 0-254 if a block exists at the given location (all valid block IDs are in the range 0-254), otherwise f there is no block at the given location then it will return Map.EmptyBlockID (which has a value of 255).

Parameters:
  • map (Map) The map.
  • x (number or Vector3) The location's x component, or the location as a Vector3.
  • y (number) [optional] The location's y component. Should be nil if the "x" argument is a Vector3.
  • z (number) [optional] The location's z component. Should be nil if the "x" argument is a Vector3.
Return value:
    (number) The block ID.

Map.GetBlockOrientationAt( map, x, y, z )

Returns The block orientation of the block at the specified location, otherwise if there is no block at the given location it will return Map.BlockOrientation.North.

Parameters:
  • map (Map) The map.
  • x (number or Vector3) The location's x component, or the location as a Vector3.
  • y (number) [optional] The location's y component. Should be nil if the "x" argument is a Vector3.
  • z (number) [optional] The location's z component. Should be nil if the "x" argument is a Vector3.
Return value:
    (Map.BlockOrientation) The block orientation.

Map.SetBlockAt( map, x, y, z, id, orientation )

Sets a block's ID and block orientation at the given location on the map.

Parameters:
  • map (Map) The map.
  • x (number or Vector3) The location's x component, or the location as a Vector3.
  • y (number) [optional] The location's y component. Must have the value of the "id" argument if the "x" argument is a Vector3.
  • z (number) [optional] The location's z component. Must have the value of the optional "orientation" argument if the "x" argument is a Vector3.
  • id (number) The block ID.
  • orientation (Map.BlockOrientation) [optional] The block orientation.

MapRenderer.LoadNewMap( mapRenderer, callback )

Dynamically loads a new version of the provided map renderer's map and sets it as the map renderer new map.

Parameters:
  • mapRenderer (MapRenderer) The map renderer.
  • callback (function) [optional] The callback function to be called when the new map has been loaded. The new map is pased as first and only argument.

MapRenderer.Set( mapRenderer, params )

Apply the content of the params argument to the provided map renderer.

Parameters:
  • mapRenderer (MapRenderer) The map renderer.
  • params (table) A table of parameters to set the component with.

MapRenderer.SetMap( mapRenderer, mapNameOrAsset, replaceTileSet )

Attach the provided map to the provided map renderer.

Parameters:
  • mapRenderer (MapRenderer) The map renderer.
  • mapNameOrAsset (string or Map) [optional] The map name or asset, or nil.
  • replaceTileSet (boolean) [default=true] Replace the current TileSet by the one set for the provided map in the map editor.

MapRenderer.SetTileSet( mapRenderer, tileSetNameOrAsset )

Set the specified tileSet for the mapRenderer's map.

Parameters:
  • mapRenderer (MapRenderer) The mapRenderer.
  • tileSetNameOrAsset (string or TileSet) [optional] The tileSet name or asset, or nil.

ModelRenderer.GetColor( modelRenderer )

Get the color of the provided model renderer.

Parameters:
  • modelRenderer (ModelRenderer) The model renderer.
Return value:
    Rc (Color) The result/renderer color (the one you see).

ModelRenderer.Set( modelRenderer, params )

Apply the content of the params argument to the provided model renderer.

Parameters:
  • modelRenderer (ModelRenderer) The model renderer.
  • params (table) A table of parameters to set the component with.

ModelRenderer.SetAnimation( modelRenderer, animationNameOrAsset )

Set the specified animation for the modelRenderer's current model.

Parameters:
  • modelRenderer (ModelRenderer) The modelRenderer.
  • animationNameOrAsset (string or ModelAnimation) [optional] The animation name or asset, or nil.

ModelRenderer.SetColor( modelRenderer, color )

Set the color of the provided model renderer.

Parameters:
  • modelRenderer (ModelRenderer) The model renderer.
  • color (Color) The color instance.

ModelRenderer.SetModel( modelRenderer, modelNameOrAsset )

Attach the provided model to the provided modelRenderer.

Parameters:
  • modelRenderer (ModelRenderer) The modelRenderer.
  • modelNameOrAsset (string or Model) [optional] The model name or asset, or nil.

MouseInput.GetTags( mouseInput )

Return the tag(s) of the game objects the component works with.

Parameters:
  • mouseInput (MouseInput) The mouse input component.
Return value:
    (table) The tag(s) of the game objects the component works with.

MouseInput.New( gameObject, params )

Create a new MouseInput component.

Parameters:
  • gameObject (GameObject) The game object.
  • params (table) [optional] A table of parameters.
Return value:
    (MouseInput) The new component.

MouseInput.SetTags( mouseInput, tags )

Set tag(s) of the game objects the component works with.

Parameters:
  • mouseInput (MouseInput) The mouse input component.
  • tags (string or table) The tag(s) of the game objects the component works with.

MouseInput.Update( mouseInput )

Update the specified MouseInput component or update all components when no argument is passed. When the component is specified, the update is forced. It happens even if the mouse doesn't move and no button input happens.

Parameters:
  • mouseInput (MouseInput) [optional] The MouseInput component to update.

Ray.Cast( ray, gameObjects, sortByDistance )

Check the collision of the ray against the provided set of game objects.

Parameters:
  • ray (Ray) The ray.
  • gameObjects (table) The set of game objects to cast the ray against.
  • sortByDistance (boolean) [default=false] Sort the raycastHit by increasing distance in the returned table.
Return value:
    (table) A table of RaycastHits (will be empty if the ray didn't intersects anything).

Ray.IntersectsGameObject( ray, gameObjectNameOrInstance )

Check if the ray intersects the specified game object.

Parameters:
  • ray (Ray) The ray.
  • gameObjectNameOrInstance (string or GameObject) The game object instance or name.
Return value:
    (RaycastHit) A raycastHit if there was a collision, or nil.

RaycastHit.New( params )

Create a new RaycastHit

Parameters:
  • params
Return value:
    (RaycastHit) The raycastHit.

Scene.Append( sceneNameOrAsset, parentNameOrInstance )

Alias of CraftStudio.AppendScene(). Appends the specified scene to the game by instantiating all of its game objects. Contrary to CraftStudio.LoadScene, this doesn't unload the current scene nor waits for the next tick: it happens right away. You can optionally specify a parent game object which will be used as a root for adding all game objects. Returns the game object appended if there was only one root game object in the provided scene.

Parameters:
  • sceneNameOrAsset (string or Scene) The scene name or asset.
  • parentNameOrInstance (string or GameObject) [optional] The parent game object name or instance.
Return value:
    (GameObject) The appended game object, or nil.

Scene.Load( sceneNameOrAsset )

Alias of CraftStudio.LoadScene(). Schedules loading the specified scene after the current tick (frame) (1/60th of a second) has completed. When the new scene is loaded, all of the current scene's game objects will be removed. Calling this function doesn't immediately stops the calling function. As such, you might want to add a return statement afterwards.

Parameters:
  • sceneNameOrAsset (string or Scene) The scene name or asset.

Sound.Play( soundAssetOrPath, volume, pitch, pan )

Play the specified sound.

Parameters:
  • soundAssetOrPath (Sound or string) The sound asset or path.
  • volume (number) [default=1] The sound's volume between 0 and 1.
  • pitch (number) [default=0] The sound's pitch between -1 and 1.
  • pan (number) [default=0] The sound's pan (left/right positioning) between -1 and 1.

TextRenderer.GetColor( textRenderer )

Get the color of the provided text renderer.

Parameters:
  • textRenderer (textRenderer) The text renderer.
Return value:
    Rc (Color) The result/renderer color (the one you see).

TextRenderer.SetAlignment( textRenderer, alignment )

Set the text's alignment.

Parameters:
  • textRenderer (TextRenderer) The textRenderer.
  • alignment (string or TextRenderer.Alignment) The alignment. Values (case-insensitive when of type string) may be "left", "center", "right", TextRenderer.Alignment.Left, TextRenderer.Alignment.Center or TextRenderer.Alignment.Right.

TextRenderer.SetColor( textRenderer, color )

Set the color of the provided text renderer.

Parameters:
  • textRenderer (textRenderer) The text renderer.
  • color (Color) The color instance.

TextRenderer.SetFont( textRenderer, fontNameOrAsset )

Set the provided font to the provided text renderer.

Parameters:
  • textRenderer (TextRenderer) The text renderer.
  • fontNameOrAsset (string or Font) [optional] The font name or asset, or nil.

TextRenderer.SetTextWidth( textRenderer, width )

Update the game object's scale to make the text appear the provided width.

Parameters:
  • textRenderer (TextRenderer) The textRenderer.
  • width (number) The text's width in scene units.

Transform.GetScale( transform )

Get the transform's global scale.

Parameters:
  • transform (Transform) The transform component.
Return value:
    (Vector3) The global scale.

Transform.LocalToWorld( transform, position )

Transform a position local to this transform to a global position.

Parameters:
  • transform (Transform) The transform component.
  • position (Vector3) The local position.
Return value:
    (Vector3) The global position corresponding to the provided local position.

Transform.SetLocalScale( transform, scale )

Set the transform's local scale.

Parameters:
  • transform (Transform) The transform component.
  • scale (number or Vector3) The global scale.

Transform.SetScale( transform, scale )

Set the transform's global scale.

Parameters:
  • transform (Transform) The transform component.
  • scale (number or Vector3) The global scale.

Transform.WorldToLocal( transform, position )

Transform a global position to a position local to this transform.

Parameters:
  • transform (Transform) The transform component.
  • position (Vector3) The global position.
Return value:
    (Vector3) The local position corresponding to the provided global position.

Trigger.GetGameObjectsInRange( trigger )

Get the gameObjects that are within range of that trigger.

Parameters:
  • trigger (Trigger) The trigger component.
Return value:
    (table) The list of the gameObjects in range (empty if none in range).

Trigger.GetRange( trigger )

Get the range of the trigger.

Parameters:
  • trigger (Trigger) The trigger component.
Return value:
    (number) The range of the trigger.

Trigger.GetTags( trigger )

Return the tag(s) of the game objects the component works with.

Parameters:
  • trigger (Trigger) The trigger component.
Return value:
    (table) The tag(s) of the game objects the component works with.

Trigger.GetUpdateInterval( trigger )

Get the interval (in frames) at which the trigger is automatically updated.

Parameters:
  • trigger (Trigger) The trigger component.
Return value:
    (number) The update interval (in frames) of the trigger.

Trigger.IsGameObjectInRange( trigger, gameObject, triggerPosition )

Tell whether the provided game object is in range of the trigger.

Parameters:
  • trigger (Trigger) The trigger component.
  • gameObject (GameObject) The gameObject.
  • triggerPosition (Vector3) [optional] The trigger's current position.
Return value:
    (boolean) True or false.

Trigger.New( gameObject, params )

Create a new Trigger component.

Parameters:
  • gameObject (GameObject) The game object.
  • params (table) [optional] A table of parameters.
Return value:
    (Trigger) The new component.

Trigger.SetRange( trigger, range )

Set the range of the trigger.

Parameters:
  • trigger (Trigger) The trigger component.
  • range (number) The range of the trigger. Must be >= 0. Set to 0 to use the trigger's map or model as area.

Trigger.SetTags( trigger, tags )

Set tag(s) of the game objects the component works with.

Parameters:
  • trigger (Trigger) The trigger component.
  • tags (string or table) The tag(s) of the game objects the component works with.

Trigger.SetUpdateInterval( trigger, updateInterval )

Set the interval (in frames) at which the trigger is automatically updated. A value < 1 will prevent the trigger to be automatically updated.

Parameters:
  • trigger (Trigger) The trigger component.
  • updateInterval (number) The update interval in frames. Must be >= 0

Tween.Timer.New( duration, callback, isInfiniteLoop, params )

Creates a new tweener via one of the two allowed constructors :
Timer.New(duration, OnCompleteCallback[, params])
Timer.New(duration, OnLoopCompleteCallback, true[, params])


Parameters:
  • duration (number) The time or frame it should take for the timer or one loop to complete.
  • callback (function or userdata) The function that gets called when the OnComplete or OnLoopComplete event are fired.
  • isInfiniteLoop [optional default=false] (boolean) Tell wether the timer loops indefinitely.
  • params [optional] (table) A table of parameters.
Return value:
    (Tweener) The tweener.

Tween.Tweener.Complete( tweener )

Complete the tweener fire the OnComple event.

Parameters:
  • tweener (Tween.Tweener) The tweener.

Tween.Tweener.Destroy( tweener )

Destroy the tweener.

Parameters:
  • tweener (Tween.Tweener) The tweener.

Tween.Tweener.New( target, property, endValue, duration, onCompleteCallback, params )

Creates a new tweener via one of the three allowed constructors :
Tweener.New(target, property, endValue, duration[, params])
Tweener.New(startValue, endValue, duration[, params])
Tweener.New(params)

Parameters:
  • target (table) An object.
  • property (string) The name of the propertty to animate.
  • endValue (number) The value the property should have at the end of the duration.
  • duration (number) The time or frame it should take for the property to reach endValue.
  • onCompleteCallback (function) [optional] The function to execute when the tweener has completed.
  • params (table) [optional] A table of parameters.
Return value:
    (Tweener) The Tweener.

Tween.Tweener.Pause( tweener )

Pause the tweener and fire the OnPause event.

Parameters:
  • tweener (Tween.Tweener) The tweener.

Tween.Tweener.Play( tweener )

Unpause the tweener and fire the OnPlay event.

Parameters:
  • tweener (Tween.Tweener) The tweener.

Tween.Tweener.Restart( tweener )

Completely restart the tweener.

Parameters:
  • tweener (Tween.Tweener) The tweener.

Tween.Tweener.Update( tweener, deltaDuration )

Update the tweener's value based on the tweener's elapsed property. Fire the OnUpdate event. This allows the tweener to fast-forward to a certain time.

Parameters:
  • tweener (Tween.Tweener) The tweener.
  • deltaDuration [optional] (number) Only used internaly. If nil, the tweener's value will be updated based on the current value of tweener.elapsed.

Vector2.GetLength( vector )

Return the length of the vector.

Parameters:
  • vector (Vector2) The vector.
Return value:
    (number) The length.

Vector2.GetSqrLength( vector )

Return the squared length of the vector.

Parameters:
  • vector (Vector2) The vector.
Return value:
    (number) The squared length.

Vector2.New( x, y )

Creates a new Vector2 intance.

Parameters:
  • x (number, table, Vector2 or Vector3) The vector's x component, or a table that contains "x" and "y" components.
  • y (number) [optional] The vector's y component. If nil, will be equal to x.
Return value:
    (Vector2) The new instance.

Vector2.Normalize( vector )

Normalize the provided vector in place (makes its length equal to 1).

Parameters:
  • vector (Vector2) The vector to normalize.

Vector2.Normalized( vector )

Return a copy of the provided vector, normalized.

Parameters:
  • vector (Vector2) The vector to normalize.
Return value:
    (Vector2) A copy of the vector, normalized.

Vector2.ToPixel( vector, camera )

Make sure that the components of the provided Vector2 are numbers and in pixel, instead of strings or in percentage or relative to the screensize.

Parameters:
  • vector (Vector2) The vector2.
  • camera (Camera) [optional] The reference camera used to convert from pixels to units. Only needed when the vector's components are in units.
Return value:
    (Vector2) The fixed position.

Vector2.ToString( vector )

Returns a string representation of the vector's component's values. ie: For a vector {-6.5,10}, the returned string would be "-6.5 10". Such string can be converted back to a vector with string.tovector()

Parameters:
  • vector (Vector2) The vector.
Return value:
    (string) The string.

Vector2.__add( a, b )

Allow to add two Vector2 by using the + operator. Ie : vector1 + vector2

Parameters:
  • a (Vector2) The left member.
  • b (Vector2) The right member.
Return value:
    (Vector2) The new vector.

Vector2.__div( a, b )

Allow to divide two Vector2 or a Vector2 and a number by using the / operator.

Parameters:
  • a (Vector2 or number) The numerator.
  • b (Vector2 or number) The denominator. Can't be equal to 0.
Return value:
    (Vector2) The new vector.

Vector2.__eq( a, b )

Allow to check for the equality between two Vector2 using the == comparison operator.

Parameters:
  • a (Vector2) The left member.
  • b (Vector2) The right member.
Return value:
    (boolean) True if the same components of the two vectors are equal (a.x=b.x and a.y=b.y)

Vector2.__mul( a, b )

Allow to multiply two Vector2 or a Vector2 and a number by using the * operator.

Parameters:
  • a (Vector2 or number) The left member.
  • b (Vector2 or number) The right member.
Return value:
    (Vector2) The new vector.

Vector2.__pow( vector, exp )

Allow to raise a Vector2 to a power using the ^ operator.

Parameters:
  • vector (Vector2) The vector.
  • exp (number) The power to raise the vector to.
Return value:
    (Vector2) The new vector.

Vector2.__sub( a, b )

Allow to substract two Vector2 by using the - operator. Ie : vector1 - vector2

Parameters:
  • a (Vector2) The left member.
  • b (Vector2) The right member.
Return value:
    (Vector2) The new vector.

Vector2.__unm( vector )

Allow to inverse a vector2 using the - operator.

Parameters:
  • vector (Vector2) The vector.
Return value:
    (Vector2) The new vector.

Vector3.GetLength( vector )

Returns the length of the provided vector

Parameters:
  • vector (Vector3) The vector.
Return value:
    (number) The length.

Vector3.GetSqrLength( vector )

Return the squared length of the vector.

Parameters:
  • vector (Vector3) The vector.
Return value:
    (number) The squared length.

Vector3.New( x, y, z, z2 )

Returns a new Vector3.

Parameters:
  • x (number, Vector3 or Vector2) [optional] The vector's x component.
  • y (number or Vector2) [optional] The vector's y component.
  • z (number) [optional] The vector's z component.
  • z2

Vector3.ToString( vector )

Returns a string representation of the vector's component's values. ie: For a vector {-6.5,10,2.1}, the returned string would be "-6.5 10 2.1". Such string can be converted back to a vector with string.tovector()

Parameters:
  • vector (Vector3) The vector.
Return value:
    (string) The string.

error( message, doNotPrintStacktrace )

Print the stackTrace unless told otherwise then the provided error in the console. Only exists when debug is enabled. When debug in disabled the built-in 'error(message)'' function exists instead.

Parameters:
  • message (string) The error message.
  • doNotPrintStacktrace [optional default=false] (boolean) Set to true to prevent the stacktrace to be printed before the error message.

math.clamp( value, min, max )

Return the value clamped between min and max.

Parameters:
  • value (number) The value.
  • min (number) The minimal value.
  • max (number) The maximal value.
Return value:
    (number) The new value.

math.isinteger( number )

Tell whether the provided number is an integer. That include numbers that have one or several zeros as decimals (1.0, 2.000, ...).

Parameters:
  • number (number) The number to check.
Return value:
    (boolean) True if the provided number is an integer, false otherwise.

math.lerp( a, b, factor, easing )

Returns the value resulting of the linear interpolation between value a and b by the specified factor.

Parameters:
  • a (number)
  • b (number)
  • factor (number) Should be between 0.0 and 1.0.
  • easing (string) [optional] The easing of the factor, can be "smooth", "smooth in", "smooth out".
Return value:
    (number) The interpolated value.

math.round( value, decimal )

Round the value to the closest integer or decimal.

Parameters:
  • value (number) The value to round.
  • decimal (number) [default=0] The decimal at which to round the value.
Return value:
    (number) The rounded value.

math.truncate( value, decimal )

Trucate the value to the provided decimal.

Parameters:
  • value (number) The value to truncate.
  • decimal (number) [default=0] The decimal at which to truncate the value.
Return value:
    (number) The truncated value.

math.warpangle( angle )

Wrap the provided angle between -180 and 180.

Parameters:
  • angle (number) The angle.
Return value:
    (number) The angle.

string.endswith( s, chunk )

Tell whether the provided string ends by the provided chunk or not.

Parameters:
  • s (string) The string.
  • chunk (string) The searched chunk.
Return value:
    (boolean) True or false.

string.fixcase( s, set )

Make sure that the case of the provided string is correct by checking it against the values in the provided set.

Parameters:
  • s (string) The string to check the case of.
  • set (string or table) A single value or a table of values to check the string against.
Return value:
    (string) The string with the corrected case.

string.lcfirst( s )

Turn the first letter of the string lowercase.

Parameters:
  • s (string) The string.
Return value:
    (string) The string.

string.reverse( s )

Reverse the order of the characters in a string ("abcd" becomes "dcba").

Parameters:
  • s (string) The string.
Return value:
    (string) The reversed string.

string.split( s, delimiter, delimiterIsPattern )

Some Lua functions are overridden here with some Daneel-specific stuffs

Parameters:
  • s
  • delimiter
  • delimiterIsPattern

string.split( s, delimiter, delimiterIsPattern )

Some Lua functions are overridden here with some Daneel-specific stuffs

Parameters:
  • s
  • delimiter
  • delimiterIsPattern

string.startswith( s, chunk )

Tell whether the provided string begins by the provided chunk or not.

Parameters:
  • s (string) The string.
  • chunk (string) The searched chunk.
Return value:
    (boolean) True or false.

string.tocolor( sColor )

Convert a string representation of a color component's values to a Color object. ie: For a string "10 250 128", the returned color would be { 10, 250, 128 }. Such string can be created from a Color with with Color.ToString()

Parameters:
  • sColor (string) The color as a string, each component's value being separated by a space.
Return value:
    (Color) The color.

string.totable( s )

Turn a string into a table, one character per index.

Parameters:
  • s (string) The string.
Return value:
    (table) The table.

string.tovector( sVector )

Convert a string representation of a vector component's values to a Vector3 or a Vector2. ie: For a string "-6.5 10 2.1", the returned vector would be {-6.5, 10, 2.1}. Such string can be created from a vector2 or Vector3 with Vector2.ToString() or Vector3.ToString().

Parameters:
  • sVector (string) The vector as a string, each component's value being separated by a space.
Return value:
    (Vector3 or vector2) The vector.

string.trim( s )

Removes the white spaces at the beginning and the end of the provided string.

Parameters:
  • s (string) The string.
Return value:
    (string) The trimmed string.

string.trimend( s )

Removes the white spaces at the end of the provided string.

Parameters:
  • s (string) The string.
Return value:
    (string) The trimmed string.

string.trimstart( s )

Removes the white spaces at the beginning of the provided string.

Parameters:
  • s (string) The string.
Return value:
    (string) The trimmed string.

string.ucfirst( s )

Turn the first letter of the string uppercase.

Parameters:
  • s (string) The string.
Return value:
    (string) The string.

table.combine( keys, values )

Create an associative table with the provided keys and values tables.

Parameters:
  • keys (table) The keys of the future table.
  • values (table) The values of the future table.
Return value:
    (table or boolean) The combined table or false if the tables have different length.

table.containsvalue( t, value, ignoreCase )

Tell whether the provided value is found within the provided table.

Parameters:
  • t (table) The table to search in.
  • value (mixed) The value to search for.
  • ignoreCase (boolean) [default=false] Ignore the case of the value. If true, the value must be of type 'string'.
Return value:
    (boolean) True if the value is found in the table, false otherwise.

table.copy( t, recursive )

Return a copy of the provided table.

Parameters:
  • t (table) The table to copy.
  • recursive (boolean) [default=false] Tell whether to also copy the tables found as value (true), or just leave the same table as value (false).
Return value:
    (table) The copied table.

table.getkey( t, value )

Get the key associated with the first occurrence of the provided value.

Parameters:
  • t (table) The table.
  • value (mixed) The value.
Return value:
    (mixed) The value's key or nil if the value is not found.

table.getkeys( t )

Return all the keys of the provided table.

Parameters:
  • t (table) The table.
Return value:
    (table) The keys.

table.getlength( t, keyType )

Returns the length of a table, which is the numbers of keys of the provided type (or of any type), for which the value is not nil.

Parameters:
  • t (table) The table.
  • keyType (string) [optional] Any Lua or CraftStudio type ('string', 'GameObject', ...), case insensitive.
Return value:
    (number) The table length.

table.getvalue( t, keys )

Safely search several levels down inside nested tables. Just returns nil if the series of keys does not leads to a value.
Can also be used to check if a global variable exists if the table is _G.
Ie for this series of nested table : table1.table2.table3.fooBar
table.getvalue( table1, "table2.table3.fooBar" ) would return the value of the 'fooBar' key in the 'table3' table
table.getvalue( table1, "table2.table3" ) would return the value of 'table3'
table.getvalue( table1, "table2.table3.Foo" ) would return nil because the 'table3' has no 'Foo' key
table.getvalue( table1, "table2.Foo.Bar.Lorem.Ipsum" ) idem


Parameters:
  • t (table) The table.
  • keys (string) The chain of keys to looks for as a string, each keys separated by a dot.
Return value:
    (mixed) The value, or nil.

table.getvalues( t )

Return all the values of the provided table.

Parameters:
  • t (table) The table.
Return value:
    (table) The values.

table.havesamecontent( table1, table2 )

Compare table1 and table2. Returns true if they have the exact same keys which have the exact same values.

Parameters:
  • table1 (table) The first table to compare.
  • table2 (table) The second table to compare to the first table.
Return value:
    (boolean) True if the two tables have the exact same content.

table.insertonce( t, index, value )

Insert the provided value at the end of the provided table (or at the provided index) but only if the value is not already found in the table.

Parameters:
  • t (table) The table.
  • index (number) [optional] The index at which to insert the value.
  • value (mixed) The value to insert.
Return value:
    (boolean) Whether the value has been inserted (true) or not (false).

table.isarray( t, strict )

Tell whether he provided table is an array (has only integer keys). Decimal numbers with only zeros after the coma are considered as integers.

Parameters:
  • t (table) The table.
  • strict (boolean) [default=true] When false, the function returns true when the table only has integer keys. When true, the function returns true when the table only has integer keys in a single and continuous set.
Return value:
    (boolean) True or false.

table.merge( ..., recursive )

Merge two or more tables into one new table. Table as values with a metatable are considered as instances and are not recursively merged. When the tables are arrays, the integer keys are not overridden.

Parameters:
  • ... (table) Two or more tables
  • recursive (boolean) [default=false] Tell whether tables as values must be merged recursively. Has no effect when the tables are arrays.
Return value:
    (table) The new table.

table.mergein( ..., recursive )

Merge two or more tables in place, into the first provided table. Table as values with a metatable are considered as instances and are not recursively merged. When the tables are arrays, the integer keys are not overridden.

Parameters:
  • ... (table) Two or more tables
  • recursive (boolean) [default=false] Tell whether tables as values must be merged recursively. Has no effect when the tables are arrays.
Return value:
    (table) The first provided table.

table.print( t )

Print all key/value pairs within the provided table.

Parameters:
  • t (table) The table to print.

table.printr( t, maxLevel, reprint, currentLevel )

Recursively print all key/value pairs within the provided table. Fully prints the tables that have no metatable found as values.

Parameters:
  • t (table) The table to print.
  • maxLevel (number) [default=10] The max recursive level. Clamped between 1 and 10.
  • reprint (boolean) [default=false] Tell whether to print again the content of already printed table. If false a message "Already printed table with key" will be displayed as the table's value. /!\ See above for warning when maxLevel argument is -1.
  • currentLevel (number) [default=1] Should only be set when called recursively.

table.reindex( t )

Turn the provided table (with only integer keys) in a proper sequence (with consecutive integer key beginning at 1).

Parameters:
  • t (table) The table.
Return value:
    (table) The sequence.

table.removevalue( t, value, maxRemoveCount )

Remove the provided value from the provided table. If the index of the value is an integer, the value is nicely removed with table.remove(). /!\ Do not use this function on tables which have integer keys but that are not arrays (whose keys are not contiguous). /!\

Parameters:
  • t (table) The table.
  • value (mixed) The value to remove.
  • maxRemoveCount (number) [optional] Maximum number of occurrences of the value to be removed. If nil : remove all occurrences.
Return value:
    (number) The number of occurrence removed.

table.reverse( t )

Reverse the order of the provided table's values.

Parameters:
  • t (table) The table.
Return value:
    (table) The new table.

table.setvalue( t, keys, value )

Safely set a value several levels down inside nested tables. Creates the missing levels if the series of keys is incomplete.
Ie for this series of nested table : table1.table2.fooBar
table.setvalue( table1, "table2.fooBar", true ) would set true as the value of the 'fooBar' key in the 'table1.table2' table. if table2 does not exists, it is created


Parameters:
  • t (table) The table.
  • keys (string) The chain of keys to looks for as a string, each keys separated by a dot.
  • value (mixed) The value (nil is ok).

table.shift( t, returnKey )

Remove and returns the first value found in the table. Works for arrays as well as associative tables.

Parameters:
  • t (table) The table.
  • returnKey (boolean) [default=false] If true, return the key and the value instead of just the value.
Return value:
    (mixed) The value, or the key and the value (if the returnKey argument is true), or nil.

table.sortby( t, property, orderBy )

Sort a list of table using one of the tables property as criteria.

Parameters:
  • t (table) The table.
  • property (string) The property used as criteria to sort the table.
  • orderBy (string) [default="asc"] How the sort should be made. Can be "asc" or "desc". Asc means small values first.
Return value:
    (table) The ordered table.

tonumber2( data )

A more flexible version of tonumber(). Returns the first continuous series of numbers found in the text version of the provided data even if it is prefixed or suffied by other characters.

Parameters:
  • data (mixed) The data to be converted to number. Usually of type number, string or userdata.
Return value:
    (number) The number, or nil.