transporters

This commit is contained in:
2026-07-08 10:06:25 -05:00
parent e43dae54a8
commit f407b5d9a6
14 changed files with 323 additions and 34 deletions
+7 -6
View File
@@ -27,7 +27,7 @@
//!
//! `move(dir)`, `delay(secs)`, `now()`, `set_tile(n)`, `log(msg)`, `say(msg)`,
//! `set_fg(fg)`, `set_bg(bg)`, `set_color(fg, bg)`, `set_tag(target, tag, present)`,
//! `send(target_id, fn_name [, arg])`, `teleport(x, y)`, `push(x, y, dir)`,
//! `send(target_id, fn_name [, arg])`, `teleport(id, x, y)`, `push(x, y, dir)`,
//! `shift([[x, y], …])`, `alter_gems(n)`, `alter_health(dh)`, `set_key(color, present)`, `die()`
use crate::action::{Action, BoardAction, ScrollLine, SendArg, MOVE_COST};
@@ -554,12 +554,13 @@ fn register_write_api(engine: &mut Engine, board: BoardRef) {
},
);
// teleport(x, y): move the calling object to an arbitrary cell. Zero time cost.
// Blocked (with an error logged at resolve time) if the object is solid and the
// destination already has a solid occupant.
// teleport(target, x, y): move object `target` to an arbitrary cell (pass your
// own `me.id` to move yourself; `target == -1` moves the player). Zero time
// cost. Blocked (with an error logged at resolve time) if that entity is solid
// and the destination already holds a different solid occupant.
let b = board.clone();
engine.register_fn("teleport", move |ctx: NativeCallContext, x: i64, y: i64| {
emit(&b, source_of(&ctx), Action::Teleport { x, y });
engine.register_fn("teleport", move |ctx: NativeCallContext, target: i64, x: i64, y: i64| {
emit(&b, source_of(&ctx), Action::Teleport { target, x, y });
});
// push(x, y, dir): shove the pushable chain at (x, y) one step in dir. Acts on