Skip to content

Lua Scripting

TheGoodDoktor edited this page Feb 29, 2024 · 3 revisions

The analysers can be scripted using the Lua programming language

Configuring

Global Config

In the global config file you can configure Lua's base behaviour.
To enable Lua scripting: "EnableLua" : true
To specify the Lua files that should always be loaded (for all games): "LuaBaseFiles": ["Lua/LuaBase.lua","Lua/ViewerBase.lua"]

Game Config

Individual games can also customise their Lua functionality.
To specify game specific Lua files:"LuaSourceFiles": ["ViewerScript.lua","MapViewer.lua" ]

Lua API

The analysers expose an API that can be used to add additional functionality:

Core API

Memory Related

ReadByte(address)
Reads byte from memory and returns the value

ReadWord(address)
Reads a word (16 bits) from memory and returns the value

GetMemPtr(address)
Returns a pointer to an address in memory. This can be used for subsequent API calls that operate on memory

Code Analysis

SetDataItemComment(address, comment text)
Set the comment text for a data item
Example: SetDataItemComment(0x1234,"Player Sprite 1")

SetDataItemDisplayType(address, display_type)
Set the display type for a data item value
Example: SetDataItemDisplayType(0x1234,EDataItemDisplayType.Pointer)

UI

Graphics

ZX Spectrum API

Amstrad CPC API

Clone this wiki locally