How To Call It
VisualTarget is a singleton global table: call its functions with a dot (VisualTarget.<method>(...)).
Visual target tracking: describe several views of one target with profile, find it on each frame with step, and follow its moving or lost status.
Documented for app version 1.0.51Updated:
VisualTarget is a singleton global table: call its functions with a dot (VisualTarget.<method>(...)).
In detection flow, refresh the screen with Snap.screenRefresh() first, then narrow the search area and confidence using Region and FindParam.
VisualTarget offers 7 methods; each method page lists its parameters and return value.
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.
local profile = VisualTarget.profile("enemy", { { name = "front", template = Asset.image("enemy_front") } })
local state = VisualTarget.step(profile, Region())
if state.found then VisualTarget.click(profile) endFrom 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.
local profile = VisualTarget.profile("enemy", { { name = "front", template = Asset.image("enemy_front") } })
local state = VisualTarget.step(profile, Region())
if state.found then VisualTarget.click(profile) endlocal profile = VisualTarget.profile("enemy", { { name = "front", template = Asset.image("enemy_front") } })
local state = VisualTarget.step(profile, Region())
if state.found then VisualTarget.click(profile) end
-- Continue with one focused method on the object.local profile = VisualTarget.profile("enemy", { { name = "front", template = Asset.image("enemy_front") } })
local state = VisualTarget.step(profile, Region())
if state.found then VisualTarget.click(profile) end
local note = "VisualTarget overview loaded"
print(note)-- In detection flow, refresh the screen with Snap.screenRefresh() first, then narrow the search area and confidence using Region and FindParam.
local function run_visualtarget_step()
local profile = VisualTarget.profile("enemy", { { name = "front", template = Asset.image("enemy_front") } })
local state = VisualTarget.step(profile, Region())
if state.found then VisualTarget.click(profile) end
end
local ok, err = pcall(run_visualtarget_step)
if not ok then
toast("Step failed")
print(err)
endSnap.screenRefresh()
local profile = VisualTarget.profile("enemy", { { name = "front", template = Asset.image("enemy_front") } })
local state = VisualTarget.step(profile, Region())
if state.found then VisualTarget.click(profile) end
local target = Region():find(Asset.image("target"), FindParam.timeout(3000))
if target then
quickTap(target)
end
toast("Detection step completed")