Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Scripts

Pedro Fanha edited this page Feb 25, 2019 · 14 revisions

Index

  1. Overview
  2. API
    1. Lighting module
    2. Aida64 module
  3. Debugging

Overview

Scripts are written in Lua and allow you to create new effects. Lua is a very easy to learn, dynamically typed language, meaning writing and testing scripts will be pretty straightforward even for newbies.

Scripts are loaded from the 'Scripts' folder in the directory where you have saved MSIRGB. Any file with a .lua extension in that folder (subdirectories excluded) will be loaded. The name of the script that will appear on MSIRGB is the file name without extension. As a convention, you should use upper camel case and spaces between words for your file names, e.g. 'Hue Wheel', 'Single Colour', 'Edgy Rainbow'.

Scripts, when enabled, run on Windows startup, so you don't have to enable them every time.

It is recommended that scripts set all LED settings on startup because there are no guarantees on their state at that point.

I'm open to pull requests/issues for new scripting functionality.

API

Scripts are loaded into a sandboxed Lua 5.2 environment with the following standard functions and packages:

  • assert
  • collectgarbage
  • error
  • print
  • select
  • type
  • tonumber
  • tostring
  • next
  • ipairs
  • pairs
  • string package
  • table package
  • math package
  • bit32 package
  • os time package

Additionally, there is one extension function to the os package:

os.sleep(number ms)

This function pauses the Lua thread for the number of milliseconds specified in 'ms'. 'ms' must be a positive number. Execution stops if an invalid value is passed.

Lighting module

The 'Lighting' module provides the API to control the LEDs. Here follows documentation for each function:

Lighting.SetAllEnabled(boolean enabled)

This function allows you to enable or disable the LEDs connected to the motherboard. As far as I know, this controls both motherboard and header LEDs.

boolean Lighting.BatchBegin()

(Release 1.1.0 onwards) A call to this function enables batching of updates to the LEDs. After calling it, any update to the LEDs is stored and only applied when Lighting.BatchEnd is called. This allows for optimizing the number of driver calls, and therefore, the performance of the script. Batching calls is encouraged. This function returns true if it successfully started batching calls, and false if it is already batching calls.

boolean Lighting.BatchEnd()

(Release 1.1.0 onwards) A call to this function disables batching of updates to the LEDs. A call to this function commits all updates to the LEDs after Lighting.BatchBegin was called. See Lighting.BatchBegin for why it's encouraged to use this function. This function returns true if it successfully disabled batching and committed changes, and false if batching calls was not enabled.

Lighting.SetColour(number index, number r, number g, number b)

This function sets the colour of one of the 4 built-in colours. 'index' can be a number between 1 and 4, inclusive. 'r', 'g', 'b' are the R, G, B values between 0 and 255. Execution stops if any of the arguments is invalid. Any call to this function that succeeds automatically turns on the LEDs.

number, number, number Lighting.GetColour(number index)

This function gets the current colour of one of the 4 built-in colours. 'index' can be a number between 1 and 4, inclusive. The function returns the R, G, B values in that order. Execution stops if 'index' is invalid.

boolean Lighting.SetBreathingModeEnabled(boolean enabled)

This function sets the state of the breathing mode. Breathing mode and flashing mode are exclusive, and the latter will override the former. If flashing mode is enabled at the time of the call, this function will fail and return false, otherwise it returns true. Any call to this function that succeeds automatically turns on the LEDs.

boolean Lighting.IsBreathingModeEnabled()

This function returns whether breathing mode is currently enabled.

Lighting.SetFlashingSpeed(number flashingSpeed)

This function sets the flashing mode speed. Valid values for 'flashingSpeed' range from 0 to 6, inclusive. A value of '0' means that flashing mode will be disabled. A value of '1' means fastest flashing, while a value of '6' means slowest flashing. This function will disable breathing mode if it was previously enabled. Execution stops if 'flashingSpeed' is invalid. Any call to this function that succeeds automatically turns on the LEDs.

number Lighting.GetFlashingSpeed()

This function returns the current flashing mode speed. Speeds are as described above for 'SetFlashingSpeed'.

Lighting.SetStepDuration(number stepDuration)

This function sets the value for step duration. Step duration is the interval of time between changes in any of the 4 chosen colours. It is in an arbitrary time unit. Valid values range from 0 to 511, inclusive. Execution stops if 'stepDuration' is invalid. Any call to this function that succeeds automatically turns on the LEDs.

number Lighting.GetStepDuration()

This function returns the current step duration.

Aida64 module

