1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
pub use lotus_bindgen_macros::lotus_bindgen;

use message::Message;

pub mod action;
pub mod content;
#[doc(hidden)]
pub mod event;
pub mod font;
pub mod gizmos;
pub mod graphics;
pub mod input;
pub mod log;
#[doc(hidden)]
pub mod macros;
pub mod math;
pub mod message;
pub mod public_vars;
pub mod rand;
#[doc(hidden)]
pub mod settings;
pub mod time;
pub mod var;
pub mod vehicle;
pub mod prelude {
    pub use crate::{
        action,
        graphics::{textures::Texture, Color},
        log,
        message::{message_type, send_message, Message, MessageTarget, MessageType},
        rand, script, time,
        var::{get_var, set_var},
        Script,
    };
}

pub trait Script {
    /// Initialize the script.
    fn init(&mut self) {}

    /// Register actions.
    fn actions() -> Vec<action::RegisterAction> {
        Default::default()
    }

    /// Tick the script.
    fn tick(&mut self) {}

    /// Handle a message.
    #[allow(unused_variables)]
    fn on_message(&mut self, msg: Message) {}
}

/// Returns true if the object the script is attached to is remote controlled.
pub fn is_rc() -> bool {
    unsafe { lotus_script_sys::is_rc() }
}