Skip to content

LineTool

Lets the player lay a line on the grid by dragging, as a factory game’s belt tool does: press on a cell, drag, let go. The line runs from the cell pressed on to the one under the mouse, along one axis and round a corner, each cell pointing the way the line runs; a see-through ghost shows where it goes, GhostColor where it fits and BlockedColor where it can’t. Letting go lays the cells that fit on a Conveyor as belts and on a Tiles map with its LineTiles, and raises Placed, so a script can lay something else (build orders, walls) or charge for it. R (the Rotate action) turns a single cell, or swaps the corner while dragging; a right-click (Command) or untick Controllable drops the line. With Joins, a line dragged from another’s end carries it on, and one dragged into or out of a line’s side merges or splits.

Put it on the camera (or anywhere) and untick Controllable while another tool is in hand: while it’s ticked, a SelectionControls leaves the mouse to it. Where a cell can’t go is up to StayOnMap, BlockedByWalls (solid tiles and colliders, as grid movers see them, but not the belts of its own conveyor, which a line laid over turns), BlockedByMovers, MaxCells (what the money covers, say) and a script’s CanLay.

The drag is this machine’s own, and isn’t kept by a rewind; what it lays is the scene’s, like anything else a script changes. In a network game, have a client’s script send the host what Placed gives, as a command.

Works with: Conveyor (lays belts on it); LineTiles (lays a tilemap’s line tiles); SelectionControls (leaves the mouse to it while it’s in hand)

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.

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 while another tool is in hand (or none): it leaves the mouse alone and drops a line being dragged. Its Focus action ticks it and unticks it on everything else the player plays. (Field: on or off.)
  • map: text = null. The tilemap whose cells it lays on. Empty uses its Conveyor’s map, else its Tiles map, else the tilemap on its own entity or the one it’s inside, else the first in the scene; with none, cells are world units centered on whole numbers, as for a grid mover. (Names an entity.) (Field: an entity’s name.)
  • conveyor: text = null. A conveyor to lay the line on as belts when it’s let go, turning belts already there. Empty lays no belts. (Names an entity.) (Field: an entity’s name.)
  • beltKind: one of Belt, Crossing, Split, Under = “Belt”. What it lays on the Conveyor: belts, crossings (walkers step over), splitters or unders (a line passes beneath). (Field: one of its values.)
  • tiles: text = null. A tilemap with LineTiles to lay the line’s tiles on when it’s let go, straight pieces and corners turned to follow it: a layer for belts, pipes or rails. Empty lays no tiles. (Names an entity.) (Field: an entity’s name.)
  • corners: true or false = true. True to turn a corner to reach the mouse; untick it for straight lines only, across or up and down, whichever way it’s dragged further (a wall tool). (Field: on or off.)
  • firstLeg: one of Started, Longer = “Started”. Which leg of a line with a corner comes first: the way the drag started (the default), or the way it’s dragged further. (Field: one of its values.)
  • way: one of Right, Down, Left, Up = “Right”. Which way a single cell points (a click without dragging). The Rotate action turns it a quarter clockwise. (Field: one of its values.)
  • joins: true or false = false. True to join a line onto those already laid (its Conveyor’s belts, else its Tiles’ pieces): dragged from a line’s end it carries that line on (the old end turns to feed it, keeping its kind and speed, and its tile becomes a straight piece or a corner); dragged out of a line’s side it splits off it (that belt becomes a splitter); and ended on a line’s side it merges in (that belt stays as it is, the cell before it pointing in). The ghost shows the join. Unticked, each line is laid on its own, turning the belts it’s laid over. (Field: on or off.)
  • action: text = “Select”. The input action held to drag a line, e.g. “Select” (the left mouse button). (Names an input action.) (Field: a name.)
  • rotateAction: text = “Rotate”. The input action that turns a single cell a quarter clockwise, or swaps the corner while dragging, e.g. “Rotate” (R). (Names an input action.) (Field: a name.)
  • cancelAction: text = “Command”. The input action that drops a line being dragged without laying it, e.g. “Command” (the right mouse button). (Names an input action.) (Field: a name.)
  • stayOnMap: true or false = true. True if cells off the map’s grid can’t take the line. (Field: on or off.)
  • blockedByWalls: true or false = true. True if walls block it, as they do grid movers: solid tiles, solid colliders and other conveyors’ solid belts. (Field: on or off.)
  • blockingLayers: text = null. Collision layers whose solid colliders block it, e.g. “Machines, Walls”. Empty: any solid collider does. (Names collision layers: their names, separated by commas.) (Field: a name.)
  • blockedByMovers: true or false = false. True if a cell with a grid mover in it (a worker standing there), or heading into it, can’t take the line. (Field: on or off.)
  • maxCells: a whole number = 0. The most cells a line can have: those past it are blocked (what the money covers, set by a script). 0 for no limit. (Field: a number.)
  • ghostColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#59E67373”. The ghost’s tint where the line fits. (Field: a color.)
  • blockedColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#FF4C4C80”. The ghost’s tint where the line can’t go. (Field: a color.)
  • message: text = null. A message sent with Game.Send when a line is laid, with how many cells as its data. (Names a message.) (Field: a name.)

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”).

  • Rotate. Turns the single cell’s Way a quarter clockwise, or while a line is dragged, swaps its corner: what the Rotate action does.
  • Cancel. Drops the line being dragged without laying it.
  • 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).

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • isDragging: true or false. True while a line is being dragged.
  • hover: [x, y], whole numbers or null. The cell under the mouse while it’s in hand, or null.

Scripts use it as LineTool: its methods, events and values that aren’t saved with the scene.