System

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article

Contents

Overview

These Lua functions are in the System table. For example, the Log function would be invoked like this:

System.Log("logging this message");

Configuration

IsEditor()
check whether you're running in the Editor
GetCPUQuality()


GetGPUQuality()


GetSystemMem()


IsPS20Supported()
LoadLocalizationXml(filename)
SaveConfiguration
Quit
QuitInNSeconds
Don't use this


SetBudget(sysmemlimit, videomemlimit, frametimelimit, soundmemlimit, drawcallslimit)
example - none
ViewDistanceGet
ApplyForceToEnvironment
GetOutdoorAmbientColor
ActivatePortal
IsPointIndoors
CheckHeapValid
GetConfigSpec
SetScissor


LoadFont(name)

File

ScanDirectory(directory,mode, recursive)
returns directory listing as a table
directory - directory pathname, a string
mode - scan mode, 0 - all, 1 - files, 2 - subdirectories
recursive - optional, specifies whether to scan subdirectories
CreateTemporaryFile()
creates a temporary file and returns the file path.
Note that the io.tmpfile method in standard library returns file handle (not file path).

Surface Types

See surface type.


GetSurfaceTypeIdByName(surfaceName)
return value - id of surface
GetSurfaceTypeNameById(surfaceId)
return value - surface name
LoadSurfaceTypes(file)

Renderer

Screen

GetScreenSize()
get the extents of the render area
Screenshot(file)
save a screen capture to file
ProjectToScreenAR(point)
transform world point into screen coordinates
UnprojectFromScreen(point)
tranform screen coordinate into world coordinates
EnumDisplayFormats()
return value - a table of display formats, each with width,height and bpp fields
example - none
EnumAAFormats()
SetGammaDelta(delta)
set delta gamma
example - none
SetSystemShaderRenderFlags(shaderName, flagName, enable)
load a shader
example - none
GetFrameID()
return value - current frame ID

HDR

GetHDRDynamicMultiplier()
returns multiplier in the range 0-100
SetHDRDynamicMultiplier(multiplier)
sets multiplier, clamps to range 0-100
IsHDRSupported()
Returns 1 if hardware supports high dynamic range rendering, 0 otherwise


2D Drawing

These might be obsolete

DrawLabelImage
DrawLabel
ScreenToTexture
DrawLine
Draw2DLine
DrawText


DrawImage(nTid, nPx, nPy, w, h, nMode)
draw an sprite on screen
nPx - x position(the screen is normalized at 800x600)
nPy - y position(the screen is normalized at 800x600)
w - width
h - height
nMode - blending mode (the number must be specified)

R_BLEND_MODE__ZERO__SRC_COLOR 1 R_BLEND_MODE__SRC_COLOR__ZERO 2 R_BLEND_MODE__SRC_COLOR__ONE_MINUS_SRC_COLOR 3 R_BLEND_MODE__SRC_ALPHA__ONE_MINUS_SRC_ALPHA 4 R_BLEND_MODE__ONE__ONE 5 R_BLEND_MODE__DST_COLOR__SRC_COLOR 6 R_BLEND_MODE__ZERO__ONE_MINUS_SRC_COLOR 7 R_BLEND_MODE__ONE__ONE_MINUS_SRC_COLOR 8 R_BLEND_MODE__ONE__ZERO 9 R_BLEND_MODE__ZERO__ZERO 10 R_BLEND_MODE__ONE__ONE_MINUS_SRC_ALPHA 11 R_BLEND_MODE__SRC_ALPHA__ONE 12 R_BLEND_MODE__ADD_SIGNED 14

DrawImageColor
DrawImageCoords
DrawImageColorCoords
DrawTriStrip
DrawRectShader

Screen Effects

SetPostProcessFxParam(name, value)
GetPostProcessFxParam(name)
SetScreenFx()
same as SetPostProcessFxParam
GetScreenFx()
same as GetPostProcessFxParam

Time

GetCurrTime()
return game time at the beginning of the most recent frame, in milliseconds
GetCurrAsyncTime()
return game time in milliseconds
GetFrameTime()
return time since last frame, in seconds
GetOSTime()
return UTC time in seconds
GetLocalOSTime()
returns local time as a table
GetGMOSTime()
returns GMT(UTC) time as a table

Debugging

ShowDebugger()
bring up the Lua debugger
Break()
Stop game execution with an error popup.
IsDevModeEnable

Console

Functions that access console commands and variables.


SetCVar(name, value)
sets the value of a console variable
GetCVar(name)
return value - the value of a console variable
AddCCommand(name, expr, help)
define a console command that executes Lua code
ExecuteCommand(command)
executes a console command
command - string name of the command to execute
ShowConsole(enable)
show console
SetConsoleImage(name, removeCurrent)
displays a background image on the console

Log

These logging functions are subject to the log verbosity level.


LogToConsole(message)
log message only to console, if verbosity setting is 3 or greater
LogAlways(message)
log message to the game log file and console, no matter the verbosity setting
Log(message)
log message string to the log file and console if verbosity setting is 3 or greater
Warning(message)
log warning message to the log file and console, if verbosity setting is 2 or greater
Error(message)
log error message to the log file and console, if verbosity setting is 1 or greater
ClearConsole()
clear the console

Statistics

These functions dump to the log, subject to log verbosity settings


DumpWinHeaps()
DebugStats(checkpoint)
checkpoint - not used
DumpMemStats(useKB)
dump memory statistics to a file
useKB - boolean optional parameter, indicating whether to print out stats in kilobytes
DumpMemoryCoverage()
useful for investigating memory fragmentation
DumpMMStats()

