SelectionControls
Selecting as in a real-time strategy game, with no code: put it on the camera, and Selectable on what can be selected. A click picks one, a left-drag draws a box that picks those inside it, AddToSelection (Shift) held adds to the selection (or takes one out of it), a double-click picks every one of that kind on screen, and AssignGroup (Ctrl) with a number keeps the selection as that control group, the number alone picks it again and pressing it twice quickly moves the camera to it. Esc clears it. A right-click with something selected is a command the game carries out itself: Commanded says what was under the mouse and what’s selected.
Its keys are the input actions Select (left click), Command (right click), AddToSelection (Shift), AssignGroup (Ctrl) and Group1 to Group9 (the number keys), so Game > Controls and the player’s Rebind buttons change them. Clicks on buttons and the HUD don’t select, and while it’s Busy (a tool in hand) it leaves the mouse alone. Esc closes an open window first, and with something selected it clears the selection rather than opening the game menu. The selection is this machine’s own; in a network game, the game sends the orders a command gives.
Works with: Selectable (what it selects); CameraControls (pans and zooms; set its Drag Button to Middle to keep the right button for commands)
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.
In a network game, each machine keeps its own entity with this on it: it isn’t sent.
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.
controllable: true or false = true. Untick it to have it ignore the mouse and keys while the game plays on: another part of the scene has the player’s input. Its Focus action ticks it and unticks it on everything else the player plays. (Field: on or off.)busyFlag: text = null. A flag that makes it busy while it’s set, as Busy does, e.g. “Building” (set by a trigger’s Set Flag or a script’s Game.SetFlag), or “not Ready” for while it isn’t. Empty for none. (Names a flag: “Name” holds while it’s set, “not Name” while it isn’t.) (Field: a name.)doubleClickSeconds: a number = 0.35. How quickly, in seconds, a second click on the same thing makes a double-click (picking all of its kind on screen), and a second press of a group’s number moves the camera to the group. (Field: a number.)
markerColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#57D36BFF”. The color of the marker round each thing selected, or what tints its MarkerImage. (Field: a color.)markerImage: text = null. A picture drawn round each thing selected, stretched to its area plus MarkerPadding, e.g. a bracket frame. Empty draws an outline in MarkerColor. (A picture in Assets, e.g. “Sprites/back.png”.) (Field: an image.)markerSlice: a number = 0. For a MarkerImage that stretches (nine-slice): how much of it, from 0 to 0.5 of its width and height, is border at each edge, as a sprite’s Slice. 0 stretches the whole picture. (Only used when markerImage is set.) (Field: a number.)markerSliceSize: a number = 0.25. With MarkerSlice: how big the marker’s border is drawn, in world units. (Only used when markerImage is set.) (Field: a number.)markerPadding: a number = 0.1. How far the marker stands out from each thing’s area, in world units. (Field: a number.)boxColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#57D36BFF”. The color of the box drawn while dragging one out, or what tints its BoxImage. (Field: a color.)boxImage: text = null. A picture stretched over the box while dragging one out. Empty draws a faint fill and an outline in BoxColor. (A picture in Assets, e.g. “Sprites/back.png”.) (Field: an image.)boxSlice: a number = 0. For a BoxImage that stretches (nine-slice): how much of it is border at each edge, from 0 to 0.5. (Only used when boxImage is set.) (Field: a number.)boxSliceSize: a number = 0.25. With BoxSlice: how big the box’s border is drawn, in world units. (Only used when boxImage is set.) (Field: a number.)
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”).
Clear. Selects nothing, as Esc does.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).
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.
SelectedCount(a whole number). How many things are selected.
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.
busy: true or false. True while the mouse is busy with something else (a building tool in hand, a road being painted): it neither selects, commands nor clears, so the game’s left-drag can paint. Set by scripts; see also BusyFlag. A LineTool in hand (its Controllable ticked) makes it busy too.selectedCount: a whole number. How many things are selected.isDragging: true or false. True while a box is being dragged out.
Scripts use it as SelectionControls: its methods, events and values that aren’t saved with the scene.