Skip to content

Scripting World

Dreamy Cecil edited this page Oct 25, 2026 · 1 revision

Functions

World.IsActive()

Checks whether there's any active world in the game right now that the client may interact with in any way. This includes playing in singleplayer, hosting a server, playing on a server, observing on a server, playing back a recorded demo etc.

Return value: bool


World.GetCurrentTick()

Returns context-independent time of the current world simulation tick for gameplay logic purposes. If no world is currently running, returns 0.0.

Tip

If you need context-dependent time of the current tick, use Timer.CurrentTick() instead.

Return value: float


World.GetLerpedCurrentTick()

Returns context-independent time of the current world simulation frame (i.e. current time between simulation ticks) for rendering/frame-accurate purposes. If no world is currently running, returns 0.0.

Tip

If you need context-dependent time of the current frame, use Timer.GetLerpedCurrentTick() instead.

Return value: float


World.GetLerpFactor()

Returns context-independent factor between the current and the next ticks of the current world simulation for rendering/frame-accurate purposes. If no world is currently running, returns 0.0.

Tip

If you need context-dependent factor between ticks, use Timer.GetLerpFactor() instead.

Return value: float


World.GetLerpFactor2()

Returns secondary context-independent factor between the current and the next ticks of the current world simulation for rendering/frame-accurate purposes. If no world is currently running, returns 0.0.

Tip

If you need context-dependent secondary factor between ticks, use Timer.GetLerpFactor2() instead.

Return value: float


World.GetBackgroundColor()

Returns background color of the current world. Equivalent to the engine's CWorld::GetBackgroundColor().
Throws a runtime error if no world is currently running.

Return value: integer


World.GetBackgroundViewer()

Returns current background viewer of the current world (may be none). Equivalent to the engine's CWorld::GetBackgroundViewer().
Throws a runtime error if no world is currently running.

Return value: CEntityPointer


World.GetWSC()

Returns current WorldSettingsController entity of the current world, if supported (may be none).
Throws a runtime error if no world is currently running.

Return value: CEntityPointer


World.GetFilename()

Returns path to the file of the current world. Equivalent to the engine's CWorld::wo_fnmFileName. Throws a runtime error if no world is currently running.

Return value: string


World.GetDescription()

Returns description of the current world. Equivalent to the engine's CWorld::GetDescription(). Throws a runtime error if no world is currently running.

Return value: string


World.GetName()

Returns display name of the current world. Equivalent to the engine's CWorld::GetName(). Throws a runtime error if no world is currently running.

Return value: string


World.GetSpawnFlags()

Returns spawn flags of the current world. Equivalent to the engine's CWorld::GetSpawnFlags(). Throws a runtime error if no world is currently running.

Return value: integer


World.GetEntities(predictors)

Throws a runtime error if no world is currently running.

Arguments:

  • predictors - Flag for whether to include predictor entities in the array.

Return value: Array of CEntityPointer with all the entities in the current world.


World.FindEntityByID(id)

Retrieves an entity under the specified ID in the current world (may be none).
Throws a runtime error if no world is currently running.

Arguments:

  • id - ID of the entity in the world to retrieve a pointer to.

Return value: CEntityPointer


World.FindClasses(class_name)

Throws a runtime error if no world is currently running.

Arguments:

  • class_name - Class name of entities to find, e.g. "Enemy Base" for all classes derived from CEnemyBase or "ModelHolder2" for CModelHolder2 classes.

Return value: Array of CEntityPointer with all the entities of a specific class in the current world.


World.FindClassesByID(class_id)

Throws a runtime error if no world is currently running.

Arguments:

  • class_id - Class ID of entities to find, e.g. 4 for all classes derived from CPlayerEntity or 303 for CHeadman classes.

Return value: Array of CEntityPointer with all the entities of a specific class in the current world.


World.AnyLocalPlayers()

Checks whether there are any entities of local players in the current world. Returns true only if the client calling it is able to control any of the players on their screen. For demos and observers the return value is always false.
Throws a runtime error if no world is currently running.

Return value: bool


World.GetLocalPlayers()

Returns an array of player entities only if the client calling it is able to control any of them on their screen. For demos and observers the return value is always an empty array.
Throws a runtime error if no world is currently running.

Return value: Array of CEntityPointer with all the entities of local players in the current world.


World.GetMaxPlayers()

Returns maximum amount of player entities that may exist in the world. Equivalent to the engine's CEntity::GetMaxPlayers().
Throws a runtime error if no world is currently running.

Return value: integer


World.GetPlayerEntity(player)

Returns player entity under the specified player index from 0 to World.GetMaxPlayers() - 1 (may be none). Equivalent to the engine's CEntity::GetPlayerEntity().
Throws a runtime error if no world is currently running.

Arguments:

  • player - Index of the player entity to retrieve a pointer to.

Return value: CEntityPointer

Clone this wiki locally