#[no_std, cache_output] constants = import "constants.spwn" extract constants.obj_props type @event impl @event { on: #[desc("Triggers a function every time an event fires") example(" on(touch(), !{ 10g.move(10, 0) }) ")] ( #[desc("Event to trigger on")] event: @event, #[desc("Function to trigger")] function: @trigger_function ){ event.on_triggered(function) } } return { touch: #[desc("Implementation of the touch trigger (returns an event)") example(" on(touch(), !{ 10g.move(10, 0) }) ")] ( #[desc("Dual mode (only check for touch on the dual side)")] dual_side: @bool = false ) { return @event::{ on_triggered: (function) => $.add( trigger{ OBJ_ID: 1595, HOLD_MODE: true, TOGGLE_MODE: 1, TARGET: function, DUAL_MODE: dual_side, }) } }, touch_end: #[desc("Returns an event for when a touch ends") example(" on(touch_end(), !{ 10g.move(-10, 0) }) ")] ( #[desc("Dual mode (only check for touch on the dual side)")] dual_side: @bool = false ) { return @event::{ on_triggered: (function) => $.add( trigger{ OBJ_ID: 1595, HOLD_MODE: true, TOGGLE_MODE: 2, TARGET: function, DUAL_MODE: dual_side, }) } }, collision: #[desc("Implementation of the collision trigger (returns an event)") example(" on(collision(1b, 2b), !{ BG.set(255, 0, 0) }) ")] ( #[desc("Block A ID")] a: @block, #[desc("Block B ID")] b: @block ) { return @event::{ on_triggered: (function) => $.add( trigger{ OBJ_ID: 1815, BLOCK_A: a, BLOCK_B: b, ACTIVATE_GROUP: true, ACTIVATE_ON_EXIT: false, TARGET: function, }) } }, collision_exit: #[desc("Returns an event for when a collision exits") example(" on(collision_exit(1b, 2b), !{ BG.set(0, 0, 0) }) ")] ( #[desc("Block A ID")] a: @block, #[desc("Block B ID")] b: @block ) { return @event::{ on_triggered: (function) => $.add( trigger{ OBJ_ID: 1815, BLOCK_A: a, BLOCK_B: b, ACTIVATE_GROUP: true, ACTIVATE_ON_EXIT: true, TARGET: function, }) } }, death: #[desc("Returns an event for when the player dies") example(" on(death(), !{ BG.set(0, 0, 0) }) ")] (){ return @event::{ on_triggered: (function) => $.add( trigger{ OBJ_ID: 1812, ACTIVATE_GROUP: true, TARGET: function }) } } }