View

These functions operate on the view of the current system camera, which is superseded by custom views. See Cameras.


SetViewCameraFov(fov)
set the field of view of the current camera
GetViewCameraFov()
get field of view of the current camera
GetViewCameraPos()
get position of current camera
GetViewCameraDir()
direction of current camera
example - Game/Scripts/Entities/Render/Lightning.lua
GetViewCameraAngles()
orientation of current camera
IsPointVisible(point)
check whether a point is within the current camera's view frustum

Entity

Functions to access entities from the CryEngine entity manager. See Entity for entity functions.


GetEntity(id)
returns the entity with the given entity ID
GetEntityClass(id)
returns the entity class name for an entity
GetEntities()
returns all entities in the level, as a table
GetEntitiesInSphere(center, radius)
return a table filled with all entities in a radius
GetEntitiesInSphereByClass(center, radius, className)
return a table filled with all entities of a specified entity class in a radius
GetPhysicalEntitiesInBox(center, radius)
find all physical entities within a bounding box
GetPhysicalEntitiesInBoxByClass(center, radius, className)
find all physical entities of a class within a bounding box
GetEntitiesByClass(EntityClass)
returns all entities in level of a given class
GetNearestEntityByClass(center, radius, className)
find the nearest entity of a certain class
GetEntityByName(sEntityName)
return entity with the given name
GetEntityIdByName(sEntityName)
return entity ID of an entity
RemoveEntity(entityId)
remove an entity from the world
SpawnEntity(params)
create a entity with specified parameters

Environment

Some of these functions correspond to the Terrain Environment settings in the Sandbox Editor: http://wiki.crymod.com/index.php/Sandbox_TerrainEnvironment

Terrain

DeformTerrain
Not used
DeformTerrainUsingMat
Not used


GetTerrainElevation(pos)
Returns height of terrain at given position, which is specified as a vector.
IsValidMapPos(pos)
returns true if position is valid, false otherwise
position is a vector
valid if within 500 units of terrain extent (bounded by 0,0 to GetTerrainSize(),GetTerrainSize())

Added by Avatar Reality:


GetTerrainZ(x, y)
returns height of terrain at coordinates x,y
Height is that of nearest terrain grid point
GetTerrainSurfaceNormal(pos)
Returns normal of terrain at given position, which is specified as a vector.
Only x,y are used, z is ignored.
normal is a vector
GetTerrainSize()
returns terrain dimension in meters
GetTerrainSectorSize()

returns terrain sector dimension in meters

GetHeightMapUnitSize()
returns number of meters per height unit

Sky

The sun and sky colors are also set by TimeOfDay.


SetSunColor(color)
Set the sun color


GetSunColor()
Returns the sun color


SetSkyColor(color)
Set the sky color


GetSkyColor()
return the sky color


GetSunRel()
return value - float the brightness ratio between the sun and sky


SetSkyBrightness(brightness)

Sky highlight is used in the Flash and Lightning entities.


SetSkyHighlight(tableSkyHighlightParams)
set sky highlight parameters


GetSkyHighlight()
return sky highlight parameters


These functions correspond to the Sandbox Editor moon settings under the Terrain Environment rollup tab.

Image:Moonsettings.PNG


SetMoonPosition(latitude, longitude)
set the moon latitude and longitude


GetMoonPosition()
return the moon latitude and longitude

Fog

SetVolumetricFogModifiers(densityMod, heightMod)
sets the global density modifier and atmospheric height modifier


SetFogColor(color)
Set the fog color
color - vector the new fog color
by Avatar Reality


GetFogColor()
return value - vector the current fog color
by Avatar Reality

Wind

Functions for accessing global wind


SetWind(windvector)
set the global wind vector, a vector


GetWind()
returns the global wind vector, a vector

See http://wiki.crymod.com/index.php/Sandbox_WeatherEffectsSetupTut#Wind

Water

EnableOceanRendering(enable)
GetOceanVisiblePixelsCount()
return number of visible ocean pixels
GetOceanRenderFlags()
returns ocean render flags as a number
SetOceanRenderFlags(flags)
Sets ocean render flags

Ocean render flags can be

OCR_NO_DRAW
OCR_OCEANVOLUME_VISIBLE


These functions return water information about the specified x,y world position (i.e. terrain position). z is ignored.

GetWaterLevel(pos)
returns water height at position
GetBottomLevel(pos)
returns water bottom height at position
IsUnderwater(pos)
returns whether position is underwater


These functions correspond to the Sandbox Editor ocean animation settings. Each argument value or return value type is a number.

Image:Oceananimationsettings.PNG


GetOceanWindDirection()
SetOceanWindDirection(direction)
direction is in radians
GetOceanWindSpeed()
SetOceanWindSpeed(speed)
GetOceanWavesSpeed()
SetOceanWavesSpeed(speed)
GetOceanWavesSize()
SetOceanWavesSize(size)
GetOceanWavesAmount()
SetOceanWavesAmount(amount)


Input

See ActionMap Manager


ClearKeyState()
clears key state of all devices
GetWindowMouse()
get position of mouse in window coordinates
SetWindowMouse(x, y)
Set mouse position in window coordinates
GetScreenMouse()
position of mouse in screen coordinates
SetScreenMouse(x, y)
Set mouse position in screen coordinates
HasFocus()
check whether the game window has the input focus

Console Commands

See Console/System

Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools