Table of Contents

Tasker Variables

There are tricks to using Tasker variables in Watchmaker. I learnt this the hard way and after much relearning Lua. Thankfully, Lua is not too difficult a language to get into. If you have done any BASIC or shell scripting, you won't be too lost!

How to use them

Tasker variables that are sent to Watchmaker are prefixed with a t and enclosed around { }. All variable names are converted to lowercase, so bare this in mind when running Tasks. For example, %SomeVar will be {tsomevar}. This can result in issues if you use a global and local identical, for example %loc and %LOC - both will be {tloc} to Watcmaker.

In most cases, Tasker variables are seen as Lua tables to Watchmaker. This can make using the raw {tvariable} difficult to use in formula or string conversions. So we ideally want to map them to var_variables in the Main Script.

How often

The raw {tvariables} will update as you send them through Watchmaker (when screen is bright). This is fine for simple sending of small data sets where no math or string formulas are used. However, to make everything pretty and error free, there are tricks to make them more efficient and usable.

Once a minute or longer

This includes being updated on_display_bright() as well as results from ontap actions.

In this example, we'll send %taskerstring containing a text string Hello World and %taskernumber containing a number 62.21

There is a trick to handling both!

 function static_variables()
  taskerstring=wm_tag('{ttaskerstring}') 
  var_string=tostring(taskerstring)
  taskernumber=wm_tag('{ttaskernumber}')
  var_number=tonumber(taskernumber)
 end
static_variables()

Now, this alone won't do anything but initialize the var_ variables to use in faces. What it does, it initializes the variable as Lua only local variable. The next step then sets it to a type, string or number. This is important to know what we are sending to map correctly. If your variable contains both strings and numbers, whether together or alone, use tostring().

We can error check against them easily!

var_string == nil and 'No string yet' or var_string

and

var_number == nil and '-1' or var_number

WIP