SandboxTools
Garry’s Mod style tools for building contraptions while the game runs: grab and throw things, freeze them in place, spawn props, weld, hinge and rope them together, wire buttons to lamps, thrusters and wheels’ motors, and remove them. Pick a tool along the top of the screen (or with the number keys and mouse wheel); Z undoes the last thing made.
Part of the Contraptions module: Contraptions, Garry’s Mod and Wiremod style: building tools used while the game runs (SandboxTools), welds, ropes and thrusters, wiring with buttons, sensors, gates, lamps and displays, and the Contraption template.
Props are prefabs: give them a Body and a collider to grab and weld them, and wiring parts (WireGate, WireButton, WireLamp, Thruster…) to wire them. Things built with the tools are kept in the scene, so Keep Play Changes (Ctrl+K) brings a contraption back to the editor.
Works with: Weld (what the Weld tool makes); HingeJoint (what the Hinge tool makes); Rope (what the Rope tool makes); Wire (what the Wire tool makes)
Takes the player’s input only while it has focus (its Controllable): its Focus action hands it the input and takes it from everything else the same player plays.
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.
tools: text = “Grab, Spawn, Weld, Hinge, Rope, Wire, Remove”. The tools it has, in order, separated by commas: Grab, Spawn, Weld, Hinge, Rope, Wire and Remove. (Tools in order, separated by commas, each one of Grab, Spawn, Weld, Hinge, Rope, Wire, Remove. The Inspector lists them a row each, picked, to add, remove and reorder.) (Field: its own editor: List Of.)props: text = “Crate”. The props the Spawn tool can put down, by prefab name, separated by commas, e.g. “Crate, Ball, Lamp”. (Names prefabs: their names, separated by commas.) (Field: a name.)selected: a whole number = 0. The tool in hand, counting from 0 along Tools. (Field: a number.)selectedProp: a whole number = 0. The prop the Spawn tool puts down, counting from 0 along Props. (Field: a number.)grabStrength: a number = 14. How hard a grabbed thing is pulled to the mouse: higher follows more tightly. (Field: a number.)reach: a number = 0. How far from the entity the tools reach, in world units. 0 reaches anywhere on screen. (A distance: the Scene view draws it as a circle around the entity, with a handle to drag.) (Field: a number.)within: text = null. The part of the scene the tools work on, by an entity’s name: they grab, weld, rope, wire and remove only what’s inside that entity or standing in its area (a Room’s, a tilemap’s, a collider’s), and spawn only in its area (or, for an entity with no area, into it), e.g. “Workshop”. Empty works on the whole scene. (Names an entity.) (Field: an entity’s name.)controllable: true or false = true. Untick it to put the tools down: no HUD, and clicks and keys go to whatever else has the player’s input. Its Focus action ticks it and unticks it on everything else the player plays, and another’s Focus takes it back. (Field: on or off.)undoKey: one of None, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, Space, Enter, Escape, Tab, Backspace, Left, Right, Up, Down, LeftShift, RightShift, LeftControl, RightControl, LeftAlt, RightAlt, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, Delete, Insert, Home, End, PageUp, PageDown, CapsLock, NumPad0, NumPad1, NumPad2, NumPad3, NumPad4, NumPad5, NumPad6, NumPad7, NumPad8, NumPad9, NumPadPlus, NumPadMinus, NumPadMultiply, NumPadDivide, NumPadDecimal, Minus, Equals, Comma, Period, Slash, Backslash, Semicolon, Quote, LeftBracket, RightBracket, Grave = “Z”. The key that undoes the last prop, weld, hinge, rope or wire made. (Field: one of its values.)sound: text = null. A sound played when a tool does something (spawns, welds, wires). (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
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”).
Focus. Gives its entity the player’s input: whatever there and inside it has focus, and everything else the same player plays loses it (a platformer’s player stops on the arrow keys while a board takes them).
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
propList: lines of text: an array of strings, or one string with line breaks. The props as listed in Props.current: one of Grab, Spawn, Weld, Hinge, Rope, Wire, Remove or null. The tool in hand, or null if it has none.currentProp: text. The prop the Spawn tool puts down, or null if there are none.
Scripts use it as SandboxTools: its methods, events and values that aren’t saved with the scene.