Lua · Documentation
Variables
Every function on one page. Click one for its arguments, return values and an example.
Namespaces are plain global tables. [settings], [chat] and [network] mark calls that need a permission.
color Core
color(r, g, b[, a]) |
Packs four channels into one colour. Values outside 0 to 255 are clamped. |
color.rgba(r, g, b[, a]) |
Same as color(r, g, b, a). |
color.unpack(c) |
Splits a colour back into its channels. |
color.alpha(c, a) |
Returns the same colour with a new alpha. The best way to fade something in or out. |
color.lerp(a, b, t) |
Mixes two colours. t = 0 gives a, t = 1 gives b. Keep t between 0 and 1. |
color.hsv(h, s, v[, a]) |
Makes a colour from hue, saturation and value. Handy for rainbow effects. |
util and print Core
print(...) |
Writes all arguments to the console, separated by two spaces. Tables print as their address; use json.encode to see what is inside. |
util.print(...) |
Same as print. |
util.time() |
Seconds since the program started, with decimals. Use it for timers and animation. |
util.random(a, b) |
A random whole number from a to b, both included. The order does not matter. |
input Core
input.key_down(vk) |
True while the key is held. |
input.key_pressed(vk) |
True only on the frame the key went down. Use it for toggles. |
input.mouse() |
The Windows cursor position in screen pixels. |
input.mouse_down([button]) |
True while a mouse button is held. |
game Game state
game.local_player() |
You, as a player table. nil when you are dead or not in a match. |
game.players() |
All living players, you included. |
game.map() |
The map name, for example de_mirage. Empty until it is known. |
game.mode() |
The game mode: Competitive, Premier, Casual, Wingman, Deathmatch, Arms Race, or Community - … on community servers. Empty until known. |
game.in_match() |
True while you are in a match (not in the main menu or loading). |
game.time() |
Seconds since the current round started. 0 until the first round start is seen. |
game.round() |
The current round number, starting at 1. |
entity Game state
entity.players() |
All living players with full detail. |
entity.get(slot) |
One player by slot, or nil. |
entity.local_player() |
You with full detail, plus view_angles. nil when dead. |
entity.grenades() |
Grenades in the world and fires on the ground. Same as nade.list(). |
entity.c4() |
The bomb. Same as bomb.state(). |
entity.weapons() |
Weapons and items lying on the ground. |
entity.hostages() |
Hostages on hostage maps. |
globals Game state
globals.time() |
Seconds since the program started. Same as util.time(). |
globals.frametime() |
Seconds the last frame took. Multiply speeds by it so animation is the same at any FPS. |
globals.frame() |
A frame counter that goes up by one every frame. |
globals.map() |
Map name. Same as game.map(). |
globals.round() |
Round number. Same as game.round(). |
globals.round_time() |
Seconds since the round started. Same as game.time(). |
globals.in_match() |
True in a match. |
globals.menu_open() |
True while the Adolfjon menu is open. |
globals.screen() |
Screen size in pixels. Same as draw.screen(). |
globals.score() |
Team scores. -1 until known. The first call starts reading; values arrive within a second and refresh twice a second while you keep asking. |
server Game state
server.address() |
The server address as text, or empty. |
server.kind() |
What kind of server: 0 none, 1 local (offline or listen server), 2 direct IP, 3 Valve relay (matchmaking). |
server.mode() |
Game mode text. Same as game.mode(). |
draw Drawing
draw.screen() |
Screen size in pixels. |
draw.line(x1, y1, x2, y2, col[, thickness]) |
A straight line. |
draw.rect(x, y, w, h, col[, rounding][, thickness]) |
A rectangle outline. |
draw.rect_filled(x, y, w, h, col[, rounding]) |
A filled rectangle. |
draw.circle(x, y, radius, col[, thickness]) |
A circle outline. |
draw.circle_filled(x, y, radius, col) |
A filled circle. |
draw.text(x, y, text, col[, size]) |
Text in the menu font. (x, y) is the top-left corner of the text. |
draw.text_size(text[, size]) |
How big the text will be. Use it to centre or right-align. |
draw.text_outline(x, y, text, col[, size]) |
Text with a thin black outline, readable on any background. |
draw.gradient(x, y, w, h, col1, col2[, horizontal]) |
A rectangle that fades from one colour to another. |
draw.polygon(points, col) |
A filled convex shape (triangle, arrow, diamond). Concave shapes draw wrong. |
draw.polyline(points, col[, thickness][, closed]) |
Connected lines through the points. |
draw.world_to_screen(x, y, z) |
Turns a world position into screen pixels. Takes three numbers, not a vector. |
draw.line3d(a, b, col[, thickness]) |
A line between two world points. Drawn only when both ends are in front of the camera. |
draw.circle3d(center, radius, col[, thickness]) |
A flat circle on the ground around a world point (32 segments). |
draw.box3d(min, max, col[, thickness]) |
A 3D box outline between two corners. |
draw.load_image(file) |
Loads a PNG or JPG from the script's data folder. Do it once, outside on_frame. |
draw.load_image_data(bytes) |
Loads an image from bytes in memory, for example the body of an http.get reply. |
draw.image(handle, x, y, w, h[, tint][, rounding]) |
Draws an image. |
draw.image_size(handle) |
Original size of a loaded image. 0, 0 for a bad handle. |
draw.load_font(file[, size]) |
Loads a .ttf, .otf or .ttc font. Looks in the script's data folder first, then in Windows\Fonts. |
draw.font_ready(handle) |
True once the font can be used. |
draw.text_font(handle, x, y, text, col[, size]) |
Text in a loaded font. Uses the menu font until the font is ready. |
draw.text_size_font(handle, text[, size]) |
Text size in a loaded font. |
hud Drawing
hud.panel(id, title, w, h) |
Draws a panel with a header and returns where its content area starts. |
ui Script UI
ui.checkbox(id, label[, default]) |
An on/off switch. |
ui.slider(id, label, min, max[, default]) |
A number slider. Whole numbers when min, max and default are all whole and the range is at least 2; otherwise two decimals. |
ui.combo(id, label, items[, default]) |
A dropdown. |
ui.color(id, label[, default]) |
A colour picker with alpha. |
ui.keybind(id, label[, default]) |
A key picker. |
ui.get(id) |
The current value of a control made with the functions above. |
menu Script UI
menu.text(text) |
A line of text. |
menu.section(title) |
A section heading. |
menu.separator() |
A thin line. |
menu.spacing() |
Some empty space. |
menu.same_line() |
Puts the next widget to the right of the last button. Works only right after a button. |
menu.button(label) |
A button. |
menu.checkbox(label, value) |
A checkbox. |
menu.slider(label, value, min, max[, decimals]) |
A slider. |
menu.combo(label, index, items) |
A dropdown. |
menu.color(label, col) |
A colour picker. |
menu.keybind(label, vk) |
A key picker. |
menu.input(label, text) |
A one-line text field, up to 255 bytes. |
menu.tooltip(text) |
A hover tooltip on the widget drawn just before it. |
menu.progress(label, value) |
A progress bar. |
menu.list(label, selected, items[, rows]) |
A scrolling list. |
menu.image(handle, w, h) |
An image from draw.load_image. The width is capped to the page width. |
notepad Script UI
notepad.open(id[, title][, text][, options]) |
Opens (or brings back) a notepad. |
notepad.set_text(id, text) |
Replaces the text and marks it saved. |
notepad.get_text(id) |
The current text. Empty when not open. |
notepad.close(id) |
Closes it. |
notepad.is_open(id) |
True while open. |
aim Features
aim.enabled([on]) settings |
Returns whether the aimbot is on. Pass true or false to change it. |
aim.target() |
The player the aimbot is locked on, or nil. |
aim.info() |
What the aimbot is doing this frame. |
trigger Features
trigger.enabled([on]) settings |
Returns whether the triggerbot is on. Pass a value to change it. |
weapon Features
weapon.info([slot]) |
Your weapon, or the one held by that player. |
bomb Features
bomb.state() |
Everything about the bomb. Same as entity.c4(). |
nade Features
nade.list() |
Grenades in the world. Same as entity.grenades(). |
nade.held() |
The predicted path of the grenade you are holding, or nil. |
spectators Features
spectators.list() |
Players spectating you right now. |
velocity Features
velocity.state() |
Movement stats. Speeds are in units per second. |
keystrokes Features
keystrokes.state() |
Physical key states, plus clicks per second. |
esp Features
esp.add_text(slot, text[, col]) |
Adds a line under that player's ESP box for this frame. Call it every frame you want it shown. Needs ESP to be on. |
notify Features
notify.push(text[, damage][, hp]) |
Adds a line to the notification feed, in the user's chosen style. |
players Features
players.flag(steamid[, flag]) settings |
Reads a player's flag in the player list, or sets it. |
players.color(steamid[, col]) settings |
Reads or sets a player's custom colour. |
players.intel(steamid) |
Public stats. The first call starts loading them; it returns nil until they arrive, so call it again on later frames. |
config Settings
config.sections() |
The section names. |
config.list(path) |
Key names inside a section or object, in alphabetical order. Empty for arrays and plain values. |
config.get(path) |
The current value. Arrays and colours come back as tables (colours are {r, g, b, a} from 0 to 1). |
config.set(path, value) settings |
Changes a setting. |
map World
map.ready() |
True when map data is loaded. |
map.name() |
The map that is loaded. |
map.visible(a, b) |
True when nothing solid is between two points. |
map.penetrate(a, b[, bullet]) |
Damage a bullet from a to b would do through walls. |
map.trace(a, b[, radius]) |
Casts a ray (or a ball when radius is set) from a to b against the map. |
map.ground(pos[, depth]) |
The floor under a point. |
world World
world.aim([range]) |
Where your crosshair points on the map. |
world.marker(pos[, options]) |
A dot with optional text, ring, vertical beam and icon. |
world.zone(options) |
A circle (pos + radius, height = vertical reach, default 128) or a box (min + max). Fires zone_enter / zone_leave for this script when you walk in or out. |
world.path(points[, options]) |
A line through 2 to 512 points. arrows adds direction marks, dashed breaks it up. |
world.decal(image, pos[, options]) |
A picture from draw.load_image placed in the world. With normal it lies flat on that surface; without it always faces you. size is in units (default 32). |
world.set(id, options) |
Changes options (and pos) of an object. |
world.move(id, pos) |
Moves an object. |
world.remove(id) |
Deletes an object. |
world.clear() |
Deletes all of this script's objects. |
world.count() |
How many objects this script has. |
world.inside(id) |
True while you stand in that zone. |
world.list() |
This script's objects. |
world.save([name]) |
Writes markers, zones and paths to world_<name>.json in the data folder. Default name is the map. |
world.load([name]) |
Adds the objects saved under that name. |
view World
view.window(x, y, w, h, options) |
Shows the map from any point. Call it in on_frame every frame you want it. |
vpk World
vpk.read(entry, callback[, source]) |
Reads one file by its exact path, on a worker thread. The callback runs later on the render thread. |
sound Sound
sound.play(file[, volume][, options]) |
Plays a WAV. |
sound.play_at(file, pos[, volume][, range]) |
Plays a WAV as if it came from a point: quieter with distance, panned left or right from where you look. Silent past range (default 2000). |
sound.tone(hz[, seconds][, volume][, pan]) |
A beep without any file. 20 to 12000 Hz, 0.02 to 5 s (default 0.15), volume default 0.6. |
sound.stop(id) |
Stops one of this script's sounds. |
sound.stop_all() |
Stops all of this script's sounds. |
sound.playing(id) |
True while that sound plays. |
sound.list() |
WAV files in the data folder. |
sound.speak(text[, rate]) |
Reads text aloud with a Windows voice. Queued, up to 8 lines of 240 characters. Rate -10 to 10. |
sound.speak_stop() |
Stops speaking and clears the queue. |
json Storage and web
json.encode(value) |
A table, string, number or boolean as JSON text. A table with keys 1..n becomes an array; others become objects (keys that are not strings are dropped). Up to 16 levels deep. |
json.decode(text) |
JSON text as Lua values. nil when the text is not valid JSON. |
db Storage and web
db.get(key) |
A saved value, or nil. |
db.set(key, value) |
Saves a value. nil deletes the key. |
files Storage and web
files.read(name) |
The file contents, or nil. |
files.write(name, text) |
Writes (replaces) a file. |
files.list() |
File names in the folder. |
files.remove(name) |
Deletes a file. |
http Storage and web
http.get(url, callback) network |
Starts a GET request on a worker thread. The callback runs later on the render thread. |
clipboard Storage and web
clipboard.get() |
The clipboard text. |
clipboard.set(text) |
Copies text. |
events Helpers
events.on(name, handler) |
Adds a handler. Several handlers for one event all run, in the order added. |
events.off(name) |
Removes all handlers of that event. |
timer Helpers
timer.after(seconds, fn) |
Runs fn once after that many seconds. |
timer.every(seconds, fn) |
Runs fn every that many seconds. |
timer.cancel(id) |
Stops a timer. |
math extras Helpers
math.clamp(v, min, max) |
Keeps v inside min to max. |
math.lerp(a, b, t) |
a + (b - a) * t. |
math.round(v) |
Nearest whole number (halves go up). |
math.distance(a, b) |
Distance between two vectors. |
math.angle_to(from, to) |
View angles that look from one point at another, in degrees (negative pitch is up, the game's own convention). |
vec Helpers
vec.new([x][, y][, z]) |
A new vector. Missing parts are 0. |
vec.add(a, b) |
a + b. |
vec.sub(a, b) |
a - b. |
vec.scale(a, s) |
a * s. |
vec.dot(a, b) |
Dot product. |
vec.length(a) |
Length. |
vec.distance(a, b) |
Distance. |
vec.normalize(a) |
Same direction, length 1. A zero vector stays zero. |
bit Helpers
bit.band(a, b) |
a & b. |
bit.bor(a, b) |
a | b. |
bit.bxor(a, b) |
a ~ b. |
bit.bnot(a) |
~a. |
bit.lshift(a, n) |
a << n. |
bit.rshift(a, n) |
a >> n. |
No function matches.