The 'Aida64' module provides a way for scripts to communicate with AIDA64 and query hardware sensor and system data to create effects based on them. Some version of AIDA64 must be installed and running for this module to work, and "Enable writing sensor values to WMI" must be enabled under "External Applications" in AIDA64 preferences. Here follows the documentation for each function from this module. Keep in mind that this module is only available starting in release 1.1.0.

boolean Aida64.IsInstalledAndRunning()

(Release 1.1.0 onwards) This function returns true if AIDA64 is installed and running, and false if not. It also returns false if writing sensor values to WMI is not enabled in AIDA64.

number/boolean Aida64.GetSensorValue(string label)

(Release 1.1.0 onwards) This function returns the value (as a number) associated to some sensor label. Possible sensor labels are immediately below. If the label is not valid or AIDA64 is not running, execution of the script stops. If you're running a trial version of AIDA64 and the sensor label is not available in that version, or the label is valid but does not apply to this specific hardware (for instance, CPU core info for core > number of cores of your CPU), this function returns false.

Possible sensor labels:

Label (in regex pattern) Sensor
SCPUCLK CPU Clock (MHz)
SCC-1-([1-9][0-9]*) CPU Core #n Clock (MHz), where n is the regex pattern that matches any positive integer without leading zeros. Example: SCC-1-1 for core #1, SCC-1-2 for core #2, ...
SMEMCLK Memory Clock (MHz)
SCPUUTI CPU Utilization (percentage)
SCPU([1-9][0-9]*)UTI CPU n Utilization (percentage), where n is the regex pattern that matches any positive integer without leading zeros. Example: SCPU1UTI for CPU #1
SMEMUTI Memory Utilization (percentage)
SVIRTMEMUTI Virtual Memory Utilization (percentage)
SDSK([1-9][0-9]*)ACT Disk n Activity (percentage), where n is the regex pattern that matches any positive integer without leading zeros. Example: SDSK1ACT for disk #1
SGPU([1-9][0-9]*)CLK GPU n Clock (MHz), where n is the regex pattern that matches any positive integer without leading zeros. Example: SGPU1CLK for GPU #1
SGPU([1-9][0-9]*)MEMCLK GPU n Memory Clock (MHz), where n is the regex pattern that matches any positive integer without leading zeros. Example: SGPU1MEMCLK for GPU #1
SGPU([1-9][0-9]*)UTI GPU n Utilization (percentage), where n is the regex pattern that matches any positive integer without leading zeros. Example: SGPU1UTI for GPU #1
SVMEMUSAGE Video Memory Utilization (percentage)
SGPU([1-9][0-9]*)USEDDEMEM GPU n Used Dedicated Memory (MB), where n is the regex pattern that matches any positive integer without leading zeros. Example: SGPU1USEDDEMEM for GPU #1
SGPU([1-9][0-9]*)USEDDYMEM GPU n Used Dynamic Memory (MB), where n is the regex pattern that matches any positive integer without leading zeros. Example: SGPU1USEDDYMEM for GPU #1
TMOBO Motherboard temperature (degree celsius)
TCPU CPU temperature (degree celsius)
TCPUDIO CPU Diode temperature (degree celsius)
TGPU([1-9][0-9]*)DIO GPU n Diode temperature (degree celsius), where n is the regex pattern that matches any positive integer without leading zeros. Example: TGPU1DIO for GPU #1
THDD([1-9][0-9]*) HDD temperature (degree celsius), where n is the regex pattern that matches any positive integer without leading zeros. Example: THDD1 for HDD #1. This label is not supported on trial versions of AIDA64.
FCPU CPU fan speed (RPM)
FCHA([1-9][0-9]*) Chassis n fan speed (RPM), where n is the regex pattern that matches any positive integer without leading zeros. Example: FCHA1 for chassis fan #1
FGPU([1-9][0-9]*) GPU n fan speed (RPM), where n is the regex pattern that matches any positive integer without leading zeros. Example: FGPU1 for GPU fan #1
VCPU CPU Core voltage (V). This label is not supported on trial versions of AIDA64.
VGPU([1-9][0-9]*) GPU n Core voltage (V), where n is the regex pattern that matches any positive integer without leading zeros. Example: VGPU1 for GPU #1
PCPUPKG CPU Package power comsumption (W)
PCPUVDD CPU VDD power comsumption (W)
PCPUVDDNB CPU VDDNB power comsumption (W)
PGPU([1-9][0-9]*)TDPP GPU n power comsumption (percentage, in relation to TDP), where n is the regex pattern that matches any positive integer without leading zeros. Example: PGPU1TDPP for GPU #1

Debugging

In order to debug scripts, you can click on 'Open script log' in the 'Scripts' group to open the script log containing errors, warnings and other information from the script. The script can also call 'print' to print information to the log.

Clone this wiki locally