Watchmaker Wiki

The ultimate watch maker for Android Wear!

User Tools

Site Tools


lua

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
lua [2017/08/08 14:24] – [Run Lua Function Every Second or Millisecond] alex_curranlua [2024/10/20 20:29] (current) – Added volume controls frutejuise
Line 143: Line 143:
 ===== Run Lua Function Every Hour, Minute, Second or Millisecond ===== ===== Run Lua Function Every Hour, Minute, Second or Millisecond =====
  
-    function on_hour(h)     - every hour (h = hour) +    function on_hour(h)           - every hour (h = hour) 
-    function on_minute(h, m)   - every minute (h = hour, m = minute)+    function on_minute(h, m)      - every minute (h = hour, m = minute)
     function on_second(h, m, s)   - every second (h = hour, m = minute, s = second)     function on_second(h, m, s)   - every second (h = hour, m = minute, s = second)
     function on_millisecond(dt)   - every millisecond (dt = delta time)     function on_millisecond(dt)   - every millisecond (dt = delta time)
Line 207: Line 207:
 ===== WatchMaker Lua API ===== ===== WatchMaker Lua API =====
  
-WatchMaker extends the Lua commandset. Just use the wm_action() or other functions anywhere in your script or tap actions :+WatchMaker extends the Lua commandset. Just use the wm_action() or other functions anywhere in your script or tap actions:
  
     wm_action('sw_start_stop'         -- start or stop the stopwatch     wm_action('sw_start_stop'         -- start or stop the stopwatch
     wm_action('sw_reset'              -- reset stopwatch     wm_action('sw_reset'              -- reset stopwatch
 +    wm_action('media_next'            -- next track
 +    wm_action('media_prev'            -- previous track
 +    wm_action('media_play'            -- play media       
 +    wm_action('media_pause'           -- pause media       
 +    wm_action('media_play_pause'      -- play paused media or pause playing media    
 +    wm_action('vol_up'                -- increase the volume on the connected phone
 +    wm_action('vol_down'              -- decrease the volume on the connected phone
     wm_action('m_update_weather'      -- update weather     wm_action('m_update_weather'      -- update weather
     wm_action('m_task:MyTask'         -- run Tasker task 'MyTask'     wm_action('m_task:MyTask'         -- run Tasker task 'MyTask'
Line 216: Line 223:
     wm_action('color_switch_prev'     -- Color Switch: Previous Color     wm_action('color_switch_prev'     -- Color Switch: Previous Color
     wm_action('color_switch_select'   -- Color Switch: Select Color     wm_action('color_switch_select'   -- Color Switch: Select Color
 +    wm_action('tap_launcher'          -- Launch Tap Launcher 
 +    wm_action('widget_weather'        -- Launch Weather Widget 
 +    wm_action('widget_health'         -- Launch Health Widget 
 +    wm_action('widget_calendar'       -- Launch Calendar Widget 
 +    wm_action('w_app:App Name`com.app.package.name') -- Launch Wear OS app* 
 +    wm_action('w_app:App Name`com.app.package.name`com.app.package.name.activityName') -- Launch specific activity 
 +            
     wm_schedule('...'    -- schedule an animation or event (see Scheduling Animations / Functions)     wm_schedule('...'    -- schedule an animation or event (see Scheduling Animations / Functions)
     wm_unschedule_all()    -- unschedule all animations or events     wm_unschedule_all()    -- unschedule all animations or events
     wm_vibrate(d, r)       -- vibrate for duration d (milliseconds) and repeat r times      wm_vibrate(d, r)       -- vibrate for duration d (milliseconds) and repeat r times 
 +    wm_sfx('sfx_file'    -- play MP3 file with name sfx_file.mp3 (needs to be in /BeautifulWatches/sfx) - supported watches with speaker only
     wm_transition('...'  -- run a transition (see Transitions)     wm_transition('...'  -- run a transition (see Transitions)
 +    wm_anim_set('layerName', 'anim_in', 'Typewriter"    -- set animation in for 'layerName' to Typewriter
 +    wm_anim_set('layerName', 'dur_in', 1.0)     -- set duration in for 'layerName' to 1.0 (or use -1 for default)
 +    wm_anim_start('layerName'   -- start animation on 'layerName'
     wm_tag('...'         -- ONLY use for dynamic variables otherwise will break     wm_tag('...'         -- ONLY use for dynamic variables otherwise will break
                                 return a value of a WatchMaker tag, e.g. wm_tag("{c"..var_myvar.."bp}")                                 return a value of a WatchMaker tag, e.g. wm_tag("{c"..var_myvar.."bp}")
     is_bright              -- return true if watch is bright, else false     is_bright              -- return true if watch is bright, else false
 +
 +*About wm_action w_app
 +
 +The delimiter for the app link is a backtick ''`'' and it consists of two or three parts:
 +
 +  * App name (may be empty)
 +  * Package name
 +  * Activity name (optional)
 +
 +The app name is optional. If it is empty, the app main activity is launched. Example: ''wm_action('w_app:`com.samsung.android.watch.weather')''
 +
 +The easiest way to find the package name (example ''com.samsung.android.calendar'') is to search for the app on https://www.apkmirror.com/ or https://apkpure.net/. The package names are listed on the download pages. A more precise approach is to create a tap action first, select the app via "Watch: Select Application", export the watch, unzip the .watch file and search for ''tap_action="w_app:'' in watch.xml. It uses the same app link format.
 +
 +Available activities of apps can be obtained by downloading the APK file and uploading it to https://www.virustotal.com/. The "details" tab will list all activity names. Though at the time of writing, no activity could be launched successfully, so this may be broken (Wear OS 4).
  
 ===== Tweening Functions ===== ===== Tweening Functions =====
lua.1502202253.txt.gz · Last modified: 2017/08/08 14:24 by alex_curran