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 pis {
27    pub use lotus_shared::pis::*;
28}
29pub mod prelude {
30    pub use crate::{
31        action,
32        graphics::{textures::Texture, Color},
33        log,
34        message::{message_type, send_message, Message, MessageTarget, MessageType},
35        rand, script, time,
36        var::{get_var, set_var, VariableType},
37        vehicle, Script,
38    };
39}
40pub use lotus_shared::animation::*;
41
42pub trait Script {
43    /// Initialize the script.
44    fn init(&mut self) {}
45
46    /// Register actions.
47    fn actions() -> Vec<action::RegisterAction> {
48        Default::default()
49    }
50
51    /// Tick the script.
52    fn tick(&mut self) {}
53
54    /// Handle a message.
55    #[allow(unused_variables)]
56    fn on_message(&mut self, msg: Message) {}
57}
58
59/// Returns true if the object the script is attached to is remote controlled.
60pub fn is_rc() -> bool {
61    unsafe { lotus_script_sys::env::is_rc() }
62}