Plugin structure
my-plugin/ main.lua runs when the plugin loads lib/util.lua anything else you require schemas/game.sal the game's types wraith.json the manifestmain.lua
Section titled “main.lua”Your code runs top to bottom when the plugin loads. Everything comes from require("wraith"), so pull out what you use.
local wraith = require("wraith")local config, frame, keybinds, ui = wraith.config, wraith.frame, wraith.keybinds, wraith.ui
local settings = config.load({ visible = true })
keybinds.bind("toggle", { name = "Show the window", chord = "ctrl+f8" }, function() settings.visible = not settings.visibleend)
frame.onFrame(function() if not settings.visible then return end ui.window("My Plugin", function() ui.text("Hello!") end)end)Namespaces use a dot, like wraith.memory.readU32(address). Objects use a colon, like hook:enable().
Your own files
Section titled “Your own files”require("lib.util") loads lib/util.lua from your plugin’s folder, once. Nothing outside the folder can be required.
Cleaning up
Section titled “Cleaning up”You mostly don’t. When the plugin unloads, Wraith undoes everything it set up and puts the game’s code back.
Settings
Section titled “Settings”config.load(defaults) gives you a table with the saved values on top of your defaults. Change it and it’s saved. Use gameConfig for settings that should be separate for each game.
Game types
Section titled “Game types”Put schemas in schemas/ and require("schema") gives you their types.
local types = require("schema")
local player = types.Player.at(address)player.health = 100Waiting
Section titled “Waiting”main.lua, callbacks and anything started with wraith.spawn can wait without blocking the game.
wraith.spawn(function() wraith.frame.next():await() -- one frame laterend)What Lua can’t do
Section titled “What Lua can’t do”It’s Lua 5.5 without the parts that reach outside the game. There’s no io, no dofile or loadfile, and os only has its time functions.
Made with ♥ by Asgard
