This project is an example of how to use wasmtime as a modding system for games written in Rust. I use a wrapper around wasmtime made by DouglasDwyer.
- Event system
- Internal data
- Callbacks
- Graphics
- Player control example
src- Game logic.wit- WIT API defenitions.mods- Crates with module logic compiled to WASM.crates- Some packages to simplify code.mod_macros- A few macros to make mod creation easier.mod_manager- Abstraction for interacting with WASM packages.utils- Utils for development.types- Type defs shared between mods and game.
Build occurs in two stages: main executable and mods. Mods are built through the build.rs file which runs build scripts inside mod directories and copies binaries into the wasm folder next to the executable.
NOTE: The build scripts are in bash format. Support for windows is planned in the future
Make sure you have rust, cargo, and wasm-tools installed on your machine.
Install wasm32-unknown-unknown build target with:
rustup target add wasm32-unknown-unknownRun with:
RUST_LOG=info cargo run