Plugin structure
The files
Section titled “The files”Here’s what the template gives you.
my-plugin/ src/main.ts your code schemas/game.sal the game's types public/ copied into dist/ as is wraith.json the manifest package.json .wraith/types/ typings, made for you dist/ the build, what Wraith loadsmy-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 manifest .wraith/types/ types for your editor, made for yourequire("lib.util") loads lib/util.lua from your plugin’s folder, once. Nothing outside the folder can be required.
my-plugin/ Plugin.cs your code MyPlugin.csproj how it's built, NativeAOT or CoreCLR schemas/game.sal the game's types wraith.json the manifest .wraith/cs/ Wraith's API as C#, made for you dist/ the build, what Wraith loadsmy_plugin/ src/plugin.cpp your code CMakeLists.txt how it's built schemas/game.sal the game's types wraith.json the manifest build/ the build, with the headers made for you dist/ what Wraith loadsmy_plugin/ src/lib.rs your code Cargo.toml how it's built build.rs keeps .wraith/rust up to date schemas/game.sal the game's types wraith.json the manifest .wraith/rust/ Wraith's API as crates, made for you dist/ what Wraith loadsmy_plugin/ src/root.zig your code build.zig how it's built build.zig.zon its dependencies, Wraith's SDK among them schemas/game.sal the game's types wraith.json the manifest zig-out/ the build, what Wraith loadsmy_plugin/ src/plugin.c your code CMakeLists.txt how it's built schemas/game.sal the game's types wraith.json the manifest build/ the build, with the headers made for you dist/ what Wraith loadsWraith’s API
Section titled “Wraith’s API”Wraith’s API is described in schemas, the same as the game’s types, and every language gets it from them. It’s all in the Wraith namespace, and it comes in areas, one for each thing Wraith does, like Wraith.Ui, Wraith.Input, Wraith.Hooks or Wraith.Tweaks. Each plugin gets its own of each, which stops working once the plugin’s unloaded.
The types an area uses are inside it, like Wraith.Window.Options for a window or Wraith.Tweaks.Definition for a tweak. The ones used everywhere, like Key, Chord, Vec3 and the errors, are right under Wraith. These docs name things the way the schemas do, like ui.addWindow or threads.toGame, and each tab shows how that’s written in its language.
Import what you use from the wraith module. It has Wraith, your plugin’s own namespace and the namespaces of plugins you depend on, like Freecam. None of them are globals, so a file that uses one imports it. Rename them as you like, like import { MyPlugin as game } from "wraith".
Areas are functions, like Wraith.ui(), and types and enums are under their names, like Wraith.Keybind.Phase.pressed. Each area also has instance(), so Wraith.Tweaks.instance() is the same as Wraith.tweaks(). Your editor’s autocomplete shows everything.
import { Wraith, MyPlugin, Freecam } from "wraith";
const ui = Wraith.ui();const pressed = Wraith.Keybind.Phase.pressed;const camera = Freecam.camera();An imported namespace is a type too, so MyPlugin.Player works in a type annotation.
salamander is the other module, for native functions and snapshots, see below.
require("wraith") gives a table with Wraith, your plugin’s own namespace and the namespaces of plugins you depend on, like Freecam. None of them are globals, so take what you use into locals, named as you like.
Areas are functions, like Wraith.ui(), and types and enums are under their names, like Wraith.Keybind.Phase.pressed. Each area also has instance(), so Wraith.Tweaks.instance() is the same as Wraith.tweaks().
local wraith = require("wraith")local Wraith, game = wraith.Wraith, wraith.MyPlugin
local ui = Wraith.ui()local pressed = Wraith.Keybind.Phase.pressedFor just one, local Wraith = require("wraith").Wraith does it. Calls on an area or on what it gives use a colon, like ui:addWindow(...) and window:setOpen(true). require("salamander") is the other module, for native functions.
using Wraith; brings it in. Each area is a class with a static Instance, like Ui.Instance or Tweaks.Instance, and its types are nested in it, like new Window.Options { ... } or Keybind.Phase.Pressed. Methods are PascalCase, and ones that wait end in Async.
using Wraith;
var ui = Ui.Instance;var pressed = Keybind.Phase.Pressed;Instance throws before your plugin’s started.
#include "wraith_plugin.hpp" brings it in, and wraith::api() is Wraith’s API, so areas are wraith::api().ui(), wraith::api().tweaks() and so on. Types are in the Wraith namespace, nested in their area, like Wraith::Window::Options or Wraith::Keybind::Phase::pressed. Your schemas are in schema.hpp, in your namespace.
#include "wraith_plugin.hpp"
auto ui = wraith::api().ui();auto pressed = Wraith::Keybind::Phase::pressed;Calls that can fail give a sal::Result, which is true when it worked, with the value through * and the error through error(). Strings, spans and optionals go in as std::string_view, std::span and std::optional. It needs no exceptions or RTTI.
The wraith crate is Wraith’s API, so areas are wraith::api().ui(), wraith::api().tweaks() and so on. Types are right in the crate, named with their area in front, like wraith::WindowOptions or wraith::KeybindPhase::PRESSED. Methods are snake_case, and your schemas are in schema, a module you include.
use wraith::KeybindPhase;
let ui = wraith::api().ui();let pressed = KeybindPhase::PRESSED;Calls that can fail give a Result, strings and slices go in as &str and &[T], and calling the game’s code is unsafe.
ctx.wraith is Wraith’s API, so areas are ctx.wraith.ui(), ctx.wraith.tweaks() and so on. Its types are in sdk.api.wraith, like sdk.api.wraith.Window.Options, and each area’s type has instance() too, like sdk.api.wraith.Tweaks.instance(), for where there’s no ctx to hand.
const W = sdk.api.wraith;
const ui = ctx.wraith.ui();const pressed: W.Keybind.Phase = .pressed;On top, the SDK has Zig helpers, like sdk.hooks for typed hooks and sdk.threads for tasks. These docs say where one’s Zig only, and the other tabs show what does the same.
#include "wraith_plugin.h" brings it in. Every area is a function on Wraith_Api, the w you keep from start, and every call is a function on what it’s called on, like Wraith_Ui_addWindow(Wraith_Api_ui(w), ...). Types are named with their area, like Wraith_Window_Options, and enum values after their type, like Wraith_Keybind_Phase_pressed.
#include "wraith_plugin.h"
static Wraith_Api w; // set in start
/* in start */Wraith_Ui ui = Wraith_Api_ui(w);Wraith_Keybind_Phase pressed = Wraith_Keybind_Phase_pressed;Calls that can fail give SAL_OK or an error code, with what they make through a pointer at the end. Strings are sal_string, and SAL_STR("text") makes one.
Workbench scripts and tweak sessions are the exception. They have every namespace and area as a global, with nothing to import.
Your code
Section titled “Your code”This one adds a window, and a key that opens and closes it.
Your code in src/main.ts runs top to bottom when the plugin loads. There’s no start or main to export.
import { Wraith } from "wraith";
const window = Wraith.ui().addWindow({ title: "My Plugin", icon: "puzzle" }, () => { Wraith.imgui().TextUnformatted("Hello!");});
// Ctrl+F8Wraith.input().bind({ id: "toggle", name: "Show the window", chord: { key: "f8", mods: 1 } }, (phase) => { if (phase === Wraith.Keybind.Phase.pressed) window.setOpen(!window.isOpen());});Your code in main.lua runs top to bottom when the plugin loads.
local Wraith = require("wraith").Wraith
local window = Wraith.ui():addWindow({ title = "My Plugin", icon = "puzzle" }, function() Wraith.imgui():TextUnformatted("Hello!")end)
-- Ctrl+F8Wraith.input():bind({ id = "toggle", name = "Show the window", chord = { key = "f8", mods = 1 } }, function(phase) if phase == Wraith.Keybind.Phase.pressed then window:setOpen(not window:isOpen()) endend)A C# plugin is a class from WraithPlugin, with Start and maybe Stop. The partial Entry.Create at the bottom tells Wraith which class it is.
using Wraith;
namespace MyPlugin{ sealed class Main : WraithPlugin { // Kept, so they last as long as the plugin Window? window; Keybind? toggle;
public override void Start(Context context) { var imgui = ImGui.Instance;
window = Ui.Instance.AddWindow(new Window.Options { Title = "My Plugin", Icon = "puzzle" }, () => { imgui.TextUnformatted("Hello!"); });
// Ctrl+F8 var chord = new Chord { Key = Key.F8, Mods = new Mods { Ctrl = true } }; toggle = Input.Instance.Bind(new Input.Action { Id = "toggle", Name = "Show the window", Chord = chord }, phase => { if (phase == Keybind.Phase.Pressed) window!.SetOpen(!window.IsOpen()); }); } }}
namespace Wraith{ static partial class Entry { internal static partial WraithPlugin Create() => new MyPlugin.Main(); }}A C++ plugin is a class with start and maybe stop. WRAITH_PLUGIN makes it the one Wraith starts, and Wraith makes it as the plugin starts and destroys it after.
#include "wraith_plugin.hpp"
struct Plugin { Wraith::Window window;
bool start() { // Wraith keeps what you hand it, so sal::keep makes a heap copy it lets go of window = wraith::api().ui().addWindow({.title = sal::String::of("My Plugin"), .icon = sal::String::of("puzzle")}, sal::keep<Wraith::Window::Draw>([] { wraith::api().imgui().TextUnformatted("Hello!"); }));
// Ctrl+F8 Wraith::Input::Action toggle{ .id = sal::String::of("toggle"), .name = sal::String::of("Show the window"), .chord = {Wraith::Key::f8, Wraith::Mods{}.with_ctrl(true)}, }; auto bound = wraith::api().input().bind(toggle, sal::keep<Wraith::Keybind::Fired>([this](Wraith::Keybind::Phase phase) { if (phase == Wraith::Keybind::Phase::pressed) window.setOpen(!window.isOpen()); })); return bound.ok(); }
void stop() {}};
WRAITH_PLUGIN(Plugin)Anything with the right method works where Wraith calls you back, like a lambda or a class of your own. sal::keep hands Wraith a copy it destroys once it’s done, and Type::of(x) lends it x, which then has to outlive it.
A Rust plugin is a type implementing wraith::Plugin, whose start gives it. wraith::plugin! makes it the one Wraith starts.
use salamander::Str;use wraith::{Chord, InputAction, Key, KeybindFired, KeybindPhase, Mods, WindowDraw, WindowOptions};
struct Plugin;
impl wraith::Plugin for Plugin { fn start() -> Option<Self> { let api = wraith::api(); // Wraith keeps what you hand it, so keep makes a heap copy it lets go of let window = api.ui().add_window( WindowOptions { title: Str::new("My Plugin"), icon: Str::new("puzzle"), ..Default::default() }, WindowDraw::keep(|| wraith::api().imgui().text_unformatted(c"Hello!".as_ptr().cast())), );
// Ctrl+F8 let toggle = InputAction { id: Str::new("toggle"), name: Str::new("Show the window"), chord: Chord { key: Key::F8, mods: Mods::default().with_ctrl(true) }, ..Default::default() }; api.input() .bind(toggle, KeybindFired::keep(move |phase| { if phase == KeybindPhase::PRESSED { window.set_open(!window.is_open()); } })) .ok()?; Some(Plugin) }}
wraith::plugin!(Plugin);A closure works where Wraith calls you back, or any type implementing that callback’s ...Impl trait. keep hands Wraith a copy it drops once it’s done, and from_static lends it something that lasts as long as the program.
A Zig plugin is a struct with start and maybe stop, in src/root.zig.
const std = @import("std");const sdk = @import("wraith_sdk");
pub const std_options: std.Options = .{ .logFn = sdk.logFn };pub const panic = sdk.panic;
const W = sdk.api.wraith;const log = sdk.log.scoped(.my_plugin);
pub const Plugin = struct { window: W.Window = undefined, toggle: W.Keybind = undefined,
pub fn start(self: *Plugin, ctx: *sdk.Context) !void { self.window = ctx.wraith.ui().addWindow(.{ .title = "My Plugin", .icon = "puzzle" }, .init(self, draw)); // Ctrl+F8 self.toggle = try ctx.wraith.input().bind(.{ .id = "toggle", .name = "Show the window", .chord = .{ .key = .f8, .mods = .{ .ctrl = true } }, }, .init(self, onToggle)); log.info("Hello!", .{}); }
pub fn stop(self: *Plugin) void { _ = self; }
fn draw(self: *Plugin) void { _ = self; sdk.ui.text("Hello!", .{}); }
fn onToggle(self: *Plugin, phase: W.Keybind.Phase) void { if (phase == .pressed) self.window.setOpen(!self.window.isOpen()); }};
comptime { sdk.exportPlugin(Plugin);}std_options and panic send logs and crashes to Wraith’s log. exportPlugin checks your struct and turns it into what Wraith loads. It tells you at compile time if start or stop look wrong.
A C plugin is start and stop, which WRAITH_PLUGIN exports. Where Wraith calls you back, you give it a table of functions made with SAL_TABLE.
#include "wraith_plugin.h"
static Wraith_Api w;static Wraith_Window window;
static void draw(uintptr_t self) { (void)self; Wraith_ImGui_TextUnformatted(Wraith_Api_imgui(w), "Hello!");}
static void toggle(uintptr_t self, Wraith_Keybind_Phase phase) { (void)self; if (phase == Wraith_Keybind_Phase_pressed) Wraith_Window_setOpen(window, !Wraith_Window_isOpen(window));}
static const Wraith_Window_Draw_table draw_table = { SAL_TABLE(Wraith_Window_Draw), .call = draw };static const Wraith_Keybind_Fired_table toggle_table = { SAL_TABLE(Wraith_Keybind_Fired), .call = toggle };
static bool start(sal_Host host, wraith_Guest guest) { (void)host; w = wraith_root(guest); Wraith_Window_Options options = { .title = SAL_STR("My Plugin"), .icon = SAL_STR("puzzle") }; window = Wraith_Ui_addWindow(Wraith_Api_ui(w), options, (Wraith_Window_Draw){ 0, &draw_table });
// Ctrl+F8 Wraith_Input_Action action = { .id = SAL_STR("toggle"), .name = SAL_STR("Show the window"), .chord = { .key = Wraith_Key_f8, .mods = Wraith_Mods_with_ctrl(0, true) }, }; Wraith_Keybind bound; return Wraith_Input_bind(Wraith_Api_input(w), action, (Wraith_Keybind_Fired){ 0, &toggle_table }, &bound) == SAL_OK;}
static void stop(void) {}
WRAITH_PLUGIN(start, stop)When it starts
Section titled “When it starts”Your code runs once as the plugin loads. If it fails, the plugin didn’t start, and the log says why.
Throwing while main.ts runs means the plugin didn’t start.
An error while main.lua runs means the plugin didn’t start.
Start gets a Context. Wraith’s calls throw when they fail, and throwing from Start means the plugin didn’t start.
start gives false if the plugin didn’t start. An exception from it, if you use them, means the same. wraith::api(), wraith::host() and wraith::render_queue() work from anywhere once it’s started.
start gives None if the plugin didn’t start, and a panic in it means the same. wraith::api() works from anywhere once it’s started.
start gets a ctx, which is yours for the plugin’s lifetime. Failing from start means the plugin didn’t start.
ctx.wraithis Wraith’s API. Where there’s noctxto hand,sdk.wraith.root()gives the same, or null outside a plugin.ctx.allocatoris a heap that reports leaks when the plugin unloads.ctx.iois for anything that waits.ctx.spawnstarts a task, see Waiting.ctx.config(T)andctx.gameConfig(T)load files of your own, see Settings and files.ctx.addWindow,ctx.menuItemandctx.settingsWindoware the SDK’s own windows, see UI.
start gets the plugin’s wraith_Guest, whose wraith_root(guest) is Wraith’s API, and gives false if the plugin didn’t start. Keep what you need from it, since it’s only handed over once.
Waiting
Section titled “Waiting”Plugins spend most of their time waiting, for a key, a file or the next frame. Wraith’s calls that take a while are async, and waiting on them never holds up the game. When one’s done you carry on on the thread you asked from, and hops like threads.toWorker move you.
They give promises, so await them, in an async function or at the top of main.ts.
import { Wraith } from "wraith";
await Wraith.threads().nextDraw();// one frame later, on the render threadThey give promises. promise:await() waits for one, inside task.spawn.
local Wraith = require("wraith").Wraith
task.spawn(function() Wraith.threads():nextDraw():await() -- one frame later, on the render threadend)They’re ...Async methods that give a Task, so await them. C# doesn’t allow await in unsafe code, so keep async methods out of unsafe classes.
public override void Start(Context context) => _ = Watch();
static async Task Watch(){ var threads = Threads.Instance; while (true) { await threads.NextDrawAsync(); // once a frame, on the render thread }}They give a sal::Future, which a coroutine can co_await for its sal::Result. Any function giving a sal::Future can be one.
static sal::Future<void> watch() { for (;;) { co_await wraith::api().threads().nextDraw(); // once a frame, on the render thread }}
// in startwatch();future.take() gets the result without waiting, once it’s settled, and future.then(f) runs f once it is.
Clang can’t build coroutines for 32-bit games with MSVC’s ABI, so there SAL_COROUTINES is 0 and there’s no co_await. Use then instead, keeping the future till it’s run:
static sal::Future<void, Wraith::ThreadsError> frame;
static void watch() { frame = wraith::api().threads().nextDraw(); frame.then([] { // once a frame, on the render thread watch(); });}They give a salamander::Future, which you .await for its Result. salamander::spawn runs an async block, up to its first .await that has to wait.
// in startlet _ = salamander::spawn(async { loop { if wraith::api().threads().next_draw().await.is_err() { break Ok::<(), salamander::Code>(()); } // once a frame, on the render thread }});future.take() gets the result without waiting, once it’s settled, and future.wait() blocks till it is, which is fine on a worker but never on the game’s threads.
Tasks let you write waiting as a plain loop. ctx.spawn starts one on the render thread. sdk.tasks.wait waits on anything async from Wraith, and sdk.threads.nextDraw(io) and the other hops wait for frames.
try ctx.spawn(watch, .{ self, ctx.io });
fn watch(self: *Plugin, io: std.Io) !void { while (true) { try sdk.threads.nextDraw(io); // runs once a frame, on the render thread }}Before stop, every task is cancelled. Their waits fail with error.Canceled so they can wind down.
They give a sal_Promise. sal_Promise_then runs a task once it’s settled, and sal_Promise_take gets the result, then sal_Promise_release lets it go.
static sal_Promise frame;
static void next_frame(uintptr_t self);static const sal_Task_table next_frame_table = { SAL_TABLE(sal_Task), .call = next_frame };
static void watch(void) { frame = Wraith_Threads_nextDraw(Wraith_Api_threads(w)); sal_Promise_then(frame, (sal_Task){ 0, &next_frame_table }, (sal_Queue){ 0, NULL });}
static void next_frame(uintptr_t self) { (void)self; sal_Promise_release(frame); // once a frame, on the render thread watch();}Never block the render thread or the game thread, since the game waits for them. For slow work, hop to a worker and back. See Game and render threads.
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.
There’s nothing to write. What your script made goes with it.
There’s nothing to write. What your script made goes with it.
Override Stop for your own stuff, like saving a file.
Use stop, or your class’s destructor, for your own stuff, like saving a file.
Use stop, or Drop on your type, for your own stuff, like saving a file.
Use stop for your own stuff, like freeing what you allocated.
Use stop for your own stuff, like freeing what you allocated.
Settings and files
Section titled “Settings and files”Settings players change, and files of your own, are on Settings and files.
Game types
Section titled “Game types”Put schemas in schemas/ and they become types in your language, with the offsets baked in. Get the schema right in the Workbench first, then copy it in.
Your schemas are in your plugin’s own namespace, its id in PascalCase, so my_plugin gets MyPlugin and trails_horizon gets TrailsHorizon. Inside your .sal files you don’t write it, and Wraith’s types and those of plugins you depend on work by their short names too. See Namespaces for how names are found, and how to pick another namespace.
Code finds them through their types, like Player.heal for a method or addresses.player() for where something is, so there’s no name to type out as text.
They’re under your namespace from "wraith", fully typed. Every build regenerates the types, so they’re always in step with your .sal files.
import { MyPlugin } from "wraith";
const { Player } = MyPlugin;
const player = Player.at(address)!;player.health = 100;
// A struct with [Instance] has the game's oneconst main = Player.instance;
// Where things are, found the first time you askconst healAt = Player.addresses.heal();const playerAt = MyPlugin.addresses.player();MyPlugin.addresses has your top-level statics and functions, and each struct’s addresses has its methods and statics, all but virtual ones.
Each field you read or set on player goes to the game’s memory right then, so it’s always current. That costs a little every time, which adds up in loops over lots of objects. For those, take a snapshot:
import { snapshot, save, edit } from "salamander";
const copy = snapshot(player); // one read of the whole structtotal += copy.health + copy.armor; // plain object reads, nothing touches memorycopy.health = 100;save(copy); // writes only the fields you changedA snapshot is a plain object. Structs and arrays inside it are plain too, and pointers stay live objects. It doesn’t follow memory, so take a new one when you want fresh values. save writes only what changed since the snapshot was taken, so fields the game changed meanwhile stay as they are, and it gives how many it wrote. Text fields aren’t written.
edit takes a snapshot, hands it to you, and saves it after, even if your function is async:
edit(player, (p) => { p.health = 100; p.pos.y += 2;});They’re under your namespace from require("wraith").
local game = require("wraith").MyPluginlocal Player = game.Player
local player = Player.at(address)player.health = 100
-- A struct with [Instance] has the game's onelocal main = Player.instance
-- Where things are, found the first time you asklocal heal_at = Player.addresses.heal()local player_at = game.addresses.player()Each field you read or set goes to the game’s memory right then, so it’s always current. game.addresses has your top-level statics and functions, and each struct’s addresses has its methods and statics, all but virtual ones.
Every build makes them C#, in your namespace. Structs are real structs with the offsets baked in, used through pointers.
var player = (Player*)address;player->Health = 100;
// A struct with [Instance] has the game's onevar main = Player.InstanceOrFail();
// Where things are, found the first time you askvar healAt = Player.Addresses.Heal();var playerAt = Schema.Addresses.Player();Player.Instance() gives null while the game hasn’t made it yet, and InstanceOrFail() throws. Top-level statics and functions are on the Schema class, like Schema.Player(). Functions are methods, so player->Heal(5) calls the game’s own. Each declared function also has a value under its owner’s Fns, like Player.Fns.Heal, which is what hooks take.
They’re C++ types in schema.hpp, in your namespace, with the offsets baked in and checked as it compiles. The game’s functions and statics are members you call, found by their signatures the first time.
#include "schema.hpp"
auto* player = reinterpret_cast<MyPlugin::Player*>(address);player->health = 100;
// A struct with [Instance] has the game's one, null till the game's made itMyPlugin::Player* main = MyPlugin::Player::instance();
// The game's own functionsif (main) main->heal(5);
// Where things are, by the names schema.hpp givesauto heal_at = wraith::api().schema().address(MyPlugin::Player_heal_name);Each function also has its pointer type, like MyPlugin::Player_heal_fn, for hooks.
They’re Rust types in your schema module, with the offsets baked in and checked as it compiles. The game’s functions and statics are unsafe methods you call, found by their signatures the first time.
use schema::Player;
let player = unsafe { &mut *(address as *mut Player) };player.health = 100.0;
// A struct with [Instance] has the game's one, null till the game's made itlet main = unsafe { Player::instance() };
// The game's own functionsif let Some(main) = unsafe { main.as_mut() } { unsafe { main.heal(5) };}
// Where things are, by the names schema giveslet heal_at = wraith::api().schema().address(schema::PLAYER_HEAL_NAME);Each function also has its pointer type, like schema::PlayerHealFn, for hooks.
They’re Zig types, in your namespace in the schema import.
const generated = @import("schema");const schema = generated.MyPlugin;
const player: *schema.Player = @ptrFromInt(address);player.health = 100;
// A struct with [Instance] has the game's oneconst main = try schema.Player.instanceOrFail();
// Where things are, found the first time you askconst heal_at = try schema.Player.addresses.heal();const player_at = try schema.addresses.player();They’re real extern structs with the offsets baked in. Wraith’s own types are in sdk.api.wraith. The maths ones, Vec2, Vec3, Vec4, Quat and Mat4, come from tuft with methods like add, dot, cross, normalize, lerp, rotate, slerp, mul, inverse, lookAt and perspective. They’re sdk.math too, for code that isn’t about a schema.
const t: *schema.Transform = @ptrFromInt(address);const ahead = t.rotation.rotate(.unit_z);t.position = t.position.add(ahead.scale(2));They’re C structs in schema.h, named with your namespace, with the offsets baked in and checked as it compiles. Each of the game’s functions and statics has its name, to find it by, and functions their pointer type, to call it through.
#include "schema.h"
MyPlugin_Player *player = (MyPlugin_Player *)address;player->health = 100;
// Where things are, found by their signatures the first timeuintptr_t heal_at = 0;Wraith_Schema_address(Wraith_Api_schema(w), SAL_STR(MyPlugin_Player_heal_name), &heal_at);if (heal_at) ((MyPlugin_Player_heal_fn)heal_at)(player, 5);What plugins can’t do
Section titled “What plugins can’t do”Plugins run in QuickJS, not Node or a browser. Modern JavaScript works, but APIs like fs and fetch aren’t there. npm packages that are plain JavaScript bundle in fine.
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.
C# plugins are real .NET, so nothing’s held back. Players run them like any native mod, so be as careful as you’d be with one.
C++ plugins are native code, so nothing’s held back. Players run them like any native mod, so be as careful as you’d be with one.
Rust plugins are native code, so nothing’s held back. Players run them like any native mod, so be as careful as you’d be with one.
Zig plugins are native code, so nothing’s held back. Players run them like any native mod, so be as careful as you’d be with one.
C plugins are native code, so nothing’s held back. Players run them like any native mod, so be as careful as you’d be with one.
TypeScript or JavaScript
Section titled “TypeScript or JavaScript”The only difference is the file. With --js you get src/main.js, and // @ts-check at the top still checks it against Wraith’s typings.
wraith.io · Mods on the Hub · Get Wraith
Made with ♥ by Asgard
