Expand description

Unofficial Rust binding for OpenTTD Social Integration API.

Use init for entrypoint.

§Examples

use openttd_social_integration_api::{OpenTTDInfo, PluginApi};

fn shutdown() {
    println!("Shutting down!");
}

fn run_callbacks() -> bool {
    // This println will make log full of garbage.
    return true;
}

fn event_enter_main_menu() {
    println!("Entering main menu!");
}

fn event_enter_scenario_editor(map_width: u32, map_height: u32) {
    println!("Entering scenario editor ({}x{})!", map_width, map_height);
}

fn event_enter_singleplayer(map_width: u32, map_height: u32) {
    println!("Entering singleplayer ({}x{})!", map_width, map_height);
}

fn event_enter_multiplayer(map_width: u32, map_height: u32) {
    println!("Entering multiplayer ({}x{})!", map_width, map_height);
}

fn event_joining_multiplayer() {
    println!("Joining multiplayer!");
}

#[openttd_social_integration_api::init(platform = "test", name = "Test Plugin", version = "0.1")]
pub fn init(info: OpenTTDInfo) -> Result<Option<PluginApi>, ()> {
    println!("Init for OpenTTD {}", info.openttd_version);
    Ok(Some(PluginApi {
        shutdown: Some(shutdown),
        run_callbacks: Some(run_callbacks),
        event_enter_main_menu: Some(event_enter_main_menu),
        event_enter_scenario_editor: Some(event_enter_scenario_editor),
        event_enter_singleplayer: Some(event_enter_singleplayer),
        event_enter_multiplayer: Some(event_enter_multiplayer),
        event_joining_multiplayer: Some(event_joining_multiplayer)
    }))
}

Modules§

Structs§

  • Pointers supplied by OpenTTD, for the plugin to use.
  • Pointers supplied by the plugin for OpenTTD to use.

Attribute Macros§

  • Decorates the entrypoint function of a plugin.