Menu
Lumberyard
Developer Guide (Version 1.12)

ScriptBind_System

CryLua is deprecated and will be removed in a future version of Lumberyard.

This class implements Lua script functions that expose system functionalities.

ActivatePortal

Activates or deactivates a portal.

Syntax

System.ActivatePortal(Vec3 vPos, bool bActivate, ScriptHandle nID)

Parameters

Parameter Description
vPos Position vector.
bActivate True to activate the portal, false to deactivate.
nID Entity identifier.

AddCCommand

Adds a C command to the system.

Syntax

System.AddCCommand(const char* sCCommandName, const char* sCommand, const char* sHelp)

Parameters

Parameter Description
sCCommandName C command name.
sCommand Command string.
sHelp Help for the command usage.

ApplicationTest

Test the application with the specified parameters.

Syntax

System.ApplicationTest(const char* pszParam)

Parameters

Parameter Description
pszParam Parameters.

Break

Breaks the application with a fatal error message.

Syntax

System.Break()

BrowseURL

Browses a URL address.

Syntax

System.BrowseURL(const char* szURL)

Parameters

Parameter Description
szURL URL string.

CheckHeapValid

Checks the heap validity.

Syntax

System.CheckHeapValid(const char* name)

Parameters

Parameter Description
name Name string. The default is <noname>.

ClearConsole

Clears the console.

Syntax

System.ClearConsole()

ClearKeyState

Clear the key state.

Syntax

System.ClearKeyState()

CreateDownload

Syntax

System.CreateDownload()

DebugStats

Syntax

System.DebugStats(bool cp)

DeformTerrain

Deforms the terrain.

Syntax

System.DeformTerrain()

DeformTerrainUsingMat

Deforms the terrain using material.

Syntax

System.DeformTerrainUsingMat()

Draw2DLine

Draws a 2D line.

Syntax

System.Draw2DLine(p1x, p1y, p2x, p2y, float r, float g, float b, float alpha)

Parameters

Parameter Description
p1x X value of the start point of the line.
p1y Y value of the start point of the line.
p2x X value of the end point of the line.
p2y Y value of the end point of the line.
r Red component for the label color. Default is 1.
g Green component for the label color. Default is 1.
b Blue component for the label color. Default is 1.
alpha Alpha component for the label color. Default is 1.

DrawLabel

Draws a label with the specified parameter.

Syntax

System.DrawLabel(Vec3 vPos, float fSize, const char* text [, float r [, float g [, float b [, float alpha]]]])

Parameters

Parameter Description
vPos Position vector.
fSize Size for the label.
text Text of the label.
r Red component for the label colour. Default is 1.
g Green component for the label colour. Default is 1.
b Blue component for the label colour. Default is 1.
alpha Alpha component for the label colour. Default is 1.

DrawLine

Draws a line.

Syntax

System.DrawLine(Vec3 p1, Vec3 p2, float r, float g, float b, float alpha)

Parameters

Parameter Description
p1 Start position of the line.
p2 End position of the line.
r Red component for the label color. Default is 1.
g Green component for the label color. Default is 1.
b Blue component for the label color. Default is 1.
alpha Alpha component for the label color. Default is 1.

DrawText

Draws text.

Syntax

System.DrawText(float x, float y, const char* text, const char* fontName, float size, float r, float g, float b, float alpha)

Parameters

Parameter Description
x X position for the text. The default is 0.
y Y position for the text. The default is 0.
text Text to be displayed. The default is an empty string.
fontName Font name. The default is default.
size Text size. The default is 16.
r Red component for the label color. The default is 1.
g Green component for the label color. The default is 1.
b Blue component for the label color. The default is 1.
alpha Alpha component for the label color. The default is 1.

DumpMemoryCoverage

Dumps memory coverage.

Syntax

System.DumpMemoryCoverage()

This function is useful for investigating memory fragmentation. When #System.DumpMemoryCoverage() is called from the console, DumpMemoryCoverage adds a line to the MemoryCoverage.bmp file, which is generated the first time there is a maximum line count.

DumpMemStats

Dumps memory statistics.

Syntax

System.DumpMemStats(bUseKB)

Parameters

Parameter Description
bUseKB True to use KB, false otherwise. The default is false.

