# Proxy Executor scripting API (Lua 5.4) Page: https://growbgl.com/docs?app=proxy Plain text: https://growbgl.com/proxy-docs.txt Write a Lua script for your own session, open the Executor from your GrowBGL Proxy, press Run, and these are ready. One account, your screen, in-game commands and dialogs. Type executor in your proxy console to open it. ## Rules for writing a script - Plain Lua 5.4. Use only the functions, fields and events in this file. Never guess a name. If something is not here, say it cannot be done yet. - The script runs on the user's own single game session. Commands and dialogs show only on their screen. - Put sleep(ms) in every loop and give each loop a limit or a way out. - Give the whole script in one Lua code block, then one or two lines on how to start it. ## Commands & dialogs Your own slash commands and dialogs, shown only on your screen. The game server never sees them. ### addCommand `addCommand(name, fn)` Run fn(args) when you type /name in game. args is the text after the command. ### removeCommand `removeCommand(name)` Stop listening for /name. ### showConsole `showConsole(text)` Print a line in your in-game console. Color codes like `2 work. ### showDialog `showDialog(text)` Open a Growtopia dialog on your own screen (one string of dialog lines, see the AI helper for the format). ### onDialog `onDialog(name, fn)` Handle a dialog you opened. fn(values); values.buttonClicked is the button pressed, each input is values.. ## World & player Everything you can read about your session, live. Reads are instant and never send a packet. ### getLocal `getLocal()` You, or nil if not in a world: .name .netid .userid .x .y (tile) .posx .posy. ### getWorld `getWorld()` The world: .name .x (width) .y (height), and :getTiles() / :getObjects() / :getPlayers(). ### getInventory `getInventory()` Your inventory: :getItemCount(id|name), :getItem(id|name), :getItems() (each .id .count). ### getPlayers `getPlayers() / getPlayer(key)` Players in the world, all or one by netid / name: .name .netid .userid .x .y (tile) .isModerator. ### getTile `getTile(x, y) / getTiles()` A tile (.fg .bg .label .flags, :getExtra() for a lock/vend/door) or every tile. ### getObjects `getObjects() / getObject(uid)` Dropped items on the ground. A drop has .uid .id .count .tilex .tiley. ### getInfo `getInfo(id | name)` Item info from items.dat: .id .name .rarity .max_amount and more. ### bot `bot / getBot()` Your session: bot.name, bot.status, bot.world, bot.x, bot.y (tile coords). ## Actions Do things in the world. Each one sends the same packet the real client sends. ### warpTo `warpTo(world)` Warp to a world, or "WORLD|DOORID" to land on a specific door. ### walkTo `walkTo(x, y)` Pathfind and walk to a tile, avoiding blocks. ### move `bot:move(dir) / moveTo(x, y)` Walk one tile in a direction, or straight to a tile. ### face `bot:face(dir)` Face "left" or "right" without moving. ### collectNear `collectNear(range)` Pick up every dropped item within range tiles. ### place `bot:place(x, y, item)` Place a block from your inventory at a tile. ### hit `bot:hit(x, y)` Punch or break the tile at x, y (uses the Fist). ### wrench `bot:wrench(x, y)` Wrench a tile to open its menu / settings. ### wrenchPlayer `bot:wrenchPlayer(netid)` Wrench a player to open their menu. ### wear `bot:wear(id)` Wear, use, or take off an item by id. ### drop `bot:drop(id, count)` Drop items on the ground. count 0 drops the whole stack. ### trash `bot:trash(id, count)` Trash items from your inventory. count 0 trashes the stack. ### say `bot:say(text)` Send a chat message (or a /command). ### useTile `bot:useTile() / enterDoor()` Use the tile you stand on (a door, switch, or sign). ### leave `bot:leave()` Leave the current world (back to EXIT). ### respawn `bot:respawn()` Respawn at the world's checkpoint. ## Events & packets React to what the server sends, or block and rewrite packets. Start listening, then add handlers. ### listenEvents `listenEvents()` Start receiving events (call once). stopEvents() to stop. ### addEvent `addEvent(kind, fn)` Handle an event. fn(ev, netid); kind = Event.text / Event.call / Event.any. ### removeEvent `removeEvent(kind) / removeEvents()` Drop one kind of handler, or all of them. ### onPacket `onPacket(dir, fn)` Block or rewrite a packet before it passes. dir = "in" / "out" / "any"; fn(ev) returns true to drop it, or a hex string to replace it. ### removePacketHook `removePacketHook(dir)` Stop a packet hook, or all with no dir. ### ev:get `ev:get(i):getString() / getInt() / getFloat()` Read a value out of a call event (variant list). ### ev fields `ev.type / ev.text / ev.netid / ev:size()` The event's kind, its text, who it is about, and how many values it carries. ## Enums Named constants so your checks read clearly, e.g. bot.status == BotStatus.online. ### BotStatus `BotStatus.online / account_banned / mod_entered / ...` Every status your session can report. ### VariantType `VariantType.float / int32 / uint32 / string / vector2 / ...` The type of a value inside a call event. ### GeigerArea `GeigerArea.red / yellow / green / rapid / prize` Geiger (surgery) zones. ### Role `Role.farm / build / surg / fish / cook` Bot roles. ### Bubble `Bubble.none / talk / brb` Chat-bubble states. ## HTTP & Discord Call a web API or post to a Discord webhook straight from a script (direct, not through the proxy). ### HttpClient `HttpClient.new()` :setMethod(m):request() -> { status, body }. Set .url, .headers, .content first. The script's other threads keep running while it waits. ### Webhook `Webhook.new(url)` Post to a Discord webhook: :send() with content, username, embeds. ### Embed `Embed.new()` Build a Discord embed: :addField(name, value, inline). ## Raw packets & utilities For power users: send anything, plus the small helpers every script leans on. ### sendRaw `sendRaw(hex)` Send a raw packet (hex) to the server. ### sendClientRaw `sendClientRaw(hex)` Send a raw packet (hex) to your own game client. ### sendPacket `bot:sendPacket(type, body)` Send a text packet (type 2 = generic text, 3 = game message). ### sleep `sleep(ms) / wait(ms)` Pause the script without freezing the session. ### runThread `runThread(fn)` Run fn in the background alongside your script. ### print `print(...) / log(...)` Print to the Executor Output tab. ### removeColor `removeColor(text)` Strip color codes from a string.