How To Call It
This is a function of the Region factory table itself: call it with a dot (Region.<method>(...)); no Region object is needed. An object method with the same name also exists: region:scale(...).
Region.scale(x, y, w, h, edges) maps an area in macro coordinates to the device screen and returns a Region anchored to the given edges (edges: a sum of the LEFT, TOP, RIGHT and BOTTOM constants). On a Region object, region:scale(factor) multiplies its position and size by the factor instead.
Documented for app version 1.0.51Updated:
This is a function of the Region factory table itself: call it with a dot (Region.<method>(...)); no Region object is needed. An object method with the same name also exists: region:scale(...).
In detection flow, refresh the screen with Snap.screenRefresh() first, then narrow the search area and confidence using Region and FindParam.
Required: x, y. Optional: w, h, edges (omit to pass nil and use the runtime default). Returns a Region object.
It is typically combined with Snap, Region, Asset, and FindParam; you can feed the result into quickTap(), click(), or a follow-up OCR step.
The snippet below is a starter pattern that can be applied directly in runtime flow.
-- A 400 x 120 bar anchored to the right edge of the screen
local bar = Region.scale(600, 40, 400, 120, RIGHT)
local half = Region():scale(0.5)From foundation to combined usage, each level is provided as a separate code block so you can copy the level you need and adapt it directly.
-- A 400 x 120 bar anchored to the right edge of the screen
local bar = Region.scale(600, 40, 400, 120, RIGHT)
local half = Region():scale(0.5)local stepOk = true
-- A 400 x 120 bar anchored to the right edge of the screen
local bar = Region.scale(600, 40, 400, 120, RIGHT)
local half = Region():scale(0.5)
if stepOk then
wait(200)
endlocal ok, err = pcall(function()
-- A 400 x 120 bar anchored to the right edge of the screen
local bar = Region.scale(600, 40, 400, 120, RIGHT)
local half = Region():scale(0.5)
end)
if not ok then
print("API step failed: Region.scale: " .. tostring(err))
requestStop()
end-- In detection flow, refresh the screen with Snap.screenRefresh() first, then narrow the search area and confidence using Region and FindParam.
local function run_scale_step()
-- A 400 x 120 bar anchored to the right edge of the screen
local bar = Region.scale(600, 40, 400, 120, RIGHT)
local half = Region():scale(0.5)
end
local ok, err = pcall(run_scale_step)
if not ok then
toast("Step failed")
print(err)
endSnap.screenRefresh()
-- A 400 x 120 bar anchored to the right edge of the screen
local bar = Region.scale(600, 40, 400, 120, RIGHT)
local half = Region():scale(0.5)
local target = Region():find(Asset.image("target"), FindParam.timeout(3000))
if target then
quickTap(target)
end
toast("Detection step completed")