DumpMMStats

Dumps the MM statistics.

Syntax

System.DumpMMStats()

DumpWinHeaps

Dumps windows heaps.

Syntax

System.DumpWinHeaps()

EnableOceanRendering

Enables/disables ocean rendering.

Syntax

System.EnableOceanRendering()

Parameters

Parameter Description
bOcean True to activate the ocean rendering, false to deactivate it.

EnumAAFormats

Enumerates multisample anti-aliasing formats.

Syntax

System.EnumAAFormats()

EnumDisplayFormats

Enumerates display formats.

Syntax

System.EnumDisplayFormats()

Error

Shows a message text with the error severity.

Syntax

System.Error(const char* sParam)

Parameters

Parameter Description
sParam Text to be logged. The default is an empty string.

ExecuteCommand

Executes a command.

Syntax

System.ExecuteCommand(const char* szCmd)

Parameters

Parameter Description
szCmd Command string.

GetConfigSpec

Gets the config specification.

Syntax

System.GetConfigSpec()

GetCurrAsyncTime

Gets the current asynchronous time.

Syntax

System.GetCurrAsyncTime()

GetCurrTime

Gets the current time.

Syntax

System.GetCurrTime()

GetCVar

Gets the value of a console variable.

Syntax

System.GetCVar(const char* sCVarName)

Parameters

Parameter Description
sCVarName Name of the variable.

GetEntities

Returns a table with all the entities currently present in a level.

Syntax

System.GetEntities(Vec3 center, float radius)

Parameters

Parameter Description
center Center position vector for the area where to get entities. The default is (0, 0, 0).
radius Radius of the area. The default is 0.

GetEntitiesByClass

Gets all the entities of the specified class.

Syntax

System.GetEntitiesByClass(const char* EntityClass)

Parameters

Parameter Description
EntityClass Entity class name.

GetEntitiesInSphere

Gets all the entities contained into the specified sphere.

Syntax

System.GetEntitiesInSphere(Vec3 center, float radius)

Parameters

Parameter Description
center center position vector for the sphere where to look at entities.
radius Radius of the sphere.

GetEntitiesInSphereByClass

Gets all the entities contained into the specified sphere for the specific class name.

Syntax

System.GetEntitiesInSphereByClass(Vec3 center, float radius, const char* EntityClass)

Parameters

Parameter Description
center center position vector for the sphere where to look at entities.
radius Radius of the sphere.
EntityClass Entity class name.

GetEntity

Gets an entity from its ID.

Syntax

System.GetEntity(entityId)

Parameters

Parameter Description
entityId Entity identifier (svtNumber or ScriptHandle).

GetEntityByName

Retrieve entity table for the first entity with specified name. If multiple entities with same name exist, first one found is returned.

Syntax

System.GetEntityByName(const char *sEntityName)

Parameters

Parameter Description
sEntityName Name of the entity to search.

GetEntityClass

Gets an entity class from its ID.

Syntax

System.GetEntityClass(entityId)

Parameters

Parameter Description
entityId Entity identifier (svtNumber or ScriptHandle).

GetEntityIdByName

Retrieve entity Id for the first entity with specified name. If multiple entities with same name exist, first one found is returned.

Syntax

System.GetEntityIdByName(const char *sEntityName)

Parameters

Parameter Description
sEntityName Name of the entity to search.

GetFrameID

Gets the frame identifier.

Syntax

System.GetFrameID()

GetFrameTime

Gets the frame time.

Syntax

System.GetFrameTime()

GetHDRDynamicMultiplier

Gets the HDR dynamic multiplier.

Syntax

System.GetHDRDynamicMultiplier()

GetLocalOSTime

Gets the local operating system time.

Syntax

System.GetLocalOSTime()

GetNearestEntityByClass

Gets the nearest entity with the specified class.

Syntax

System.GetNearestEntityByClass(Vec3 center, float radius, const char *className)

Parameters

Parameter Description
center Center position vector for the area where to look at entities.
radius Radius of the sphere.
className Entity class name.

GetOutdoorAmbientColor

Gets the outdoor ambient color.

Syntax

System.GetOutdoorAmbientColor()

GetPhysicalEntitiesInBox

