Switch
Turns things on and off with no code: levers, pressure plates, buttons, locks. While it’s on, its Targets are on (a mover moves, a spawner spawns, a door unlocks, anything else appears) and its Hides are hidden (a barrier, a wall of spikes). While it’s off, it’s the other way round, from the start of the game. Needs a collider, usually a trigger.
Names are looked for inside the switch first, so a locked block can hide itself; otherwise every entity in the scene with that name is switched. If several switches name the same entity, it’s on only while all of them are, so a gate can need two plates held down.
Requires: Collider (usually a trigger)
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
mode: one of Lever, Plate, Button = “Lever”. How it’s switched: a lever flipped with Interact, a plate held down by standing on it, or a button pressed once. (Field: one of its values.)isOn: true or false = false. True while it’s on. Tick it to start switched on; scripts can set it too. (Field: on or off.)targets: text = null. What it turns on, by name, separated by commas: a Mover moves (a MoverMode.Once one slides back when it’s switched off again), a Spawner or Shooter runs, particles emit, an animation plays, a Door unlocks; anything else appears. (Names entities: their names, separated by commas.) (Field: an entity’s name.)hides: text = null. What it hides while it’s on, by name, separated by commas: a barrier, a locked block (even itself). (Names entities: their names, separated by commas.) (Field: an entity’s name.)
Working It
Section titled “Working It”layers: text = “Player”. The collision layers that work it, e.g. “Player” or “Player, Crate”. Empty lets anything with a Body. (Names collision layers: their names, separated by commas.) (Field: a name.)key: text = null. An item it needs to turn on, e.g. “Key”: whoever works it must have one in their Inventory, and it’s used up. It only takes it once; after that this is cleared and it works like any other switch. (Names an item.) (Field: a name.)needsFlag: text = null. A flag that has to be set before it can be worked, e.g. “PowerOn” (set by a trigger’s Set Flag, a dialogue’s “[set PowerOn]” or a script’s Game.SetFlag), or “not PowerOn” for while it isn’t. Until then levers, plates and buttons do nothing and its prompt stays hidden; a trigger’s or script’s On still turns it on. (Names a flag: “Name” holds while it’s set, “not Name” while it isn’t.) (Field: a name.)onTime: a number = 0. Seconds it stays on before turning itself off again: a timed button. 0 stays on. (Field: a number.)prompt: text = null. The name of an entity to show only while it can be worked with Interact, e.g. a “Press E” hint above a lever. It’s hidden the rest of the time. (Names an entity.) (Field: an entity’s name.)
Sound and Messages
Section titled “Sound and Messages”sound: text = null. A sound played when it turns on or off, e.g. “Sounds/click.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)onMessage: text = null. A message sent with Game.Send when it turns on, with this entity as its data. (Names a message.) (Field: a name.)offMessage: text = null. A message sent with Game.Send when it turns off, with this entity as its data. (Names a message.) (Field: a name.)
onTint: a color, “#RRGGBB” or “#RRGGBBAA” = “#57AB5AFF”. The color its sprite turns while it’s on. Transparent leaves it alone. (Field: a color.)onFrame: a whole number = -1. The sprite-sheet frame its sprite shows while it’s on (a lever pulled the other way). -1 leaves it alone. (Field: a number.)
beats: a whole number = 0. Steps to the music of a BeatClock: flips itself on or off on every this many beats, as well as however it’s worked (though a plate stays as it’s held): spikes that come and go, a gate that opens on the bar. 0 doesn’t. (Field: a number.)beatOffset: a whole number = 0. Steps this many beats later: with two on every 2 beats, one 1 beat later, they take turns. (Only used when beats is set.) (Field: a number.)clock: text = null. The entity whose BeatClock it steps to. Empty follows the first in the scene. (Only used when beats is set.) (Names an entity.) (Field: an entity’s name.)
Actions
Section titled “Actions”What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).
On. Turns it on, as working it does (sounding, sending its On Message and switching its targets).Off. Turns it off.Toggle. Turns it on if it’s off, and off if it’s on.
Outputs
Section titled “Outputs”What anything can read with no code: a Counter’s, Bar’s or Text’s output, a Contraptions Wire’s output as its signal; Text shows names too, the rest read numbers, true as 1.
On(true or false). True while it’s on. Tick it to start switched on; scripts can set it too.
Scripts use it as Switch: its methods, events and values that aren’t saved with the scene.