- Home
- Developer Documentation
- API reference
API reference
The most used calls of the SDK. Every header is documented in its own comments.
All headers are in include/sw/ of the public repository. The comments in a header say what is proven and what is not. Every call that talks to the game fails closed: it returns false or nullptr when the game does not match.
The complete header reference (every header with its comments, recipes, generated tables) is the API wiki.
Mod framework sw::mod (sw/mod.hpp)#
| Call | Purpose |
|---|
SW_MOD("name") | Declares the mod (export of name, shutdown and the DLL entry point). |
void sw_mod_start() / void sw_mod_stop() | You write these. Start runs on its own thread. |
bool sw::mod::running() | False as soon as the mod should unload. |
bool sw::mod::sleep(unsigned ms) | Waits; returns false if unloading begins. |
Runtime& sw::mod::rt() | The runtime of the game (already connected and checked). |
void sw::mod::log(fmt, ...) | Console window and log file. |
Runtime sw::Runtime (sw/runtime.hpp)#
| Call | Purpose |
|---|
hook_api / hook_ctor / hook_method / hook_rva | Install hooks (see Events and hooks). |
resolve(api) | The address of a mapped Lua handler. |
readable(ptr, size) | Is this memory readable? |
read_rva<T> / write_rva<T> / write_bytes | Read or write game memory. Writing changes the game. |
class_of(obj) / is_instance_of(obj, cls) / class_vtable(cls) | Identify objects by their vtable. |
is_function_start(addr) | Is this the start of a function in the main module? |
Objects sw::Instances (sw/instances.hpp)#
| Call | Purpose |
|---|
track(cls, err) | Start watching the constructors of a class. |
list(cls) | Addresses of the live objects. |
untrack(cls) / tracked() | Stop watching / what is watched. |
| Header | Gives |
|---|
tiles.hpp, start_tiles.hpp, world.hpp | Tile system, your own start card, islands |
weather.hpp | Weather, wind, time of day |
render.hpp | Frame end, OpenGL, shaders, uniforms, render targets |
audio.hpp, input.hpp, camera.hpp, physics.hpp | Audio engine, input callbacks, cameras, the physics world |
vehicle.hpp | Spawned vehicles and components (read only) |
vfs.hpp, overlay.hpp | Mod folders in the game without writing |
network.hpp, game_state.hpp | Message ids and application states |
flags.hpp, mapicons.hpp, textures.hpp, mesh.hpp, trees.hpp | Flags, map icons, textures, meshes, trees |
discord.hpp | Discord Rich Presence |
Documentation for game build 1.15.26. Found a mistake? Open an issue.