Gets all the entities contained into the specified area.

Syntax

System.GetPhysicalEntitiesInBox(Vec3 center, float radius)

Parameters

Parameter Description
center Center position vector for the area where to look at entities.
radius Radius of the sphere.

GetPhysicalEntitiesInBoxByClass

Gets all the entities contained into the specified area for the specific class name.

Syntax

System.GetPhysicalEntitiesInBoxByClass(Vec3 center, float radius, const char *className)

Parameters

Parameter Description
center Center position vector for the area where to look at entities.
radius Radius of the sphere.
className Entity class name.

GetPostProcessFxParam

Gets a post processing effect parameter value.

Syntax

System.GetPostProcessFxParam(const char* pszEffectParam, value)

Parameters

Parameter Description
pszEffectParam Parameter for the post processing effect.
value Value for the parameter (float or string).

GetScreenFx

Gets a post processing effect parameter value.

Note

This is a convenience wrapper function for GetPostProcessFxParam.

Syntax

System.GetScreenFx(const char* pszEffectParam, value)

Parameters

Parameter Description
pszEffectParam Parameter for the post processing effect.
value Value for the parameter (float or string).

GetSkyColor

Retrieve color of the sky (outdoor ambient color).

Syntax

Vec3 System.GetSkyColor()

Returns: Sky color as an {x,y,z} vector (x=r,y=g,z=b).

GetSkyHighlight

Retrieves sky highlighing parameters. See SetSkyHighlight for a description of the parameters.

Syntax

System.GetSkyHighlight(SmartScriptTable params)

GetSunColor

Retrieve color of the sun outdoors.

Syntax

Vec3 System.GetSunColor()

Returns: Sun Color as an {x,y,z} vector (x=r,y=g,z=b).

GetSurfaceTypeIdByName

Gets the surface type identifier by its name.

Syntax

System.GetSurfaceTypeIdByName(const char* surfaceName)

Parameters

Parameter Description
surfaceName Surface name.

GetSurfaceTypeNameById

Gets the surface type name by its identifier.

Syntax

System.GetSurfaceTypeNameById(int surfaceId)

Parameters

Parameter Description
surfaceId Surface identifier.

GetSystemMem

Gets the amount of the memory for the system.

Syntax

System.GetSystemMem()

GetTerrainElevation

Gets the terrain elevation of the specified position.

Syntax

System.GetTerrainElevation(Vec3 v3Pos)

Parameters

Parameter Description
v3Pos Position of the terraint to be checked.

GetUserName

Gets the username on this machine.

Syntax

System.GetUserName()

GetViewCameraAngles

Gets the view camera angles.

Syntax

System.GetViewCameraAngles()

GetViewCameraDir

Gets the view camera direction.

Syntax

System.GetViewCameraDir()

GetViewCameraFov

Gets the view camera fov.

Syntax

System.GetViewCameraFov()

GetViewCameraPos

Gets the view camera position.

Syntax

System.GetViewCameraPos()

GetViewCameraUpDir

Gets the view camera up-direction.

Syntax

System.GetViewCameraUpDir()

GetWind

Gets the wind direction.

Syntax

System.SetWind()

IsDevModeEnable

Checks if game is running in dev mode (cheat mode), which enables certain script function facilities (god mode, fly mode etc.).

Syntax

System.IsDevModeEnable()

IsEditing

Checks if the system is in pure editor mode - that is, not editor game mode.

Syntax

System.IsEditing()

IsEditor

Checks if the system is the editor.

Syntax

System.IsEditor()

IsHDRSupported

Checks if the HDR is supported.

Syntax

System.IsHDRSupported()

IsMultiplayer

Checks if the game is multiplayer.

Syntax

System.IsMultiplayer()

IsPointIndoors

Checks if a point is indoors.

Syntax

System.IsPointIndoors(Vec3 vPos)

Parameters

Parameter Description
vPos Position vector. The default is (0, 0, 0).

IsPointVisible

Checks if the specified point is visible.

Syntax

System.IsPointVisible(Vec3 point)

Parameters

Parameter Description
point Point vector.

IsPS20Supported

Checks if the PS20 is supported.

Syntax

System.IsPS20Supported()

IsValidMapPos

Checks if the position is a valid map position.

