API Docs

Version: 0.7.65.79976
Back to top
Globals
Functions
IsInSchedule bool IsInSchedule()
Wait number Wait(number time) Wait for at least given time interval in seconds then resume execution, and return the exact time taken which is = Time seconds. Only valid within a Schedule function
Wait number Wait() Wait a single frame then resume execution, and return the time taken. Only valid within a Schedule function. Within a Schedule function this is how you implement a loop to make something happen every frame and give you a delta of time between the frames for smooth animation.
print print( varArgs) Standard print function (same as Print), takes a comma separated list of arguments and prints out their string representation.
Print Print( varArgs) Standard print function (same as print), takes a comma separated list of arguments and prints out their string representation.
printf printf(string format, varArgs) This print function replaces instances of {1} with the first argument passed in, {2} with the second etc (same as Printf).
Printf Printf(string format, varArgs) This print function replaces instances of {1} with the first argument passed in, {2} with the second etc (same as printf).
FormatString string FormatString(string format, varArgs) Format a string using either {1}, {2}, etc or using named variables.
ScreenPrint ScreenPrint( varArgs) Unsupported
GetWorld World GetWorld() Get the World object
IsClient bool IsClient() Return true if this script is running on the client
IsServer bool IsServer() Return true if this script is running on the server
Back to top
math
Functions
lerp number math.lerp(number a, number b, number alpha)
sign number math.sign(number value)
copysign number math.copysign(number value, number sign)
clamp number math.clamp(number value, number min, number max)
Back to top
Analytics
Functions
SendTelemetry Analytics.SendTelemetry(Entity entity, string type, table parametersTable)
SendTelemetry Analytics.SendTelemetry(string type, table parametersTable)
MatchStarted Handle Analytics.MatchStarted() When a match is started. It is up to the game to define what a match is. Returns a handle that can be used to end the match
MatchEnded Analytics.MatchEnded(Handle matchHandle) When a match has ended.
MatchEnded Analytics.MatchEnded(Handle matchHandle, table userEntriesTable) When a match has ended, also takes a table with an entry per user with a ‘user’ and ‘rank’ value
Attacked Analytics.Attacked(Entity attacker, Entity victim)
Attacked Analytics.Attacked(Entity attacker, Entity victim, Entity weapon)
Defeated Analytics.Defeated(Entity attacker, Entity victim) When a player or entity is defeated.
PlayerHealthCritical Analytics.PlayerHealthCritical(Entity playerOrUser) When a players health is critically low.
Back to top
Asset
Functions
GetName string asset:GetName()
GetIcon string asset:GetIcon()
Back to top
VoxelAsset
Back to top
Template
Functions
FindScriptProperty object templateAsset:FindScriptProperty(string propertyName)
FindScriptProperties Properties templateAsset:FindScriptProperties(string scriptName)
FindScriptProperties Properties templateAsset:FindScriptProperties(ScriptAsset script)
FindAllScriptProperties table templateAsset:FindAllScriptProperties(string scriptName)
FindAllScriptProperties table templateAsset:FindAllScriptProperties(ScriptAsset script)
Back to top
MeshAsset
Back to top
EffectAsset
Back to top
SoundAsset
Back to top
GripAsset
Back to top
VoxelMeshAsset
Back to top
PostProcessAsset
Back to top
ColorGradingAsset
Back to top
SkydomeAsset
Back to top
InnerHorizonAsset
Back to top
OuterHorizonAsset
Back to top
SkyMeshAsset
Back to top
WorldAsset
Back to top
ScriptAsset
Back to top
WidgetAsset
Back to top
VibrationEffectAsset
Back to top
Camera
Camera is a physical entity which provides a camera that a User can set with SetCamera. Camera derives from Entity so if you have a Camera you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Camera) to see if a particular entity variable is a Camera type entity.
Functions
RevertClientProperty camera:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
Overrides
index object camera.var
Back to top
Character
A Character is a type of Entity which provides additional features for a humanoid character model in the game. A Character can be controlled by a User. To get one from a User do user:GetPlayer(). Character derives from Entity so if you have a Character you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Character) to see if a particular entity variable is a Character type entity.
Functions
RevertClientProperty character:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
Attach characterToAttachTo:Attach(Entity entityToAttach, string socketName) DEPRECATED Server Attach an entity to this character using the given socketName (this is deprecated and will be removed, do entity:AttachTo(characterToAttachTo, socketName))
GetUser User character:GetUser() Get the User entity which controls this Character
SetAlive character:SetAlive(bool alive) Server For a Player set it to be alive (true) or dead (false).
IsAlive bool character:IsAlive() Get whether a Player is alive. Return false for non-Player.
GetLookAtPos Vector character:GetLookAtPos() Server Local Get the point the player is looking at, for an action camera this is the same as User:GetCameraLookAtPos but for orbit style cameras it will be in front of the player
GetLookAt Vector,Vector character:GetLookAt() Server Local Return two values, the position of the player’s virtual “eye” and the position the player is looking at. For an action camera this is the same as User:GetCameraLookAt but for an orbit style camera it will be the player’s head position and what is in front of the player.
SetInputLocked character:SetInputLocked(bool inputLocked) Server Local Lock player control
SetGrip character:SetGrip(GripAsset gripPresetAsset) Set the current grip animations used by this player. Passing nil is the same as calling SetNoGrip()
SetNoGrip character:SetNoGrip() Reverts the player back to the default ‘unarmed’ animations. Can also be achieved by calling SetGrip(nil)
PlayAction character:PlayAction(string actionName, table properties) Play an animation action, with properties specifying how it should be played
PlayAction character:PlayAction(string actionName) Play an animation action with default properties
HasAction bool character:HasAction(string actionName) Returns true if the current grip can perform this type of action
GetActions table character:GetActions() Get the name of every available action for this grip type
GetActionEvents table character:GetActionEvents(string actionName) Get the name of every event available event for an action
HasActionEvent bool character:HasActionEvent(string actionName, string eventName) Returns true if this action has an animation event of the specified name
GetPlayLength number character:GetPlayLength(string actionName) Returns the length of an animation, in seconds, assuming a playbackSpeed of 1 is set
HasActionEvent bool character:HasActionEvent(string actionName, string eventName) Returns true if an action is currently in progress
Launch character:Launch(Vector impulse) Launch the character
GetInteraction Entity,HitResult character:GetInteraction() Server Local Get whichever Entity you would interact with if you pressed interact
PlayVibrationEffect character:PlayVibrationEffect(VibrationEffectAsset vibrationEffect)
PlayManualVibration character:PlayManualVibration(number intensity, number duration, bool affectSmallMotors, bool affectLargeMotors)
Variables
speedMultiplier number speedMultiplier Multiplier on movement speed (default is 1.0)
jumpHeightMultiplier number jumpHeightMultiplier Multiplier on jump height (default is 1.0)
canSprint bool canSprint Turn on or off ability to sprint
canJump bool canJump Turn on or off ability to jump
displayDefaultNameTag bool displayDefaultNameTag Turn on or off the default name tag
displayDefaultQuickChat bool displayDefaultQuickChat Turn on or off the default overhead quick chat
canCrouch bool canCrouch Turn on or off ability to crouch or go prone
interactionRange number interactionRange Interaction range (from camera in cm)
cameraType number cameraType Set the character camera type. 1 = Action, 2 = Orbit
forcedCameraPerspective number forcedCameraPerspective Set restrictions on the action player camera perspective. 1 = No Restrictions, 2 = 1st Person Only, 3 = 3rd Person Only. (Default is 1)
canIronSight bool canIronSight Will the action camera iron-sight on secondary press
thirdPersonFOV number thirdPersonFOV FOV of the third person action camera
thirdPersonIronSightFOV number thirdPersonIronSightFOV FOV of the third person action camera in Iron Sight mode
firstPersonFOV number firstPersonFOV FOV of the third person action camera
firstPersonIronSightFOV number firstPersonIronSightFOV FOV of the third person action camera in Iron Sight mode
ironSightLookSpeedMultiplier number ironSightLookSpeedMultiplier Speed multiplier of the look controls in Iron Sight mode
cameraDistance number cameraDistance Set the orbit camera max distance from the character
cameraPitch number cameraPitch Set the orbit camera’s pitch
cameraYaw number cameraYaw Set the orbit camera’s yaw
cameraLock bool cameraLock Lock/Unlock the orbit camera
cameraCollisionEnabled bool cameraCollisionEnabled Enable/Disable the camera’s collision
damageEnabled bool damageEnabled Turn on or off damage (ie calling of entry point OnDamaged).
Overrides
index object character.var Get a script or widget from the Player Entity by name. This is exactly the same as entity.var.
Back to top
Color
Functions
New Color.New(number red, number green, number blue, number alpha)
New Color.New(number red, number green, number blue)
Variables
red number red
green number green
blue number blue
alpha number alpha
Overrides
to_string string tostring(Color var)
Back to top
Effect
An Entity can have a single physical representation. ParticleSystem can be turned on and off with active (which is distinct to entity visible flag). Effect derives from Entity so if you have a Effect you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Effect) to see if a particular entity variable is a Effect type entity.
Functions
RevertClientProperty effect:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
Variables
active bool active Set whether the particle system is emitting particles or not.
effect EffectAsset effect EffectAsset on this entity
Overrides
index object effect.var
Back to top
Entity
Entity is a physical item in the world, viewable in the world tree when editing the game. Entities contain any number of scripts and widgets, and can have a maximum of 1 “physical” component (mesh, light). Additionally there are two special types that derive from Entity (Player and User).
Functions
IsValid bool entityOrNill:IsValid()
IsA bool entity:IsA(table derivedType)
GetName string entity:GetName() Get the name of this Entity.
GetWorld World entity:GetWorld() DEPRECATED Get the World from an Entity (currently all entities in a game exist within the same World).
RevertClientProperty entity:RevertClientProperty(string propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
SetPosition entity:SetPosition(Vector position) Set the position of this Entity in 3D space.
AlterPosition number entity:AlterPosition(Vector position, number time) Move from current to position over time.
AlterPosition number entity:AlterPosition(Vector fromPosition, Vector toPosition, number time) Move from fromPosition to toPosition over time.
GetPosition Vector entity:GetPosition() Get the position of this Entity.
SetRotation entity:SetRotation(Rotation rotation) Set the rotation of this Entity.
AlterRotation number entity:AlterRotation(Rotation rotation, number time) Rotate from current to rotation over time.
AlterRotation number entity:AlterRotation(Rotation fromRotation, Rotation toRotation, number time) Rotate from fromRotation to toRotation over time.
GetRotation Rotation entity:GetRotation() Get the rotation of this Entity.
SetRelativePosition entity:SetRelativePosition(Vector position) Set the position of this Entity relative to whatever this entity is parented to.
AlterRelativePosition number entity:AlterRelativePosition(Vector position, number time) Move from current to position over time relative to whatever this entity is parented to.
AlterRelativePosition number entity:AlterRelativePosition(Vector fromPosition, Vector toPosition, number time) Move from fromPosition to toPosition over time relative to whatever this entity is parented to.
GetRelativePosition Vector entity:GetRelativePosition() Get the position of this Entity relative to whatever this entity is parented to.
SetRelativeRotation entity:SetRelativeRotation(Rotation rotation) Set the rotation of this Entity relative to whatever this entity is parented to.
AlterRelativeRotation number entity:AlterRelativeRotation(Rotation rotation, number time) Rotate from current to rotation over time relative to whatever this entity is parented to.
AlterRelativeRotation number entity:AlterRelativeRotation(Rotation fromRotation, Rotation toRotation, number time) Rotate from fromRotation to toRotation over time relative to whatever this entity is parented to.
GetRelativeRotation Rotation entity:GetRelativeRotation() Get the rotation of this Entity relative to whatever this entity is parented to.
GetForward Vector entity:GetForward() Get the forward facing vector of an Entity from its rotation.
SetForward entity:SetForward(Vector forward) Set the rotation of an Entity to make its front face in a given direction.
SetForward entity:SetForward(Vector forward, Vector up) Set the rotation of an Entity to make its front face in a given direction, and its top point in another.
PlaySound Handle entity:PlaySound(SoundAsset sound) Play a sound Asset on this Entity, returning a Handle which can be used to stop the sound.
PlaySound Handle entity:PlaySound(SoundAsset sound, number fadeIn) Play a sound Asset on this Entity, returning a Handle which can be used to stop the sound. Fades in over the given fadeIn time.
PlaySound2D Handle entity:PlaySound2D(SoundAsset sound) Play a sound Asset on this Entity but without a 3D transform on the sound (useful for UI sounds, stereo music stings, etc).
PlaySound2D Handle entity:PlaySound2D(SoundAsset sound, number fadeIn) Play a sound Asset on this Entity but without a 3D transform on the sound (useful for UI sounds, stereo music stings, etc). Fades in over the given fadeIn time.
PlaySoundAtLocation Handle entity:PlaySoundAtLocation(Vector location, SoundAsset sound) Play a sound Asset on this Entity at the given location.
PlaySoundAtLocation Handle entity:PlaySoundAtLocation(Vector location, SoundAsset sound, number fadeIn) Play a sound Asset on this Entity at the given location. Fades in over the given fadeIn time.
StopSound entity:StopSound(Handle soundHandle) Given a sound Handle stop the sound on this Entity.
StopSound entity:StopSound(Handle soundHandle, number fadeOut) Given a sound Handle stop the sound on this Entity. Fade the sound out over the given fadeOut time.
PlayEffect Handle entity:PlayEffect(EffectAsset effect) Play a particle effect Asset on this Entity, returning a Handle which can be used to stop the effect.
PlayEffect Handle entity:PlayEffect(EffectAsset effect, bool attached) Play a particle effect Asset on this Entity, returning a Handle which can be used to stop the effect. Optionally the effect is attached to the entity and so all spawned particles are relative to it.
PlayEffectAtLocation Handle entity:PlayEffectAtLocation(Vector location, Rotation rotation, EffectAsset effect) Play a particle effect Asset at a given world location and rotation, returning a Handle which can be used to stop the effect.
PlayEffectAtLocation Handle entity:PlayEffectAtLocation(Vector location, Rotation rotation, EffectAsset effect, bool attached) Play a particle effect Asset at a given world location and rotation, returning a Handle which can be used to stop the effect. Optionally the effect is attached to the entity and so all spawned particles are relative to it.
StopEffect entity:StopEffect(Handle effectHandle)
Clone Entity entity:Clone() Server Clone the Entity returning the clone.
AttachTo entity:AttachTo(Entity entityToAttachTo) Server Attach this Entity to another Entity
AttachTo entity:AttachTo(Character characterToAttachTo, string socketName) Server Attach this Entity to a Character entity, using the named socket
Detach entity:Detach()
ApplyDamage entity:ApplyDamage(number damageAmount, HitResult hitResult, Vector shootDirection, Entity fromEntity) Apply damageAmount damage to the Entity (by calling OnDamage on it on any scripts that override that), also pass a HitResult from a World Raycast function and a shootDirection Vector and fromEntity which will be passed to the OnDamage function.
ApplyDamage entity:ApplyDamage(number damageAmount, HitResult hitResult, Vector shootDirection, Entity fromEntity, table damageModifiers) Apply damageAmount damage to the Entity (by calling OnDamage on it on any scripts that override that), also pass a HitResult from a World Raycast function and a shootDirection Vector and fromEntity which will be passed to the OnDamage function. Takes a damage modifier table in the form of: damageModifiers = {} damageModifiers[VoxelAsset] = {DamageMultiplier= DamageMultiplier}
ApplyDamage entity:ApplyDamage(number damageAmount, Vector shootDirection, Entity fromEntity) Apply damageAmount damage to the Entity (by calling OnDamage on it on any scripts that override that), also pass a shootDirection Vector and fromEntity which will be passed to the OnDamage function.
ApplyDamage entity:ApplyDamage(number damageAmount, Vector shootDirection, Entity fromEntity, table damageModifiers) Apply damageAmount damage to the Entity (by calling OnDamage on it on any scripts that override that), also pass a shootDirection Vector and fromEntity which will be passed to the OnDamage function. Takes a damage modifier table in the form of: damageModifiers = {} damageModifiers[VoxelAsset] = {DamageMultiplier= DamageMultiplier}
GetParent Entity entity:GetParent() Get a parent Entity that this Entity is attached to either within the world tree or using the Attach function.
GetChildren table entity:GetChildren() Get all children directly below this. The order of children is not guaranteed, and may change randomly.
Destroy entity:Destroy() Server Destroy an Entity. Use with care as any variables referencing that Entity will now be invalid.
SendToScripts entity:SendToScripts(string eventName, args) Call eventName function with the given args on all scripts that have it as a function. If called on the server do it only on the server, if called on a client do it only on that client.
SendToAllClients entity:SendToAllClients(string eventName, args) Server Call eventName on all scripts of this Entity on all clients connected to the server with the given args.
SendToServer entity:SendToServer(string eventName, args) Local Call eventName on all script of this Entity on the server.
SendToLocal entity:SendToLocal(string eventName, args) Server Call eventName on all scripts of this Entity on the client that owns the Player or User this script is attached to.
IsLocal bool entity:IsLocal() Local See if this Entity is owned by the local client.
IsClient bool entity:IsClient() DEPRECATED Check if this Entity is on the client
FindScript Script entity:FindScript(string scriptName) This is alternative to entity.scriptName which is the preferred way of getting a script.
FindScript Script entity:FindScript(string scriptName, bool recursive) This is alternative to entity.scriptName which is the preferred way of getting a script. This can be recursive to find the script on any child entities.
FindScript Script entity:FindScript(ScriptAsset script) Find a script by its script asset.
FindScript Script entity:FindScript(ScriptAsset script, bool recursive) Find a script by its script asset. This can be recursive to find the script on any child entities.
FindScriptProperty object entity:FindScriptProperty(string propertyName) Find a script with the named property on it and return value from the property
FindAllScripts table entity:FindAllScripts(string scriptName) Find all scripts named scriptName recursively on this entity and all child entities. Most often used where multiple scripts are used to simulate an array of structures.
FindAllScripts table entity:FindAllScripts(ScriptAsset script) Find all scripts of the given script asset recursively on this entity and all child entities. Most often used where multiple scripts are used to simulate an array of structures.
FindWidget Widget entity:FindWidget(string widgetName) This is alternative to entity.widgetName which is the preferred way of getting a widget.
FindWidget Widget entity:FindWidget(string widgetName, bool recursive) This is alternative to entity.widgetName which is the preferred way of getting a widget. This can be recursive to find the widget on any child entities.
FindWidget Widget entity:FindWidget(WidgetAsset widget) Find a widget by its widget asset.
FindWidget Widget entity:FindWidget(WidgetAsset widget, bool recursive) Find a widget by its widget asset. This can be recursive to find the widget on any child entities.
IsLocalReady bool entity:IsLocalReady() Server When called with an Entity that is owned by a particular client this sees if that Entity has been inited on that client (by calling LocalInit).
SendTelemetry entity:SendTelemetry(string type, table parametersTable) DEPRECATED Send an type of telemetry event to the telemetry server with the given parametersTable for later analysis. Deprecated and will be removed – see Analytics.SendTelemetry
PlayTimeline number entity:PlayTimeline(table timelineArray) Play a timeline from an array of values (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayTimeline number entity:PlayTimeline( args) Play a timeline from variable args (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayTimelineLoop entity:PlayTimelineLoop(table timelineArray) Loop a timeline from an array of values (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayTimelineLoop entity:PlayTimelineLoop( args) Loop a timeline from variable args (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayTimelinePingPong entity:PlayTimelinePingPong(table timelineArray) Loop a timeline back and forth from an array of values (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayTimelinePingPong entity:PlayTimelinePingPong( args) Loop a timeline back and forth Play a timeline from variable args (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayRelativeTimeline number entity:PlayRelativeTimeline(table timelineArray) Play a timeline, relative to an entity’s parent transform, from an array of values (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayRelativeTimeline number entity:PlayRelativeTimeline( args) Play a timeline, relative to an entity’s parent transform, from variable args (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayRelativeTimelineLoop number entity:PlayRelativeTimelineLoop(table timelineArray) Loop a timeline, relative to an entity’s parent transform, from an array of values (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayRelativeTimelineLoop number entity:PlayRelativeTimelineLoop( args) Loop a timeline, relative to an entity’s parent transform, from variable args (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayRelativeTimelinePingPong number entity:PlayRelativeTimelinePingPong(table timelineArray) Loop a timeline back and forth, relative to an entity’s parent transform, from an array of values (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
PlayRelativeTimelinePingPong number entity:PlayRelativeTimelinePingPong( args) Loop a timeline back and forth, relative to an entity’s parent transform, from variable args (each key on the timeline is a number for time in seconds followed by a Vector for absolute position and/or a Rotation).
CancelTimeline entity:CancelTimeline() Cancel any running timelines
GetTemplate Template entity:GetTemplate() Given an entity, get the Template it is an instance of (if there is one). Warning – this will return the template even if lots of things have been adjusted on the instance.
GetVelocity Vector entity:GetVelocity() Get Velocity. Centimeters per second.
SetVelocity unknown entity:SetVelocity(Vector velocity) Set Velocity. Centimeters per second.
GetAngularVelocity Rotation entity:GetAngularVelocity() Get AngularVelocity. Degrees per second.
SetAngularVelocity unknown entity:SetAngularVelocity(Rotation angularVelocity) Set AngularVelocity. Degrees per second.
Variables
visible bool visible Set whether any physical aspect of the Entity (generally a mesh or a light) is visible within the world.
onInteract Event onInteract Called when this entity is interacted with by a player, with the player Character and the HitResult passed as arguments, as well as the Entity from which the onInteract event was sent. An alternative to listening for OnInteract in a script on the entity.
onDestroy Event onDestroy Called when this entity is destroyed, with the Entity which sent the event passed as an argument. An alternative to listening for OnDestroy in a script on the entity.
Overrides
index object entity.var Get a script or widget from the Entity by name, or a mesh, light, etc component on this entity. ie entity.myScript returns a script called myScript, entity.theHud returns a widget named theHud, entity.mesh returns the Mesh of this Entity, entity.light returns the property bag for a light component…
Back to top
Event
Functions
Send eventProperty:Send( varArgs)
Listen eventProperty:Listen(Script listenerScriptComponent, string functionName)
HasBindings bool eventProperty:HasBindings( varArgs) Return true if this Event is bound to anything, even if its something like “every instance of a script” which would actually resolve to no bindings.
GetAllBindings table eventProperty:GetAllBindings( varArgs) Get a table where each element is a table containing a ‘script’ variable and a ‘function’ variable, describing each call that is bound by this event.
Overrides
to_string string tostring(Event var)
Back to top
Handle
Overrides
to_string string tostring(Handle var)
Back to top
HitResult
A HitResult is used by the World Raycast function to give details about where the collision happened (GetPosition) and what the normal vector of the collision is (GetNormal).
Functions
GetPosition Vector hitResult:GetPosition() Get position of hit in world space
GetRelativePosition Vector hitResult:GetRelativePosition() Get position of hit relative to the Entity hit
GetNormal Vector hitResult:GetNormal() Get normal direction of hit in world space
GetRelativeNormal Vector hitResult:GetRelativeNormal() Get normal direction of the hit relative to the rotation of the Entity hit
Back to top
Leaderboards
Functions
GetNearbyValues Leaderboards.GetNearbyValues(string leaderboardName, number numValues, User user, callback callback) Gets nearby leaderboard values on the specified leaderboard for the specified user, centered on the user where possible. Results are returned as a parameter to the callback function. Callback function parameter is a table of results, each result contains name, score, rank & icon
GetTopValues Leaderboards.GetTopValues(string leaderboardName, number numValues, callback callback) Gets the top ranking values from the specified leaderboard. Results are returned as a parameter to the callback function. Callback function parameter is a table of results, each result contains name, score, rank & icon
GetMetadata Leaderboards.GetMetadata(callback callback) DEPRECATED See Leaderboards.GetAllMetadata Gets the metadata of every leaderboard associated with this game. Results are as a parameter to the callback function. Callback function parameter is a table of results, each result contains name, displayName, displayIndex, resetTime, isPeriodic, isAscending & type.
GetMetadata Leaderboards.GetMetadata(string leaderboardName, callback callback) Gets the metadata of a single named leaderboard for this game. Results are as a parameter to the callback function. Callback function parameter is a table containing name, displayName, displayIndex, resetTime, isPeriodic, isAscending & type.
GetAllMetadata Leaderboards.GetAllMetadata(callback callback)
GetNearbyValuesForGame Leaderboards.GetNearbyValuesForGame(string gameId, string leaderboardName, number numValues, User user, callback callback) Gets nearby leaderboard values for the specified GameId. Results are returned as a parameter to the callback function. Callback function parameter is a table of results, each result contains name, score, rank & icon
GetTopValuesForGame Leaderboards.GetTopValuesForGame(string gameId, string leaderboardName, number numValues, callback callback) Gets the top ranking values for the specified GameId Results are returned as a parameter to the callback function. Callback function parameter is a table of results, each result contains name, score, rank & icon
GetMetadataForGame Leaderboards.GetMetadataForGame(string gameId, callback callback) DEPRECATED See Leaderboards.GetAllMetadataForGame Gets the metadata of every leaderboard associated with the specified GameId. Results are as a parameter to the callback function. Callback function parameter is a table of results, each result contains name, displayName, displayIndex, resetTime, isPeriodic, isAscending & type.
GetMetadataForGame Leaderboards.GetMetadataForGame(string gameId, string leaderboardName, callback callback) Gets the metadata of a single named leaderboard associated with the specified GameId. Results are as a parameter to the callback function. Callback function parameter is a table containing name, displayName, displayIndex, resetTime, isPeriodic, isAscending & type.
GetAllMetadataForGame Leaderboards.GetAllMetadataForGame(string gameId, callback callback) Gets the metadata of every leaderboard associated with the specified GameId. Results are as a parameter to the callback function. Callback function parameter is a table of results, each result contains name, displayName, displayIndex, resetTime, isPeriodic, isAscending & type.
Back to top
Light
An Entity can have a single physical representation. Light is used to represent either a point or spot source of light in the scene. It can change color, intensity and other settings. Light derives from Entity so if you have a Light you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Light) to see if a particular entity variable is a Light type entity.
Functions
RevertClientProperty light:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
Variables
color Color color Set color of light.
intensity number intensity Set intensity of light (units?)
innerAngle number innerAngle Set inner angle of a spot light (units?)
outerAngle number outerAngle Set outer angle of a spot light (units?)
attenuation number attenuation Set attenuation of the light (units?)
Overrides
index object light.var
Back to top
Locator
Locator is a physical entity which doesn’t render anything but can have its position and rotation queried. It can be used as a start location for spawning (see SpawnPlayer) Locator derives from Entity so if you have a Locator you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Locator) to see if a particular entity variable is a Locator type entity.
Functions
RevertClientProperty locator:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
Overrides
index object locator.var
Back to top
Vector
Vector
Functions
New Vector Vector.New(number x, number y, number z) Construct a new Vector with the given x, y and z components, where z is generally up.
Normalize Vector vec:Normalize() Return a normalized Vector (where the length is 1.0)
Length number vec:Length() Return the length of the given Vector.
SquaredLength number vec:SquaredLength() Return the square of the length of the given Vector.
Distance number Vector.Distance(Vector vec1, Vector vec2) Return the distance between two Vector values.
SquaredDistance number Vector.SquaredDistance(Vector vec1, Vector vec2) Return the square of the distance of two Vector values.
Cross Vector Vector.Cross(Vector vec1, Vector vec2) Return the cross product of two Vector values.
Dot number Vector.Dot(Vector vec1, Vector vec2) Return the dot product of two Vector values.
Lerp Vector Vector.Lerp(Vector vec1, Vector vec2, number alpha) Linearly interpolate between vec1 and vec2 by the fraction alpha, where alpha is normally in the range [0,1]
Abs Vector vec:Abs() Return a Vector constructed from the absolute (ie positive or zero) x, y and z components of the given Vector.
Ceil Vector vec:Ceil() Returns a Vector constructed from the ceiling (ie next integer value) x, y and z components of the given Vector.
Floor Vector vec:Floor() Returns a Vector constructed from the floor (ie integer value below) x, y and z components of the given Vector.
Variables
x float x X component of 3D vector
y float y Y component of 3D vector
z float z Z component of 3D vector
Constants
Zero Vector Vector.Zero Zero vector (0, 0, 0)
Overrides
addition operator + Add two Vector values together and return a new Vector of the result
subtraction operator – Subtract two Vector values and return a new Vector of the result
unary_minus unary_minus Negate a Vector value and return the result
multiplication operator *
division operator /
to_string string tostring(Vector var) Convert to a string
Back to top
Vector2D
Vector2D
Functions
New Vector2D Vector2D.New(number x, number y) Construct a new two dimensional Vector2D with the given x and y components.
Normalize Vector2D vec:Normalize()
Length number vec:Length()
SquaredLength number vec:SquaredLength()
Distance number Vector2D.Distance(Vector2D vec1, Vector2D vec2)
SquaredDistance number Vector2D.SquaredDistance(Vector2D vec1, Vector2D vec2)
Dot number Vector2D.Dot(Vector2D vec1, Vector2D vec2)
Lerp Vector2D Vector2D.Lerp(Vector2D vec1, Vector2D vec2, number alpha)
Abs Vector2D vec:Abs()
Ceil Vector2D vec:Ceil()
Floor Vector2D vec:Floor()
Variables
x float x X component of 2D vector
y float y Y component of 2D vector
Constants
Zero Vector Vector2D.Zero Zero vector (0, 0)
Overrides
addition operator +
subtraction operator –
unary_minus unary_minus
multiplication operator *
division operator /
to_string string tostring(Vector2D var)
Back to top
Rotation
Rotation
Functions
New Rotation Rotation.New(number pitch, number yaw, number roll)
FromVector Rotation Rotation.FromVector(Vector vector) Make a rotation from a vector
Lerp Rotation Rotation.Lerp(Rotation rot1, Rotation rot2, number alpha)
RotateVector Vector rotation:RotateVector(Vector vector) Rotate a given vector by a rotation.
UnrotateVector Vector rotation:UnrotateVector(Vector vector) Unrotate a given vector by this rotation – the opposite of Rotation.RotateVector.
Inverse Rotation rotation:Inverse() Get the inverse of this rotation.
Variables
pitch float pitch Pitch component of Rotation
yaw float yaw Yaw component of Rotation
roll float roll Roll component of Rotation
Constants
Zero Rotation Rotation.Zero Zero rotation on each axis (0, 0, 0)
Overrides
addition operator +
subtraction operator –
to_string string tostring(Rotation var)
Back to top
Mesh
An Entity can have a single physical representation. Mesh is for 3D objects that exist in the scene. They can be collided with and recieve damage when hit. Mesh derives from Entity so if you have a Mesh you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Mesh) to see if a particular entity variable is a Mesh type entity.
Functions
RevertClientProperty mesh:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
PlayAnimation mesh:PlayAnimation(string animationName) Play a named animation on this mesh, once.
PlayAnimation mesh:PlayAnimation(string animationName, bool looping) Unsupported Play a named animation on this mesh, optionally looping.
PlayAnimationLooping mesh:PlayAnimationLooping(string animationName) Play a named animation on this mesh, repeatedly.
PlayAnimationClient mesh:PlayAnimationClient(string animationName) Play a named animation on this mesh, once, for this client only
PlayAnimationClient mesh:PlayAnimationClient(string animationName, bool looping) Unsupported Play a named animation on this mesh, optionally looping, for this client only
PlayAnimationLoopingClient mesh:PlayAnimationLoopingClient(string animationName) Play a named animation on this mesh, repeatedly, for this client only
GetAnimationNames table mesh:GetAnimationNames() Get a table of animation names that you can play on this mesh with PlayAnimation.
CreateThruster Thruster mesh:CreateThruster() Add a thruster to an entity
CreateRelativeThruster Thruster mesh:CreateRelativeThruster()
DestroyThruster mesh:DestroyThruster(Thruster handle) Destroy a thruster
AddImpulse mesh:AddImpulse(Vector impulse) Add Impulse. An integral of force over a time interval. Newton seconds.
AddAngularImpulse mesh:AddAngularImpulse(Rotation angularImpulse) Add Angular Impulse. An integral of torque over a time interval. Newton seconds.
Variables
collisionEnabled bool collisionEnabled Turn on or off collision (ie calling entry point OnCollision).
damageEnabled bool damageEnabled Turn on or off damage (ie calling of entry point OnDamaged).
physicsEnabled bool physicsEnabled Turn on or off physics.
gravityEnabled bool gravityEnabled Turn on or off physics.
onCollision Event onCollision Called when this entity is collided with by a player Character with the Character passed as an argument, as well as the mesh Entity from which the onCollision event was triggered. An alternative to listening for OnCollision in a script on the entity.
onDamage Event onDamage Called when this entity is damaged with the amount of damage, the entity causing the damage and a HitResult structure, as well as the mesh Entity from which the onDamage event was sent. An alternative to listening for OnDamage in a script on the entity.
mesh mesh mesh Get or change the mesh
Overrides
index object mesh.var
Back to top
Thruster
Thruster
Functions
SetForce handle:SetForce(Vector force) Set the Force of the thruster, either in world space or relative space depending on the type of thruster.
SetTorque handle:SetTorque(Rotation torque) Set the torque, or rotation force, of the thruster.
SetPosition handle:SetPosition(Vector position) Set the position of the thruster. A force that is not applied at the center of mass will also apply some torque.
SetAutoDestroy handle:SetAutoDestroy(number lifeTime) When set the thruster will be destroyed after the lifetime is up.
SetIgnoreMass handle:SetIgnoreMass(bool ignoreMass) When true this will turn the force or torque in to accelerational changes, ignoring the mass of the object.
Back to top
Properties
The Properties structure holds the values that have been set on an instance of a script (accessed with self.properties and defined in the script by returning a Properties table within the script’s table).
Overrides
new_index properties.var = object value Set a named property to a new value
index object properties.var Get the value of a property
Back to top
PropertyArray
Overrides
new_index propertyArray.var = object value Set a array element to a new value
index object propertyArray.var Get the value of an array element
length length Get the length of the array
Back to top
Script
ScriptComponent is the base class for all user created scripts. Within a script function it is accessed through the self local variable.
Functions
GetProperties Properties scriptComponent:GetProperties() Alternative to self.properties, this gets the bag of values produced from the property editor for this script on this Entity. The properties are defined by the static Properties table on the table returned by the Lua script.
RevertClientProperty scriptComponent:RevertClientProperty(string propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
GetEntity Entity scriptComponent:GetEntity() Returns the Entity that the script is attached to.
ListenForEvent scriptComponent:ListenForEvent(string eventName, Script listenerScriptComponent) Tell this script that listenerScriptComponent wants to be informed when it sounds eventName using SendEventToListeners. eventName will be called on the listenerScriptComponent script.
ListenForEvent scriptComponent:ListenForEvent(string eventName, Script listenerScriptComponent, string functionName) Tell this script that listenerScriptComponent wants to be informed when it sounds eventName using SendEventToListeners. functionName will be called on the listenerScriptComponent script.
SendEventToListeners scriptComponent:SendEventToListeners(string eventName, args) Call eventName on any scripts that have registered for it using ListenForEvent with the given args. If called on the server do it only on the server, if called on a client do it only on that client.
Schedule Handle scriptComponent:Schedule(callback function) Pass this a function to do that function in a thread. Can use globals like Wait to control flow as the function will be re-entrant. Returns a Handle which can be passed to Cancel
Cancel scriptComponent:Cancel(Handle handle) Cancel a scheduled task if its running.
SetSaveData scriptComponent:SetSaveData(table saveTable) Server Set the save data for this script to the table supplied. The script must be owned by a User or Player.
GetSaveData scriptComponent:GetSaveData(callback callback) Server Get the save data previously written out with SetSaveData on this script. This function is asynchronous and will call the callback function when its finished with the save data as an argument.
SendToScript scriptComponent:SendToScript(string eventName, args) Call eventName on this script if it exists, with the given args.
SendToAllClients scriptComponent:SendToAllClients(string eventName, args) Server Call eventName on this script on all clients currently connected to the server with the given args. Note, this function call can not guarantee that entities are all in a ready state on the client at the time of call, and might therefore miss events during construction.
SendToServer scriptComponent:SendToServer(string eventName, args) Local Call eventName on this script on the server.
SendToLocal scriptComponent:SendToLocal(string eventName, args) Server Call eventName on this script on the client that owns the Player or User this script is attached to.
Script Entry Points
OnInteract function Script:OnInteract(Entity player, HitResult hitResult) … end Server Called when a player interacts with an entity on all scripts of the entity.
OnCollision function Script:OnCollision(Entity collidingPlayerOrEntity) … end Server Called when a player collides with an entity on all scripts of the entity. Also calls this function on the player’s scripts with the entity as the argument.
OnDamage function Script:OnDamage(number damageAmount, Entity damageCauser, HitResult hitResult) … end Server Called when an entity is damaged on all scripts of the entity. TODO: work out what gets passed in here for radial damage instead of the HitResult.
Init function Script:Init() … end Server Called to initialize a script on the server.
ClientInit function Script:ClientInit() … end Client Called to initialize a script on the client.
LocalInit function Script:LocalInit() … end Local Called to initialize a script on the client that controls this entity (eg player, user, etc…)
OnTick function Script:OnTick(number deltaTimeSeconds) … end Server Called each frame on the server.
ClientOnTick function Script:ClientOnTick(number deltaTimeSeconds) … end Client Called each frame on the client.
LocalOnTick function Script:LocalOnTick(number deltaTimeSeconds) … end Local Called each frame on the client that controls this entity (eg player, user, etc…)
OnUserLogin function Script:OnUserLogin(User user) … end Server Called when a new user joins the game.
OnUserLogout function Script:OnUserLogout(User user) … end Server Called when a new user leaves the game.
OnDeathPlaneTrigger function Script:OnDeathPlaneTrigger() … end Server Called by the game on a Player when the Player is below the death plane setting
OnTriggerEnter function Script:OnTriggerEnter(Entity other) … end Server Called by a trigger component when an entity enters the trigger volume
OnTriggerExit function Script:OnTriggerExit(Entity other) … end Server Called by a trigger component when an entity exits the trigger volume
OnButtonPressed function Script:OnButtonPressed(string buttonName) … end Server Called on player and user scripts when a particular button is pressed, giving the string name of the button
OnButtonReleased function Script:OnButtonReleased(string buttonName) … end Server Called on player and user scripts when a particular button is released, giving the string name of the button
OnIronSightStart function Script:OnIronSightStart() … end Server Called when the character goes in to Iron Sight mode
OnIronSightStop function Script:OnIronSightStop() … end Server Called when the character stops Iron Sight mode
OnSprintStart function Script:OnSprintStart() … end Server Called when the character starts sprinting
OnSprintStop function Script:OnSprintStop() … end Server Called when the character stops sprinting
OnCrouch function Script:OnCrouch() … end Server Called when the character crouches
OnStand function Script:OnStand() … end Server Called when the character stands from crouch
OnJump function Script:OnJump() … end Server Called on the player when a jump action happened
LocalOnButtonPressed function Script:LocalOnButtonPressed(string buttonName) … end Local Called locally on player and user scripts when a particular button is pressed, giving the string name of the button
LocalOnButtonReleased function Script:LocalOnButtonReleased(string buttonIndex) … end Local Called locally on player and user scripts when a particular button is released, giving the string name of the button
LocalOnIronSightStart function Script:LocalOnIronSightStart() … end Local Called when the character goes in to Iron Sight mode
LocalOnIronSightStop function Script:LocalOnIronSightStop() … end Local Called when the character stops Iron Sight mode
LocalOnSprintStart function Script:LocalOnSprintStart() … end Local Called when the character starts sprinting
LocalOnSprintStop function Script:LocalOnSprintStop() … end Local Called when the character stops sprinting
LocalOnCrouch function Script:LocalOnCrouch() … end Local Called when the character crouches
LocalOnStand function Script:LocalOnStand() … end Local Called when the character stands from crouch
LocalOnJump function Script:LocalOnJump() … end Local Called on the player when a jump action happened
OnHotbarChanged function Script:OnHotbarChanged(number hotbarIndex) … end Server Called on server when the user’s hotbar index changes, either by using the previous and next buttons or using the hotbar keys on a keyboard. Calls function on all user and player scripts.
OnChatMessage function Script:OnChatMessage() … end Called when a quick chat message is triggered by the user
OnChallengeUpdated function Script:OnChallengeUpdated() … end Called when a challenge has updated
OnDestroy function Script:OnDestroy() … end Called on the server when an entity is destroyed
Back to top
Sound
An Entity can have a single physical representation. Sound can be turned on and off with active (which is distinct to entity visible flag). Sound derives from Entity so if you have a Sound you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Sound) to see if a particular entity variable is a Sound type entity.
Functions
RevertClientProperty sound:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
Variables
active bool active Set whether the sound is playing or not.
sound SoundAsset sound Set the SoundAsset that this entity plays
volume number volume Set the volume of the sound (0 = Silent, 1 = Full volume)
pitch number pitch Set the pitch of the sound (1 = Default pitch, 0.125 = 8 times slower, 2 = 2 times faster)
Overrides
index object sound.var
Back to top
Text
Functions
Format Text format:Format( varArgs) Format a string using the passed in arguments list (in which case replaces {1} with the first one, {2} with the second, etc) or a table (in which case the string keys are replaced with their values). If run on the client this will localise all the Text values involved to the client language, if run on the server it will use the native language of each Text value.
Format Text Text.Format(string format, varArgs) Same as the normal Text:Format function but uses a Lua string as the format specifier, this is unwise as it means there is no opportunity to localize it.
FormatTime Text format:FormatTime(number time) Format a time into a Text value using the following expansions, {hh} – hour component of passed in time, {mm} – minute component of passed in time, {ss} – seconds component of passed in time, {ms} – milisecond component of passed in time. If run on the client the format Text variable will be localized to the client language, if run on the server it won’t.
FormatTime Text Text.FormatTime(string format, number time) Same as the normal Text:FormatTime function but uses a Lua string as the format specifier, this is unwise as it means there is no opportunity to localize it.
Overrides
to_string string tostring(Text var) Note: tostring() will lose any non-ASCII characters from the local version of the text
Back to top
Trigger
Trigger is an invisible volume that detects when entities enter and exit. Trigger derives from Entity so if you have a Trigger you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Trigger) to see if a particular entity variable is a Trigger type entity.
Functions
RevertClientProperty trigger:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
IsOverlapping bool triggerComponent:IsOverlapping(Entity entity) Returns whether a passed in entity is currently within the trigger
IsInside bool triggerComponent:IsInside(Vector worldPosition) Returns whether the point given (world space) is within the bounds of the trigger (whether the trigger is active or not)
Variables
playersOnly bool playersOnly Set whether the trigger should only overlap players or all entities.
size vector size The size of the trigger box
active boolean active The trigger box is active
interactable boolean interactable The trigger box is active
onTriggerEnter Event onTriggerEnter Called when this trigger volume is entered by a valid entity, with the Entity passed as an argument, as well as the trigger Entity from which the onTriggerEnter event is sent. An alternative to listening for OnTriggerEnter in a script on the entity.
onTriggerExit Event onTriggerExit Called when this trigger volume is exited by a valid entity, with the Entity passed as an argument, as well as the trigger Entity from which the onTriggerExit event is sent. An alternative to listening for OnTriggerExit in a script on the entity.
Overrides
index object trigger.var
Back to top
WidgetBindings
Functions
CallFunction widgetBindings:CallFunction(string function, args)
Overrides
new_index widgetBindings.var = object value
index object widgetBindings.var
Back to top
Widget
Functions
Show widget:Show()
Hide widget:Hide()
CallFunction widget:CallFunction(string function, args)
Variables
js WidgetBindings js
Overrides
index object widget.var
new_index widget.var = object value
Back to top
User
A User is a type of entity which provides information about a real person connected to the game. You can get all the User entities from the World (GetUsers or ForEachUser). You can also get a User from a Character (which gives the User who is controlling that Character). User derives from Entity so if you have a User you can do any of these functions as well as the functions in Entity. You can do entity:IsA(User) to see if a particular entity variable is a User type entity.
Functions
RevertClientProperty user:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
GetUsername Text user:GetUsername() Get the display name of the User.
GetPlayerCardIcon string user:GetPlayerCardIcon()
SpawnPlayer Character user:SpawnPlayer(Template playerTemplate) Server Spawn a player Entity for this User using the supplied template asset.
SpawnPlayer Character user:SpawnPlayer(Template playerTemplate, Locator locatorEntity) Server Spawn a player Entity for this User using the supplied template asset, at the position of the spawnPoint (which can be any Entity with a ‘playerstart’ component).
SpawnPlayer Character user:SpawnPlayer(Template playerTemplate, Vector position, Rotation rotation) Server Spawn a player Entity for this User using the supplied template asset, at the given position.
GetPlayer Entity user:GetPlayer() Get the Entity (if there is one) that has been spawned for the User. For now this is always a Character entity.
SetCamera user:SetCamera(Entity cameraEntity) Server Set camera view of this User to the given cameraEntity (which can be either a Camera entity or a Character entity).
SetCamera user:SetCamera(Entity cameraEntity, number transitionTime) Server Set camera view of this User to the given cameraEntity (which can be either a Camera entity or a Character entity). Transitions the camera over a given time from the previous one.
GetCamera Camera user:GetCamera()
GetCameraLookAtPos Vector user:GetCameraLookAtPos() Get the point the camera is looking at
GetCameraLookAt Vector,Vector user:GetCameraLookAt() Return two values, the position of the camera and a point the camera is facing at (where it collides with the scene).
LeaveGame user:LeaveGame() Server Local
LeaveGame user:LeaveGame(callback travelFailedCallback) Server
GoToGame user:GoToGame(string gameId) Server Local
GoToGame user:GoToGame(string gameId, callback travelFailedCallback) Server
GoToWorld user:GoToWorld(WorldAsset worldAsset) Server Local
GoToWorld user:GoToWorld(WorldAsset worldAsset, callback travelFailedCallback) Server
ShowCursor user:ShowCursor(bool showCursor) DEPRECATED Turn the cursor on or off
ProjectPositionToScreen Vector2D user:ProjectPositionToScreen(Vector worldLocation) Converts a position in world space to a screen space co-ordinate Returned values are in the range 0 to 1 Usage example: function MyPlayerScript:LocalOnTick(deltaTime) local user = self:GetEntity():GetUser() local screenPos = user:ProjectPositionToScreen(Vector.New(0,0,0)) Printf(“Screen pos: {1}”, screenPos) end
PlayVibrationEffect user:PlayVibrationEffect(VibrationEffectAsset vibrationEffect)
PlayManualVibration user:PlayManualVibration(number intensity, number duration, bool affectSmallMotors, bool affectLargeMotors)
SetMoveOverride user:SetMoveOverride(Vector2D scale, Vector2D add) Set a scale on the user’s actual move input and an addition 2D vector to add to it. Used for example to auto-walk a player forward but scaling the real input down to zero and adding an additional value.
SetLookOverride user:SetLookOverride(Vector2D scale, Vector2D add) Set a scale on the user’s actual look input and an addition 2D vector to add to it. Used for example to auto-look a player at a particular point by scaling the real input down to zero and adding an additional value.
SetLeaderboardValue user:SetLeaderboardValue(string leaderboardName, number value, callback callback)
SetLeaderboardValue user:SetLeaderboardValue(string leaderboardName, number value)
GetLeaderboardValue user:GetLeaderboardValue(string leaderboardName, callback callback) Gets the highest ranking value on the specified leaderboard for this user. Results are returned as parameters to the callback function. Callback function parameters are Score & Rank
GetChallengeProgress number user:GetChallengeProgress(string challengeId) Gets the current progress on an active challenge
SendChallengeEvent user:SendChallengeEvent(string eventName, table eventParametersTable) Server Sends a Challenge event for this user. Takes a lua table of parameter to value pairs that are conditionally checked against the Challenge definition. Usage example: function MyUserScript:OnSomeAction(someValue1, someValue2) self:GetUser():SendChallengeEvent(“SomeEvent”, {someParameter1 = someValue1, someParameter2 = someValue2}) end
SendChallengeEvent user:SendChallengeEvent(string eventName) Server Sends a Challenge event for this user.
Variables
showDefaultCrosshair bool showDefaultCrosshair Turn on or off ability to crouch or go prone
useHotbar bool useHotbar Use hotbar inputs, using the next and previous item buttons on controller and the hotbar buttons on keyboard
hotbarMax int hotbarMax Number of slots in the hotbar, this is a wrap point for next and previous item buttons
hotbarIndex int hotbarIndex The current (1-based) hotbar index for this user
voiceChannel int voiceChannel The current voice channel for this user (1 – 32)
Overrides
index object user.var Get a script or widget from the Entity by name, or a mesh, light, etc component on this entity. ie entity.myScript returns a script called myScript, entity.theHud returns a widget named theHud, entity.mesh returns the Mesh of this Entity, entity.light returns the property bag for a light component…
Back to top
VoxelMesh
An Entity can have a single physical representation. Voxels represents a voxel mesh which is edited to a start state in the editor and can be changed during gameplay. Voxels derives from Entity so if you have a Voxels you can do any of these functions as well as the functions in Entity. You can do entity:IsA(Voxels) to see if a particular entity variable is a Voxels type entity.
Functions
RevertClientProperty voxelMesh:RevertClientProperty(bool propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
SetVoxel voxelComponent:SetVoxel(Vector pos, VoxelAsset voxelAsset) Server Change a single voxel in world space.
SetVoxelBox voxelComponent:SetVoxelBox(Vector pos, Vector scale, VoxelAsset voxelAsset) Server Change a cuboid of voxels with a given scale Vector.
SetVoxelBox voxelComponent:SetVoxelBox(Vector pos, number halfSize, VoxelAsset voxelAsset) Server Change a cube of voxels given a given halfSize for each axis.
SetVoxelSphere voxelComponent:SetVoxelSphere(Vector pos, Vector scale, VoxelAsset voxelAsset) Server Change an elipsoid of voxels with a given scale Vector.
SetVoxelSphere voxelComponent:SetVoxelSphere(Vector pos, number radius, VoxelAsset voxelAsset) Server Change a sphere of voxels with a given radius.
ResetVoxels voxelComponent:ResetVoxels() Server Reset any SetVoxel…() calls that have been done during play, returning the voxel prop to its starting state (ie as it was in the editor).
CreateThruster Thruster voxels:CreateThruster() Add a thruster to an entity
CreateRelativeThruster Thruster voxels:CreateRelativeThruster() Add a thruster to an entity
DestroyThruster voxels:DestroyThruster(Thruster handle) Destroy a thruster
AddImpulse voxels:AddImpulse(Vector impulse) Add Impulse. An integral of force over a time interval. Newton seconds.
AddAngularImpulse voxels:AddAngularImpulse(Rotation angularImpulse) Add an angular impulse. An integral of torque over a time interval. Newton seconds.
Variables
mesh voxelmesh mesh Get or change the voxel mesh asset
collisionEnabled bool collisionEnabled Turn on or off collision (ie calling entry point OnCollision).
damageEnabled bool damageEnabled Turn on or off damage (ie calling of entry point OnDamaged).
physicsEnabled bool physicsEnabled Turn on or off physics.
gravityEnabled bool gravityEnabled Turn on or off physics.
onCollision Event onCollision Called when this entity is collided with by a player Character with the Character passed as an argument, as well as the voxel mesh Entity from which the onCollision event was sent. An alternative to listening for OnCollision in a script on the entity.
onDamage Event onDamage Called when this entity is damaged with the amount of damage, the entity causing the damage and a HitResult structure, as well as the voxel mesh Entity from which the onDamage event was sent. An alternative to listening for OnDamage in a script on the entity.
Overrides
index object voxelMesh.var
Back to top
World
Functions that effect everything within the current world.
Functions
RevertClientProperty world:RevertClientProperty(string propertyName) Client Revert a property that’s been changed on the client back to the server’s value for it
Raycast world:Raycast(Vector start, Vector end, Entity entityToIgnore, callback collisionCallback) Send a ray (line) from start position to end position, and call the collisionCallback with the entity that was hit and a HitResult structure if any Entity is hit along the way. Pass an entityToIgnore to tell it not to hit that one (for example ignore the player when doing a ray from a gun the player is holding).
Raycast world:Raycast(Vector start, Vector end, table entitiesToIgnoreTable, callback collisionCallback) Send a ray (line) from start position to end position, and call the collisionCallback with the entity that was hit and a HitResult structure if any Entity is hit along the way. Pass an array of entities to ignore.
Find Entity world:Find(string name) Find a named Entity within the world. Generally an entity type property which is filled in in the editor is a better option.
FindAll table world:FindAll() Return all entities in the world. Can be very slow.
FindAll table world:FindAll(table derivedType) Return all entities in the world of the given type (Light, Mesh, etc). Can be very slow.
FindAllScripts table world:FindAllScripts(string scriptName) Find all scripts named scriptName recursively in the world. Most often used where multiple scripts are used to simulate an array of structures.
FindAllScripts table world:FindAllScripts(ScriptAsset script) Find all scripts matching the script asset recursively in the world. Most often used where multiple scripts are used to simulate an array of structures.
FindScript Script world:FindScript(string scriptName) Find any entity with a script named scriptName recursively in the world, returns the script if found.
FindScript Script world:FindScript(ScriptAsset script) Find any entity with a script matching the script asset recursively in the world, returns the script if found.
FindTemplate Template world:FindTemplate(string name) Find a Template in the world by name. Returns nil if not found
GetLocalUser User world:GetLocalUser() Client Get the User that this client is owned by.
GetUsers table world:GetUsers() Get a table containing all the User entities within the current world. This works on the server or the client however the client version of the table might lag behind the server version.
ForEachUser world:ForEachUser(callback callback, args) Call the given callback for each User with the User as the argument
ApplyPointDamage world:ApplyPointDamage(number baseDamage, Vector rayStart, Vector direction, Entity fromEntity) Server Applies point damage to the first Entity that intersects the given ray.
ApplyPointDamage world:ApplyPointDamage(number baseDamage, Vector rayStart, Vector direction, Entity fromEntity, table damageModifiers) Server Applies point damage to the first Entity that intersects the given ray. Takes a damage modifier table in the form of: damageModifiers = {} damageModifiers[VoxelAsset] = {DamageMultiplier= DamageMultiplier}
ApplyRadialDamage world:ApplyRadialDamage(number baseDamage, Vector origin, number radius, number falloff, Entity fromEntity) Server Applies radial damage to all Entities within a radius of an origin.
ApplyRadialDamage world:ApplyRadialDamage(number baseDamage, Vector origin, number radius, number falloff, Entity fromEntity, table damageModifiers) Server Applies radial damage to all Entities within a radius of an origin. Takes a damage modifier table in the form of: damageModifiers = {} damageModifiers[VoxelAsset] = {DamageMultiplier= DamageMultiplier}
SetVoxelProperties world:SetVoxelProperties(table voxelPropertiesTable) Set the voxel properties of the world. Takes a table in the form of: voxelProperties = {} voxelProperties[VoxelAsset] = {Health = Health, HealTime = HealTime} defaults are 100 for health, 3.0 for heal time
SetVoxelProperties world:SetVoxelProperties(table voxelPropertiesTable, number defaultMaxHealth, number defaultHealTime) Set the voxel properties of the world. Takes a table in the form of: voxelProperties = {} voxelProperties[VoxelAsset] = {Health = Health, HealTime = HealTime} defaults are 100 for health, 3.0 for heal time, these can be modified in this version of the function.
GetTimeOfDay number world:GetTimeOfDay() Get the time of day (see SetTimeOfTime for what the return value means)
Spawn Entity world:Spawn(Template templateAsset, Vector position, Rotation rotation) Server Spawn a new Entity from the template pointed at by templateAsset, at the given position and rotation.
BroadcastToScripts world:BroadcastToScripts(string eventName, args) Try calling eventName on all scripts of all Entities within the World. When called on the server it sends to server scripts only, if called on the client it will send to client scripts only.
GetServerTime number world:GetServerTime() Get server up time in seconds (can be called on client or server)
GetUTCTime number world:GetUTCTime() Gets unit time (number of seconds that have elapsed since Jan 1 1970). This has an issue that it will start to overflow 32-bits in 2038.
GetGames world:GetGames(string railName, callback callback)
GetGames world:GetGames(table railNamesTable, callback callback)
GetActiveChallenges table world:GetActiveChallenges() Gets the current active challenges Example result table: result = {} result[1] = {id = ChallengeId, name = LocalisedName, icon = IconUrl, count = TotalCountToComplete} result[2] = {id…
Variables
startTime number startTime Start time of day from 0.0 (midnight) – 0.5 (midday) – 1.0 (next midnight)
dayLength number dayLength Length of virtual ‘day’ in real-time seconds
sunDirection number sunDirection Angle of sun in degrees. Controls whether the sun rises from west to east, north to south, etc.
sunColor Color sunColor Color of the sun
sunIntensity number sunIntensity Intensity of the sun
heightFogStartDistance number heightFogStartDistance Height fog start distance
heightFogFalloff number heightFogFalloff Height fog falloff
heightFogDensity number heightFogDensity Height fog density
heightFogColor Color heightFogColor Color of the height fog
skyLightIntensity number skyLightIntensity Intensity of the ambient light
skyLightColor Color skyLightColor Color of the ambient light
postProcess PostProcessAsset postProcess Post Process effect
colorGrading ColorGradingAsset colorGrading Color Grading effect
skydome SkydomeAsset skydome Skydome asset
innerHorizon HorizonAsset innerHorizon Inner Horizon asset
outerHorizon HorizonAsset outerHorizon Outer Horizon asset
skyMesh SkyMeshAsset skyMesh Sky Mesh asset
deathPlaneActive bool deathPlaneActive Set whether the death plane is active or not
deathPlaneZ number deathPlaneZ Height of the death plane, when active the game will send OnFellToDeath to any Player who falls below this, automatically putting the Player back to where they spawned if the event is not responded to by any scripts.