openOMSI Development Tools

The Rust SDK

openomsi-plugin-sdk is the guest library for Rust plugins. A plugin is a cdylib built for wasm32-unknown-unknown.

use openomsi_plugin_sdk as omsi;

omsi::plugin!(|| {
    // Register handlers here; this closure runs once at start.
    omsi::on_vehicle(|name| {
        if let Some(name) = name {
            let _ = omsi::api::message(&format!("You drive the {name}"), Some(6.0));
        }
    });

    omsi::every(0.5, || {
        let kmh = omsi::api::speed().unwrap_or(0.0);
        // build a HUD panel, etc.
        let _ = kmh;
    });
});

What the SDK gives you

Data crosses the boundary as JSON (serde_json::Value). The SDK and the oopc build take care of compiling to a stripped WebAssembly module.

Regenerating the typed API

When the game ships a bigger API manifest, regenerate the wrappers with one command:

cargo xtask gen-sdk path/to/api.json