Syntax

System.IsValidMapPos(Vec3 v)

Parameters

Parameter Description
v Position vector. The default is (0, 0, 0).

LoadFont

Loads a font.

Syntax

System.LoadFont(const char* pszName)

Parameters

Parameter Description
pszName Font name.

LoadLocalizationXml

Loads Excel exported XML file with text and dialog localization data.

Syntax

System.LoadLocalizationXml(const char *filename)

Log

Logs a message to the log file and console.

Syntax

System.Log(const char* sText)

Parameters

Parameter Description
sText Text to be logged.

LogAlways

Logs data even if the verbosity setting is 0.

Syntax

System.LogAlways(const char* sText)

Parameters

Parameter Description
sText Text to be logged.

LogToConsole

Logs a message to the console.

Syntax

System.LogToConsole(const char* sText)

Parameters

Parameter Description
sText Text to be logged.

PrepareEntityFromPool

Prepares the given bookmarked entity from the pool, bringing it into existence.

Syntax

System.PrepareEntityFromPool(entityId)

Parameters

Parameter Description
entityId Entity identifier (number or ScriptHandle).
bPrepareNow (optional) When another entity preparation is already in progress, specifies whether the pooled entity should be prepared immediately instead of putting it in a queue.

ProjectToScreen

Projects to the screen (not guaranteed to work if used outside Renderer).

Syntax

System.ProjectToScreen(Vec3 vec)

Parameters

Parameter Description
vec Position vector.

Quit

Quits the program.

Syntax

System.Quit()

QuitInNSeconds

Quits the application in the specified number of seconds.

Syntax

System.QuitInNSeconds(float fInNSeconds)

Parameters

Parameter Description
fInNSeconds Number of seconds before quitting.

RayTraceCheck

Checks world and static objects.

Syntax

System.RayTraceCheck(Vec3 src, Vec3 dst, int skipId1, int skipId2)

RayWorldIntersection

Shoots rays into the world.

Syntax

System.RayWorldIntersection(Vec3 vPos, Vec3 vDir, int nMaxHits, int iEntTypes)

Parameters

Parameter Description
vPos Position vector. The default is (0, 0, 0).
vDir Direction vector. The default is (0, 0, 0).
nMaxHits Maximum number of hits.
iEntTypes

RemoveEntity

Removes the specified entity.

Syntax

System.RemoveEntity(ScriptHandle entityId)

Parameters

Parameter Description
entityId Entity identifier.

ResetPoolEntity

Resets the entity's bookmarked, which frees memory.

Syntax

System.ResetPoolEntity(entityId)

Parameters

Parameter Description
entityId Entity identifier (svtnumber or ScriptHandle).

ReturnEntityToPool

Syntax

System.ReturnEntityToPool(entityId)

Returns: the bookmarked entity to the pool, destroying it.

Parameters

Parameter Description
entityId Entity identifier (svtnumber or ScriptHandle).

SaveConfiguration

Saves the configuration.

Syntax

System.SaveConfiguration()

ScanDirectory

Scans a directory.

Syntax

System.ScanDirectory(const char* pszFolderName, int nScanMode)

Parameters

Parameter Description
pszFolderName Folder name.
nScanMode Scan mode for the folder. Can be: SCANDIR_ALL (0), SCANDIR_FILES (1), or SCANDIR_SUBDIRS (2).

ScreenToTexture

Syntax

System.ScreenToTexture()

SetBudget

Sets system budget.

Syntax

System.SetBudget(int sysMemLimitInMB, int videoMemLimitInMB, float frameTimeLimitInMS, int soundChannelsPlayingLimit, int soundMemLimitInMB, int soundCPULimitInPercent, int numDrawCallsLimit)

Parameters

Parameter Description
sysMemLimitInMB Limit of the amount of system memory in MB. The default is 512.
videoMemLimitInMB Limit of the amount of video memory in MB. The default is 256.
frameTimeLimitInMS Limit of the frame time in MS. The default is 50.0f.
soundChannelsPlayingLimit Limit of the number of sound channels playing. The default is 64.
soundMemLimitInMB Limit of the sound memory in MB. The default is 64.
soundCPULimitInPercent Limit of the sound CPU usage in percent. The default is 5.
numDrawCallsLimit Limit of the number of draw calls. The default is 2000.

