CAPTCHA API
Use the hosted five-character image solver from a Lua module.
Import from SDK 1.7.9 with local captcha_api = require("sdk").captcha.
Store scripts can bundle the same helper as the captcha_api module and import it
with require("captcha_api"). The service handles only the game's
opaque 300×100 PNG image with five letters or digits. It does not accept custom
prompts or model names. Calls are asynchronous through the ordinary http table.
An answer is a suggestion until the game explicitly verifies it.
captcha_api.payload(image, model)
Builds the exact JSON request body for a Base64 image and "primary" or
"fallback". Returns the body, or nil, reason for invalid input. The service
checks decoded image dimensions and pixels; this helper performs only basic
string and size checks.
captcha_api.health(transport)
Queues a GET to the service health endpoint using a table with get. Returns
the positive HTTP request ID, or nil, reason. Pass the module's http table.
captcha_api.health_ready(body)
Returns true only for a ready service health response. Check the matching
request's HTTP status and error before calling this helper.
captcha_api.solve(transport, payload)
Queues a POST for a body created by captcha_api.payload. The transport must
provide post_json or post. Returns a positive request ID, or nil, reason.
The request may be rate limited. Each response arrives later in on_http.
captcha_api.answer(body)
Returns exactly five letters or digits from a successful solver reply, or
nil, reason. Check HTTP status first. Do not count an answer as solved until
the game reports approval. A lost or uncertain game submission should not be
replayed.
local captcha_api = require("sdk").captcha
local pending
function request_captcha(image_base64)
local body, reason = captcha_api.payload(image_base64, "primary")
if not body then return nil, reason end
pending = captcha_api.solve(http, body)
return pending
end
function on_http(request_id, status, body, error)
if request_id ~= pending then return end
pending = nil
if status ~= 200 or error ~= "" then return end
local answer = captcha_api.answer(body)
if answer then log.info("CAPTCHA suggestion: " .. answer) end
endThe service limits requests per client, per image, and across the service. Repeated pixels and the same model reuse a cached result. A module should stop its normal actions while a challenge is active, wait for the game's verdict, and use a refreshed image after a rejection.
Shared handler (SDK 1.7.10)
captcha_api.new(game, http, log, activity)
captcha_api.new(game, http, log, "farming") creates the shared handler.
Forward HTTP callbacks to handler:OnHttp(id, status, body, error, now) and
call handler:Poll(now) from your tick. A visible challenge returns true so
normal actions can stop immediately. Detection continues between solver polls.
The handler captures the current image, retries the hosted solver while it is fresh, fills one answer, waits at least two seconds, then invokes the game's reflected Confirm handler. Unknown results are never replayed. Existing manual text is preserved. The current native host must expose image capture, guarded text entry and reflection. An older unsupported host reports an unavailable error.
captcha_api.events(callback)
captcha_api.events(callback) creates the matching request/response observer.
Forward packets to events:OnPacket(packet, now) and pass each callback kind
to handler:OnVerification(kind). It accepts the current nine-byte server
verdict and the older eleven-byte form. Resume normal operations only after
approved and verified dialog closure. An OCR answer or submitted request
alone is not approval. A user Stop cancels any pending resume.