Skip to main content

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}
37pub use lotus_shared::animation::*;
38
39pub trait Script {
40    /// Initialize the script.
41    fn init(&mut self) {}
42
43    /// Register actions.
44    fn actions() -> Vec<action::RegisterAction> {
45        Default::default()
46    }
47
48    /// Tick the script.
49    fn tick(&mut self) {}
50
51    /// Handle a message.
52    #[allow(unused_variables)]
53    fn on_message(&mut self, msg: Message) {}
54}
55
56/// Returns true if the object the script is attached to is remote controlled.
57pub fn is_rc() -> bool {
58    unsafe { lotus_script_sys::env::is_rc() }
59}