touch Sample Code
Examples
-- One-liner style:
touch.on(306, 300):step_len(2):step_delay(0):move(350, 800):msleep(1000):off()
--
-- Expanded style:
touch.on(306, 300) -- touch at 306,300
:step_len(2) -- set step length to 2
:step_delay(0) -- set per-step delay to 0
:move(350, 800) -- move to 350,800 with the above settings
:msleep(1000) -- wait 1000 ms (1 second)
:off() -- lift finger
--
-- Using a variable:
local te = touch.on(306,300)
te:step_len(2)
te:step_delay(0)
te:move(350, 800)
te:msleep(1000)
te:off()
--
-- Typical slide sequence:
touch.on(306, 300)
:move(350, 800)
:msleep(1000)
:off()
--
-- Equivalent one-liner:
touch.on(306, 300):move(350, 800):msleep(1000):off()
--
-- Simulate a tap using on+delay+off:
touch.on(306, 300):msleep(30):off()
--
Tips for fast and precise swipes
-- Fast and precise swiping may need some tuning, see below:
touch.on(125, 2000) -- press at start position
:step_len(10) -- longer step for faster move
:move(125, 555) -- quickly move close to the target
:step_len(1) -- shorter step to buffer and avoid overshoot
:move(125, 505) -- slow approach to the target
:delay(100) -- wait before lifting
:off() -- lift finger