Glad I could help ! There is a Watchmaker Wiki that has a lot of useful information about how to write Lua code , but it just links to Lua language documentation for the string and math libraries . You could probably sort that out , but it isn ' t ideal . The formula is built around several calls to the string . sub function . It breaks out part of a string , based on firstcharacter and lastcharacter numbers . So string . sub , 1 , 2 returns the first through second characters , which are the twodigit hour value from the update time . string . sub , 3 , 5 returns the first comma and the twodigit minutes value . Using a string in a mathematical expression automatically converts it to a number . The 0 in the last part of the formula is only there to make sure that the hours value is evaluated as a number and not a string . The . operator concatenates different strings together , so those are used to assemble the string you want to create from the various parts . The % operator modulus returns the remainder you would get by dividing the left value by the right value . So 15 % 12 equals 3 . It is handy for working with values that rotate through a limited range , such as hours or minutes of time . The math in that first section is not obvious , but its purpose it to convert the 023 values you start with into a 112 value . Substituting a few specific values will help show how it works for different hour values 00 12120 % 12 1212 % 12 120 1207 12127 % 12 125 % 12 125 715 121215 % 12 123 % 12 129 3 The most common form of conditional in Lua looks like thislogical comparison and true value or false valueThat whole expression evaluates to only the true or false value . So the final section of the formula says that if the hours are greater than 11 return a ' P ' and otherwise return an ' A '. Then the ' M ' is stuck on the end . I think that covers most of it , but I ' m happy to answer questions if you have some .