multi board

This commit is contained in:
2026-06-13 01:25:58 -05:00
parent e5c6affc41
commit 73c8a9bd3e
13 changed files with 456 additions and 445 deletions
+5 -2
View File
@@ -164,7 +164,10 @@ impl ScriptHost {
/// compiles every script referenced by an object (once each), and creates a fresh
/// scope and output queue per scripted object. Compile errors and references to
/// unknown scripts are queued onto the error sink; no script is run here.
pub fn new(board_cell: &BoardRef) -> Self {
///
/// `scripts` is the world-level script pool (script name → Rhai source); it is
/// read only during construction and not retained afterward.
pub fn new(board_cell: &BoardRef, script_sources: &HashMap<String, String>) -> Self {
let board_queue: BoardQueue = Rc::new(RefCell::new(Vec::new()));
let queues: QueueMap = Rc::new(RefCell::new(HashMap::new()));
let errors: ErrorSink = Rc::new(RefCell::new(Vec::new()));
@@ -186,7 +189,7 @@ impl ScriptHost {
for obj in board.objects.values() {
let Some(name) = obj.script_name.as_ref() else { continue; };
if scripts.contains_key(name) || failed.contains(name) { continue; }
match board.scripts.get(name) {
match script_sources.get(name) {
Some(src) => match engine.compile(src) {
Ok(ast) => {
let defines = |n: &str, params: usize| {