Multi-Client Management
Spawn / remove / iterate clients from a script. Most scripts run with the implicit getClient() parent, but the multi-client globals are useful for orchestration scripts (open the Scripts page, run once, drive every bot).
addClient() -- new bot, random device id
addClient("deviceId") -- new bot, specific device id
addClient("email", "password") -- attach an existing account
removeClient("emailOrDeviceId") -- detach + disconnect
getClient("emailOrDeviceId") -- by identity
getClient() -- the script's parent
getClients() -- all spawned
for i, client in pairs(getClients()) do
-- per-bot work
end
Globals
getClient(key?)
| Field | Type |
|---|---|
| Signature | (key: string?) → Client? |
| Returns | Client? — nil when no parent is bound (e.g. global executor with no explicit parent), or the lookup key didn't match a known bot |
| Common errors | "getClient: expected string or nil" (passed something that wasn't a string), "client not found: <key>" (key looked valid but no bot matched) |
| Async | yes |
Returns the parent client (the bot whose :scripting():execute() ran this script). key is optional — pass an email / bot id / device id to look up a sibling bot.
local me = getClient()
getClients()
| Field | Type |
|---|---|
| Signature | () → {Client} |
| Returns | {Client} — 1-indexed table of every spawned bot at call time |
| Async | yes |
for i, client in ipairs(getClients()) do
print(i, client.id, client.username)
end
addClient() / addClient(deviceId) / addClient(email, password)
| Field | Type |
|---|---|
| Signature | (...) → Client? |
| Returns | Client? — nil when the manager refused to create the bot (auth failure, capacity, etc.) |
| Common errors | "addClient: expected (), (deviceId), or (email, password)" (bad single-arg shape), "addClient: too many args" (more than 2 args) |
| Async | yes |
Three call shapes:
| Call | Auth |
|---|---|
addClient() | New Android device, random device id |
addClient("deviceId") | New Android device, specific device id |
addClient("email", "password") | Attach an existing email/password account |
local fresh = addClient() -- random device id
local exact = addClient("PWORLDSANDROID-1234567890ABCD") -- specific device
removeClient(emailOrId)
| Field | Type |
|---|---|
| Signature | (emailOrId: string) → boolean |
| Returns | boolean — true when a matching bot was detached + disconnected; false when the key didn't match anything |
| Async | yes |
Accepts the same identity shapes as getClient(key) (email, bot id, or device id).
Run something across every bot
Pair with runThread for parallel dispatch:
for _, b in ipairs(getClients()) do
runThread(function()
b:warp("MYWORLD")
end)
end