Verge Lua API
Script the client with Lua โ callbacks, drawing, entities, items, physics, all exposed. Write a file, load it, done.
Your first script
Drop this in <TF2>\Verge\lua\hello.lua, then load it from the Lua tab in the menu or type lua_load hello in the console:
local function on_draw()
draw.Color(255, 255, 255, 255)
draw.Text(10, 10, "hello from Lua")
end
callbacks.Register("Draw", on_draw)
You should see hello from Lua in the top-left corner. print("hi") writes to the console and the Output tab; notify("hi") pops a toast; printc(255, 0, 0, 255, "red") prints in color.
How scripts run
Everything runs through callbacks โ register a function for an event and Verge calls it when that event fires:
callbacks.Register("CreateMove", function(cmd)
-- every command, before it is sent: buttons, angles, movement
end)
callbacks.Register("Draw", function()
-- every frame: draw on screen here
end)
callbacks.Register("FireGameEvent", function(ev)
-- every game event: player_hurt, round_start, ...
if ev:GetName() == "player_hurt" then
print("someone got hurt")
end
end)
callbacks.Register("Unload", function()
-- when the script is unloaded or reloaded
end)
Every event the client can receive is listed on the GameEvent page โ all 226 of them.
What's available
Namespaces group related functions: draw, client, entities, input, engine, vector, materials, render, ImGui, and more. Classes are objects with methods: Entity (ent:GetHealth()), Vector3 (Vector3(x, y, z)), UserCmd, Trace, GameEvent. Constants like IN_JUMP, KEY_1, MASK_SOLID and the E_* enums are globals โ see Constants.
Folder & auto-loading
All scripts live under <TF2>\Verge\lua\. Paths are relative to it and skip the .lua extension.
Verge\lua\
โโ autoexec\ every .lua here loads at inject (recursively)
โโ hello.lua
Console commands:
lua_load hello load a script
lua_unload hello unload a script
lua_reload hello reload a script
lua_do print(123) run code directly
lua_list list loaded scripts
Isolation & helpers
- Each script runs in its own environment โ globals are per-script unless you set
_G. LoadScript,UnloadScriptandGetScriptNameare available in every script.require("util")pulls inVerge\lua\util.lua.