This is a collection of useful "snippets" of Lua script code for users of Rainmeter, a desktop customization tool for Windows. It is maintained by the Rainmeter development team, and hosted on GitHub.
A function that separates a string into parts by a given delimiter.
A function that sorts a given table into a random order.
A function that emulates a switch statement.
Converts temperatures between Celsius and Fahrenheit.
File Input & Output
Read & Write a File
Functions that read and write any string to or from a text file.
Returns an input number as a string formatted with commas.
Returns the ordinal suffix for an input number.
A function that scales a number of bytes, with an optional number of decimal places. Returns a second string value with the scale suffix.
A function that averages a list of numbers.
Rounds a number (num) to any optional number of decimal places (idp)
Detect Value Change
A simple method for "watching" a data value in the skin (variable, measure or option) and taking action when the value changes.
A method for parsing a string with nested expressions such as variables (i.e.
Set Meter & Measure Options
A simple method for setting multiple options on the same meter or measure.
- Parse File Path
A function that breaks down a file or folder path and returns the components as a table.
- Change Case
A set of function to change a string to either Sentence Case or Title Case.
Parse 12-Hour Time
A function that takes a number (1-12) and a string ('AM' or 'PM') and returns the equivalent 24-hour figure.
Format Seconds Into Time Intervals
A function that takes a number of seconds, and returns values for weeks, days, hours, minutes, and seconds.