world
Players, NPCs, entities, round state, screen projection, traces, autowall and dynamic lights; traces work in on_paint and on_create_move.
Functions
world.get_player
world.get_player(index) -> Entity | nil| Name | Type | Description |
|---|---|---|
| index | integer | 1 to engine.max_players(). |
Connected player by slot.
nil for empty or non-player slots.
world.get_players
world.get_players([enemies_only]) -> Entity[]| Name | Type | Description |
|---|---|---|
| enemies_onlyoptional | boolean | true skips your team. Default false. |
Connected players except you, as an array.
enemies_only compares team numbers; empty when all share a team.
world.get_entities
world.get_entities([model_filter]) -> Entity[]| Name | Type | Description |
|---|---|---|
| model_filteroptional | string | Case-sensitive model path substring, like "w_c4". |
Non-player entities with models: grenades, weapons, C4, hostages, NPCs, brushes.
Empty table when not in game.
world.get_entity
world.get_entity(index) -> Entity | nil| Name | Type |
|---|---|
| index | integer |
Any live entity by index.
nil if out of range, free or dead.
world.get_npcs
world.get_npcs([enemies_only]) -> Entity[]| Name | Type | Description |
|---|---|---|
| enemies_onlyoptional | boolean | true drops friendly NPCs. Default false. |
NPCs the aim and ESP target, including recently unseen ones.
Empty when not in game.
world.bomb
world.bomb() -> tableThe bomb (Counter-Strike).
Returns {state, planted, defused, position, in_view, carrier, plant_time, time_left, total, defuser, defuse_progress, damage}, nil when there is none
- state: "carried", "dropped", "planted" or "defused".
- position: the bomb when in view, else its radar spot, else the carrier.
- defuser / defuse_progress are a guess: the game does not send them.
- damage: to you from where you stand, armor ignored.
- A dropped bomb's radar spot only reaches terrorists.
world.grenades
world.grenades() -> table[]Live grenades in view.
Returns {index, type, position, velocity, fuse, land, land_time} each
- type: "he", "flash", "smoke" (Counter-Strike).
- fuse: seconds left, nil for smoke. land / land_time: where its flight ends and when.
world.predict_grenade
world.predict_grenade([position, velocity [, fuse]]) -> table| Name | Type | Description |
|---|---|---|
| positionoptional | Vector | |
| velocityoptional | Vector | |
| fuseoptional | number | Stop the path here (HE / flash: 1.5). Default until it rests. |
The toss path with its bounces. No arguments: the grenade in your hand.
Returns {points, land, time} | nil
world.local_throw
world.local_throw() -> tableHow the grenade in your hand would leave if you threw it now.
Returns {position, velocity, fuse} | nil when you hold none
world.round_time
world.round_time() -> numberHUD round timer, seconds left; correct when loaded mid-round.
0 when unknown; never negative.
world.world_to_screen
world.world_to_screen(pos) -> number, number | nil| Name | Type |
|---|---|
| pos | Vector |
Projects a world point to the screen.
Returns x, y in pixels, or nil
One nil when behind the camera or off screen.
world.box_to_screen
world.box_to_screen(mins, maxs) -> number, number, number, number | nil| Name | Type | Description |
|---|---|---|
| mins | Vector | Minimum corner. |
| maxs | Vector | Maximum corner. |
Screen rect around an axis-aligned world box, for 2D ESP.
Returns x, y, w, h pixels, or nil
nil unless all eight corners project.
world.trace_line
world.trace_line(start, end [, mask [, ignore]]) -> trace | nil| Name | Type | Description |
|---|---|---|
| start | Vector | |
| end | Vector | |
| maskoptional | integer | world.MASK_* flags, combined with |. Default world.MASK_NORMAL. |
| ignoreoptional | Entity | integer | Entity or index to pass through. Default nil (ignore nothing). |
Point trace against world, brush entities and players; never hits you.
Returns Result table (see fields), or nil.
nil without the engine trace interface.
world.trace_hull
world.trace_hull(start, end [, hull [, mask [, ignore]]]) -> trace | nil| Name | Type | Description |
|---|---|---|
| start | Vector | Hull centre. |
| end | Vector | |
| hulloptional | integer | HULL_* or 3 (large), clamped. Default world.HULL_REGULAR. |
| maskoptional | integer | world.MASK_* flags. Default world.MASK_NORMAL. |
| ignoreoptional | Entity | integer | Entity or index to pass through. Default nil. |
Sweeps a player hull, to test fit or landing spots.
Returns Result table (see fields), or nil.
Never hits you; nil without the trace interface.
world.is_visible
world.is_visible(from, to [, ignore]) -> boolean, Vector| Name | Type | Description |
|---|---|---|
| from | Vector | Eye or start position. |
| to | Vector | |
| ignoreoptional | Entity | integer | Target entity, so it doesn't block. Default nil. |
Line of sight ignoring glass; visible past 99% of the distance.
Returns visible, and where the trace stopped
Returns false and to without the trace interface.
world.trace_bullet
world.trace_bullet(from, to) -> number| Name | Type | Description |
|---|---|---|
| from | Vector | Shot origin, usually your eye. |
| to | Vector | Impact point. |
Autowall: bullet damage with wall penetration and distance falloff.
Returns Damage at to, 0 if blocked.
- Uses your held weapon's stats; 0 when not in game.
- Ignores armour and hitgroup multipliers.
world.dlight
world.dlight(origin, radius, r, g, b [, life [, decay [, elight [, key]]]])| Name | Type | Description |
|---|---|---|
| origin | Vector | |
| radius | number | World units. |
| r | number | 0 to 255, clamped. |
| g | number | 0 to 255, clamped. |
| b | number | 0 to 255, clamped. |
| lifeoptional | number | Pulse seconds, min 0.01. Default 0.1. |
| decayoptional | number | Radius shrink per second. Default 0. |
| elightoptional | boolean | true lights only models. Default false. |
| keyoptional | integer | 0 takes any free slot; else reused. Default 0. |
Spawns a short-lived engine dynamic light; call every frame to keep it.
- Give moving lights their own key (like 1000 + i) to avoid stacking.
- Does nothing out of game or with no free slot.
world.map_entities
world.map_entities([classname]) -> table[]| Name | Type | Description |
|---|---|---|
| classnameoptional | string | Exact name, or a prefix ending in * like "func_*". |
Entities the map spawns with, read from the map file.
Returns {classname, origin, angles, targetname, model, index, keys}
- Cached per map. Players and dropped weapons are not in it.
- keys has every key/value as strings; brush entities without origin get their brush centre.
Fields
world.trace_line() / world.trace_hull() result table
| Name | Type | Description |
|---|---|---|
| fraction | number | 0 to 1 of the path covered; 1 = no hit. |
| hit | boolean | fraction < 1. |
| endpos | Vector | Where the trace stopped. |
| normal | Vector | Hit plane normal. |
| plane_dist | number | Hit plane distance from origin. |
| allsolid | boolean | Entire trace inside solid. |
| startsolid | boolean | Start point inside solid. |
| in_open | boolean | Passed through empty space. |
| in_water | boolean | Passed through water. |
| hitgroup | integer | Body part hit; 0 for non-hitbox. |
| ent_index | integer | Entity hit, 0 = world. |
| entity | Entity | Hit entity; only for tracked live entities. |
Constants
| Name | Value | Description |
|---|---|---|
| world.HULL_REGULAR | 0 | Standing hull, 32x32x72. |
| world.HULL_DUCKED | 1 | Ducked hull, 32x32x36. |
| world.HULL_POINT | 2 | Zero-size; trace_line always uses it. |
| world.MASK_NORMAL | 0 | Hits world, brush entities, players. |
| world.MASK_STUDIO_IGNORE | 1 | Skips studio models. |
| world.MASK_STUDIO_BOX | 2 | Bounding boxes instead of hitboxes. |
| world.MASK_GLASS_IGNORE | 4 | Ignores glass and see-through render modes. |
| world.MASK_WORLD | 8 | World only. |