SetConsoleImage

Sets the console image.

Syntax

System.SetConsoleImage(const char* pszName, bool bRemoveCurrent)

Parameters

Parameter Description
pszName The name of the texture image.
bRemoveCurrent True to remove the current image; otherwise false.

SetCVar

Sets the value of a console variable.

Syntax

System.SetCVar(const char* sCVarName, value)

Parameters

Parameter Description
sCVarName Name of the variable.
value Value of the variable (float or string).

SetGammaDelta

Sets the gamma/delta value.

Syntax

System.SetGammaDelta(float fDelta)

Parameters

Parameter Description
fDelta Delta value. The default is 0.

SetOutdoorAmbientColor

Sets the outdoor ambient color.

Syntax

System.GetOutdoorAmbientColor(v3Color)

Parameters

Parameter Description
v3Color Outdoor ambient color value.

SetPostProcessFxParam

Sets a post processing effect parameter value.

Syntax

System.SetPostProcessFxParam(const char* pszEffectParam, value)

Parameters

Parameter Description
pszEffectParam Parameter for the post processing effect.
value Value for the parameter (svtNumber, svtObject, or svtString).

SetScissor

Sets the scissoring screen area.

Syntax

System.SetScissor(float x, float y, float w, float h)

SetScreenFx

Sets a post processing effect parameter value.

Note

This is a convenience wrapper function for SetPostProcessFxParam.

Syntax

System.SetScreenFx(pszEffectParam, value)

Parameters

Parameter Description
pszEffectParam Parameter for the post processing effect.
value Value for the parameter (svtNumber, svtObject, or svtString).

SetSkyColor

Set color of the sky (outdoors ambient color).

Syntax

System.SetSkyColor(Vec3 vColor)

Parameters

Parameter Description
vColor Sky Color as an {x,y,z} vector (x=r,y=g,z=b).

SetSkyHighlight

Set sky highlighing parameters.

Syntax

System.SetSkyHighlight(SmartScriptTable params)

Parameters

Parameter Description
params Table with sky highlighting parameters.

Params Table Parameters

Highlight Parameter Description
color Sky highlight color
direction Direction of the sky highlight in world space.
pos Position of the sky highlight in world space.
size Sky highlight scale.

SetSunColor

Set the color of the sun, only relevant outdoors.

Syntax

System.SetSunColor(Vec3 vColor)

Parameters

Parameter Description
vColor Sun color as an {x,y,z} vector (x=r,y=g,z=b).

SetViewCameraFov

Sets the view camera fov.

Syntax

System.SetViewCameraFov(float fov)

SetVolumetricFogModifiers

Sets the volumetric fog modifiers.

Syntax

System.SetVolumetricFogModifiers(float gobalDensityModifier, float atmosphereHeightModifier)

Parameters

Parameter Description
gobalDensityModifier Modifier for the global density.
atmosphereHeightModifier Modifier for the atmosphere height.

SetWaterVolumeOffset

SetWaterLevel is not supported by the 3D engine for now.

Syntax

System.SetWaterVolumeOffset()

SetWind

Sets the wind direction.

Syntax

System.SetWind(Vec3 vWind)

Parameters

Parameter Description
vWind Wind direction. The default value is (0, 0, 0).

ShowConsole

Shows or hides the console.

Syntax

System.ShowConsole(int nParam)

Parameters

Parameter Description
nParam 1 to show the console, 0 to hide. The default is 0.

ShowDebugger

Shows the debugger.

Syntax

System.ShowDebugger()

SpawnEntity

Spawns an entity.

Syntax

System.SpawnEntity(SmartScriptTable params)

Parameters

Parameter Description
params Entity parameters.

ViewDistanceGet

Gets the view distance.

Syntax

System.ViewDistanceSet()

ViewDistanceSet

Sets the view distance.

Syntax

System.ViewDistanceSet(float fViewDist)

Parameters

Parameter Description
fViewDist View distance.

Warning

Shows a message text with the warning severity.

Syntax

System.Warning(const char* sParam)

Parameters

Parameter Description
sParam The text to be logged. The default value is an empty string.

On this page: