lotus_script/
lib.rs

1pub use lotus_bindgen_macros::lotus_bindgen;
2
3use message::Message;
4
5pub mod action;
6pub mod content;
7#[doc(hidden)]
8pub mod event;
9pub mod font;
10pub mod gizmos;
11pub mod graphics;
12pub mod input;
13pub mod log;
14#[doc(hidden)]
15pub mod macros;
16pub mod math;
17pub mod message;
18pub mod module;
19pub mod public_vars;
20pub mod rand;
21#[doc(hidden)]
22pub mod settings;
23pub mod time;
24pub mod var;
25pub mod vehicle;
26pub mod prelude {
27    pub use crate::{
28        action,
29        graphics::{textures::Texture, Color},
30        log,
31        message::{message_type, send_message, Message, MessageTarget, MessageType},
32        rand, script, time,
33        var::{get_var, set_var, VariableType},
34        vehicle, Script,
35    };
36}
37
38pub trait Script {
39    /// Initialize the script.
40    fn init(&mut self) {}
41
42    /// Register actions.
43    fn actions() -> Vec<action::RegisterAction> {
44        Default::default()
45    }
46
47    /// Tick the script.
48    fn tick(&mut self) {}
49
50    /// Handle a message.
51    #[allow(unused_variables)]
52    fn on_message(&mut self, msg: Message) {}
53}
54
55/// Returns true if the object the script is attached to is remote controlled.
56pub fn is_rc() -> bool {
57    unsafe { lotus_script_sys::env::is_rc() }
58}