Lua API Reference

The Lua API in HuntMemory provides a powerful scripting interface for automating memory operations, creating UI elements, drawing on the screen, and managing background tasks. This document covers all available Lua functions grouped by functionality.

Table of Contents

  1. Utility Functions
  2. Dynamic Menu API
  3. Canvas API
  4. Memory API
  5. Freeze API
  6. Thread Management API
  7. HTTP & Data API

Utility Functions

log(level, message)

Logs a message to the application’s log output.

showToast(message)

Displays a toast message on the screen.

sleep(milliseconds)

Pauses script execution for the specified duration.

getScreenSize()

Returns the device’s screen dimensions.

getAttachedPid()

Returns the PID of the currently attached process.

Dynamic Menu API

The Dynamic Menu API allows you to create interactive UI components that float over the screen.

clear_menu()

Removes all components from the dynamic menu.

add_label(text)

Adds a non-interactive text label to the menu.

add_button(label, onClickCallback)

Adds a button that executes a Lua function when clicked.

add_switch(label, initialValue, onToggleCallback)

Adds a toggle switch.

add_slider(label, initialValue, min, max, steps, onValueChangeCallback)

Adds a slider control.

remove_item(id)

Removes a specific component from the menu.

update_text(id, newText)

Updates the text of a component.

update_value(id, newValue)

Updates the value of a slider component.

Canvas API

The Canvas API allows you to draw shapes and text on the screen overlay.

canvas.clear()

Removes all drawings from the canvas.

canvas.drawLine(x1, y1, x2, y2, paint)

Draws a line on the canvas.

canvas.drawRect(left, top, right, bottom, paint)

Draws a rectangle on the canvas.

canvas.drawText(text, x, y, paint)

Draws text on the canvas.

canvas.drawCircle(cx, cy, radius, paint)

Draws a circle on the canvas.

canvas.remove(id)

Removes a specific drawing from the canvas.

canvas.updatePosition(id, x, y)

Updates the position of a drawing element.

canvas.updateColor(id, color)

Updates the color of a drawing element.

canvas.hasDrawing(id)

Checks if a drawing with the given ID exists.

canvas.getDrawingsCount()

Gets the total number of drawings on the canvas.

Paint Table Format

The paint parameter for canvas functions is a table with the following optional keys:

Memory API

Functions for memory scanning, reading, and writing. Require a process to be attached.

searchMemory(value, valueType, operator)

Searches memory for a value.

filterResults(value, valueType, operator)

Alias for searchMemory.

getResults(limit)

Retrieves results from the last search.

readMemory(address, valueType)

Reads a value from a specific memory address.

writeMemory(address, value, valueType)

Writes a value to a specific memory address.

gotoAddress(address)

Jumps to a memory address.

dereferencePointer(address)

Reads a pointer value and returns the address it points to.

getModuleBase(name)

Gets the base address of a loaded library/module.

clearResults()

Clears the current list of search results.

Freeze API

Functions to repeatedly write a value to a memory address.

startFreeze(address, value, valueType, interval)

Starts a freeze operation.

stopFreeze(freezeId)

Stops a specific freeze operation.

stopAllFreezes()

Stops all freeze operations.

getActiveFreezes()

Returns a list of all active freeze operations.

Thread Management API

Functions for creating and managing background threads.

createThread(name, function, interval, isRepeating, delay)

Creates a new thread that executes the given Lua function.

pauseThread(threadId)

Pauses a thread.

resumeThread(threadId)

Resumes a paused thread.

stopThread(threadId)

Stops a specific thread.

stopAllThreads()

Stops all threads.

getActiveThreads()

Gets information about all active threads.

isThreadPaused(threadId)

Checks if a thread is currently paused.

getThreadExecutionCount(threadId)

Gets the number of times a thread has been executed.

getThreadStats()

Gets detailed statistics about thread management.

forceGarbageCollection()

Forces garbage collection to free up memory.

cleanupInactiveThreads()

Cleans up inactive threads.

HTTP & Data API

Functions for web requests and simple key-value data storage.

setData(key, value)

Store simple string data that persists for the script’s session.

getData(key)

Retrieve stored data.

clearData()

Clears all stored data.

httpGet(url)

Performs an HTTP GET request.

httpPost(url, data, contentType)

Performs an HTTP POST request.

downloadLuaFileAndExecute(url)

Downloads a Lua script from a URL and executes it immediately.