> Agent-readable docs index: /llms.txt. Download /docs.zip to grep all markdown files locally.

---
title: Globals and Modules
icon: package
sidebar_position: 5
---

# Globals and Modules

Some names are available directly in every script. Other features are modules:
declare them in the manifest, and your own files are loaded with `require`.

## Common globals

You can use these without `require`:

<Columns cols={2}>
  <Column>
    **Neverlose namespaces**

    ```lua lines=false
    events.render(function() end)
    local tab = ui.AddTab("Lua")
    local pawn = entity.GetLocalPawn()
    local t = schema.client["C_CSPlayerPawn"]
    ```
  </Column>

  <Column>
    **Value constructors**

    ```lua lines=false
    local p3 = Vector(0, 0, 0)
    local p2 = Vector2D(20, 20)
    local a = QAngle(0, 90, 0)
    local c = Color(255, 255, 255)
    ```
  </Column>
</Columns>

Constructor names match their types: `Vector`, `Vector2D`, `QAngle`, and
`Color`. Functions and methods also use their documented capitalization, such
as `entity.GetLocalPawn()` and `pawn:IsValid()`.

## Standard Lua libraries

Neverlose keeps the Lua helpers you normally use for scripting:

```lua luaintelligence=true lines=false semantic="lua:cs2:cs2/api_reference/extensions/globals-and-modules:2:33ace87d51e5"
local items = { "ak47", "m4a1", "awp" }

for index, name in ipairs(items) do
    print(index, ": ", string.upper(name))
end
```

Standard globals include `math`, `bit`, `string`, `jit`, `table`, and
`coroutine`. `json` and `msgpack` are globals too. Loading `table.new` or
`table.clear` with `require` does not need a manifest requirement. The [Lua
reference](/cs2/api_reference/lua/base) documents the available library surface;
clock functions live in [`time`](/cs2/api_reference/runtime/time).

## Modules

Native capabilities such as [`http`](/cs2/api_reference/networking/http), `ffi`,
and `filesystem`, marketplace libraries, and sibling extensions must be declared
in the manifest. A declared module is also a global, and `require` returns that
same object. Your own files need no declaration and are loaded only with
`require`.

```lua main.lua luaintelligence=true semantic="lua:cs2:cs2/api_reference/extensions/globals-and-modules:3:3eb182ad030e"
local http = require("http")  -- declared in extension.json requirements
local helpers = require("lib/helpers")  -- lib/helpers.lua in this extension
```

[Requirements](/cs2/api_reference/extensions/requirements) covers each kind of
module, path rules, caching, and lookup precedence.

## Keeping globals clean

Prefer locals for your own values. It keeps reloads predictable and avoids
accidentally shadowing public API names.

```lua luaintelligence=true lines=false semantic="lua:cs2:cs2/api_reference/extensions/globals-and-modules:4:28bbd639ade1"
local font = render.LoadFont(render.EspFont.kRegular)
local accent = Color(130, 165, 255)

events.render(function()
    render.DrawText(Vector2D(16, 16), accent, font, nil, "Scoped locals")
end)
```
