Macro Module
#macro.init macro.init(string scriptFilename, ...)

This is an empty function that will be called once at the start of your script's execution. You should replace this with your own function.

The executing script's path and filename plus any arguments passed to the script execution via command line will be also passed to this function.

Example code:
function macro.init(script, ...) print("Script:", script); for i,v in pairs(unpack2(...)) do print(v); end end
Executed with:
myScript.lua abc 123 "Hello World"
Outputs:
Script: ./scripts/myScript.lua abc 123 Hello World
#macro.main boolean macro.main(number deltaTime)

This is an empty function that will be called once per logic cycle (~1,000 times a second). You should replace this with your own function.

The only parameter received is 'deltaTime'; the amount of time (in seconds) that has passed since the last call to this function.

You are expected to return true to continue script execution, or false to stop script execution. You do not need to (and are encouraged not to) insert any rests to reduce CPU usage; this is already handled for you.

It is recommended that you do not use any long while loops or blocking functions here; the main update function should execute quickly and constantly to ensure responsiveness.

Example:
function macro.init() continue = true; print("This script does nothing, but will terminate if you press the END key"); end function macro.main() if( continue ) then return true; else -- User pressed the END key so the script will shut down now. printf("\n\nAww, okay. Good bye!\n"); return false; end end function macro.event(e, ...) -- Check if the user has pressed the END key if( e == "keypressed" ) then local vk, toggle = ...; if( vk == key.VK_END ) then continue = false; end end end
#macro.event macro.event(string eventType, ...)

This is an empty function that will be called once for every event that is triggered. You should replace this with your own function.

'eventType' is a string that identifies which event was triggered. The number and types of extra parameters depends on the event type. See Events for information on what each event receives.

Example:
function macro.event(e, ...) if( e == "keypressed" ) then local vk, toggle = ...; printf("%s (%d) was pressed.\n", keyboard.getKeyName(vk), vk); end if( e == "mousepressed" ) then local vk = ...; local btnName = "Unknown"; if( vk == 1 ) then btnName = "left"; elseif( vk == 2 ) then btnName = "right"; elseif( vk == 4 ) then btnName = "middle"; end printf("%s mouse button pressed.\n", btnName); end end
#macro.fireEvent macro.fireEvent(string eventType, ...)

Pushes a custom, user-defined event onto the event queue, though there are limitations. Only very basic data types are currently supported (number and string). The first argument must be a string and will serve as the event's type/name. You may also pass up to 15 additional strings/numbers.

Example:
macro.fireEvent("customevent", "Hello", "World"); function macro.event(e, ...) if( e == "customevent" ) then print(...); end end
#macro.getVersion string macro.getVersion()

Returns the version as a MAJOR.MINOR.BUILD string format (ie 2.1.4)

#macro.is32bit boolean macro.is32bit()

Returns whether or not the MicroMacro instance is 32-bit.

#macro.is64bit boolean macro.is64bit()

Returns whether or not the MicroMacro instance is 64-bit.

Page last updated at 2023-09-04 13:54:04


Copyright 2024