Namespaces
Autorun
Main Autorun-ng namespace
Fields
Autorun.PLUGIN
Currently running plugin pointer. Don't touch this.
Autorun.VERSION
Version of Autorun-ng using semver format
Autorun.EVENTS
Internal event registry. Don't modify this directly, use Autorun.on() instead.
Functions
Autorun.print(values: ...any): void
Prints to the Autorun console in the format of '[plugin-name] ...'. Note you can print ANSI to get colors, see Autorun.color
Parameters:
values: ...any- Values to print
Autorun.read(path: string): string?
Reads a path relative to the active plugin's directory.
Parameters:
path: string
Returns:
string?- Contents of the file, nil if failed to read
Autorun.write(path: string, content: string): void
Writes to a path relative to the active plugin's /data/ directory. Cannot write outside /data/ for security reasons.
Parameters:
path: stringcontent: string
Autorun.append(path: string, content: string): void
Appends content to a file at the given path relative to the active plugin's /data/ directory. Cannot write outside /data/ for security reasons.
Parameters:
path: stringcontent: string
Autorun.writeAsync(path: string, content: string): void
ASYNCHRONOUSLY writes to a path relative to the active plugin's /data/ directory. Cannot write outside /data/ for security reasons. This is important to avoid blocking the main thread on large writes to avoid detection.
Parameters:
path: stringcontent: string
Autorun.include(path: string): ...any
Reads and executes a Lua file from the given path. This doesn't do any caching.
Parameters:
path: string
Returns:
...any
Autorun.require(path: string): ...any
Reads and executes a Lua file from the given path. This caches the output of the include so subsequent calls return the same values.
Parameters:
path: string
Returns:
...any
Autorun.mkdir(path: string): boolean
Makes a directory recursively. This runs relative to the plugin's /data/ directory
Parameters:
path: string
Returns:
boolean- Whether the directory was created successfully, false if exists
Autorun.exists(path: string): boolean
Checks if a file or directory exists at the given path relative to the active plugin's directory.
Parameters:
path: string
Returns:
boolean- True if the file/directory exists, false otherwise
Autorun.on(eventName: string, callback: function): void
Registers an event handler for the specified event.
Parameters:
eventName: string- Name of the event to listen for (e.g., 'loadbuffer')callback: function- Function to call when the event is triggered. Return value can modify event behavior.
Autorun.onRemote(eventName: string, callback: function): void
Registers an event handler for the specified remote event.
Parameters:
eventName: string- Name of the event to listen for (e.g., 'loadbuffer')callback: function- Function to call when the event is received. It will be passed the single serializable value
Autorun.trigger(eventName: string, ...: ...any): any?
Triggers all registered handlers for the specified event. Used internally by Autorun.
Parameters:
eventName: string- Name of the event to trigger...: ...any- Arguments to pass to event handlers
Returns:
any?- First non-nil return value from event handlers, or nil
Autorun.triggerRemote(eventName: string, value: string | number | boolean): void
Triggers an event registered with Autorun.onRemote on the other state. AKA, if you're on the menu and call this, it will send an event to the client, and vice versa.
Parameters:
eventName: string- Name of the event to triggervalue: string | number | boolean- Serializable value to pass to the event handlers
Autorun.detour(targetFunction: function, detourCallback: function): Detour
Creates a detour (hook) on a target Lua function, redirecting calls to a replacement function. The detour is automatically enabled upon creation. The original function is passed as the first argument to the detour callback, followed by the original arguments.
Parameters:
targetFunction: function- The function to detour/hookdetourCallback: function- The function to call instead of the target. Receives the original function as the first argument, followed by all arguments passed to the hooked function. Example: function(original, ...) return original(...) end
Returns:
Detour- Detour userdata object that can be used to manage the detour
Autorun.enableDetour(detour: Detour): void
Enables a previously disabled detour, causing calls to the target function to be redirected again.
Parameters:
detour: Detour- The detour userdata to enable
Autorun.disableDetour(detour: Detour): void
Disables a detour, restoring the original function behavior. The detour can be re-enabled later with enableDetour().
Parameters:
detour: Detour- The detour userdata to disable
Autorun.removeDetour(detour: Detour): void
Permanently removes a detour, disabling it and cleaning up all associated resources. The detour cannot be used after this.
Parameters:
detour: Detour- The detour userdata to remove
Autorun.getOriginalFunction(detour: Detour): function
Retrieves the original function pointer from a detour. This is rarely needed since the original function is automatically passed as the first argument to the detour callback. Useful for code outside the detour callback that needs to call the original function.
Parameters:
detour: Detour- The detour userdata to get the original function from
Returns:
function- The original function that was detoured
Autorun.copyFastFunction(originalFunction: function, replacementFunction: function): function
Creates a copy of a specific LuaJIT fast function, with the internals replaced by running the given lua closure. Basically, allows you to 'detour' certain functions like getfenv or getmetatable which LuaJIT JIT compiles.
Parameters:
originalFunction: function- The original fast function to copy. Must be a C function obviously.replacementFunction: function- The Lua function to run instead of the original.
Returns:
function- The copied function that looks like the original but runs the replacement code. To lua, this will look like just another C function. Note that anything that gets a stack trace will still see your Lua function and detect you if you do anything that'll give you away.
Autorun.isFunctionAuthorized(funcOrLevel: function | number): boolean
Checks if a given function or stack level is authorized by the Autorun environment.
Parameters:
funcOrLevel: function | number- The function to check or the stack level
Returns:
boolean- True if the function/level is authorized, false otherwise
Autorun.isProtoAuthorized(proto: proto): boolean
Checks if a given prototype is authorized by the Autorun environment. This can be used to verify if protos from VM events are from Autorun or not.
Parameters:
proto: proto- The prototype to check
Returns:
boolean- True if the prototype is authorized, false otherwise
Autorun.load(code: string): function?, string?
Compiles a Lua string into a callable function without executing it. Similar to Lua's loadstring/load function. Use this to dynamically compile code at runtime. NOTE: The environment inside defaults to the global environment, NOT Autorun's environment.
Parameters:
code: string- The Lua code to compile
Returns:
function?- The compiled function, or nil if compilation failedstring?- Error message if compilation failed
Autorun.color(input: string | number | table, outputFormat: string?): string | number | table
This allows you to format a range of input colors (hex strings, hex numbers, rgb tables, color names) into a variety of outputs. For example, you can convert 'red' to '#FF0000' by calling Autorun.color('red', 'hex'). Most useful output is probably 'ansi' which is the default and can be used in conjunction with Autorun.print to print colors to the console. List of output formats: - ansi - hex - number - [rgb] - {rgb}
Parameters:
input: string | number | table- Input color in various formats (e.g., '#FF0000', 0xFF0000, {r=255,g=0,b=0}, 'red')outputFormat: string?- Desired output format ('hex', 'rgb', 'ansi'). Defaults to 'ansi'.
Returns:
string | number | table- Formatted color in the requested output format