Expand description
build-time TOML compiler for lunar game data tables.
call from your crate’s build.rs to compile TOML source files into binary
blobs that can be loaded at runtime by lunar_gamedata::GameData.
§build.rs example
ⓘ
fn main() {
let src = std::fs::read_to_string("assets/data/enemies.toml").unwrap();
let blob = lunar_gamedata_build::compile_toml(&src).unwrap();
let out = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
std::fs::write(out.join("gamedata.bin"), blob).unwrap();
println!("cargo:rerun-if-changed=assets/data/enemies.toml");
}§TOML format
use array-of-tables syntax. every record must contain an id string field.
duplicate ids within a table are compile errors.
[[enemies]]
id = "goblin"
health = 100
speed = 2.5
sprite = "goblin.png"
boss = false
[[enemies]]
id = "orc"
health = 250
speed = 1.5supported TOML value types: String, Integer, Float, Boolean.
arrays, inline tables, and datetimes are not supported.
Functions§
- compile_
scene - compile a RON scene source string into the compact binary format.
- compile_
scene_ file - compile a RON scene file into the compact binary format.
- compile_
toml - compile a TOML source string into a binary blob.
- compile_
toml_ file - compile a TOML file to a binary blob.
- compile_
world_ manifest - compile a world manifest XML source string into the compact binary format.
- compile_
world_ manifest_ file - compile a world manifest XML file into the compact binary format.