screeps/console.rs
1//! Utility functions for visuals that the game API exposes on the `console`
2//! object.
3use js_sys::JsString;
4use wasm_bindgen::prelude::*;
5
6#[wasm_bindgen]
7extern "C" {
8 /// Add a visual, in json format, or multiple visuals separated by `\n`.
9 /// Each line must be:
10 /// - A serialized [`Visual`], applying to a given room, if the target is
11 /// the name of a room
12 /// - A serialized [`Visual`], which will be shown in all rooms, if target
13 /// is `None`
14 /// - A serialized [`MapVisualShape`], if the target is "map"
15 ///
16 /// [`Visual`]: crate::objects::Visual
17 /// [`MapVisualShape`]: crate::objects::MapVisualShape
18 #[wasm_bindgen(js_namespace = console, js_name = addVisual)]
19 pub fn add_visual(target: Option<&JsString>, visual: &JsValue);
20
21 /// Get the visuals applied to a given target so far in the current tick
22 /// separated by `\n`, with the taget being visuals applied to a given room,
23 /// `None` for visuals applied for all rooms, or "map" for map visuals.
24 #[wasm_bindgen(js_namespace = console, js_name = getVisual)]
25 pub fn get_visual(target: Option<&JsString>) -> Option<JsString>;
26
27 /// Get the size of the visuals applied for the current tick, either for a
28 /// given room, `None` for visuals applied for all rooms, or "map" for
29 /// map visuals.
30 #[wasm_bindgen(js_namespace = console, js_name = getVisualSize)]
31 pub fn get_visual_size(target: Option<&JsString>) -> u32;
32
33 /// Clear all of the set visuals for the current tick, either for a given
34 /// room, `None` for visuals applied for all rooms, or "map" for map
35 /// visuals.
36 #[wasm_bindgen(js_namespace = console, js_name = clearVisual)]
37 pub fn clear_visual(target: Option<&JsString>);
38}