TurnOrder
Turn-based play with no code: teams take turns, each acting on its own turn while the others wait. List its Teams in order (“Player, Enemy”, or “Blue, Red” for two people at one keyboard) and give whatever acts a TurnTaker naming its team. Teams are the one idea every genre shares (see Teams). Off its team’s turn a turn taker takes no input and its patrols, chases, attacks and shooters hold still; everything else (physics, animations, things with no turn taker) runs in real time as ever, so a turn can be a stretch of real-time play, as in Worms. A turn ends when its team presses End Turn (Tab, the gamepad’s Back, or a button whose Action is End Turn), when its time runs out, or once every turn taker on it has used its actions. With a Text beside it, it shows whose turn it is. For a roguelike, where everything moves when the player moves, give the grid player and the grid enemies turn takers with 1 action and set Between to 0: each step is a turn, and an enemy with nowhere to go passes.
It covers the whole scene, or with Within only part of it: a turn-based arena in a real-time game, or two boards each taking their own turns. A turn taker takes turns in the turn order whose Within covers it (inside that entity, or standing in its area), else in one over the whole scene; one covered by none acts freely. In a network game the host runs it, and with Multiplayer.Teams each player’s character is on its player’s team: the same “Blue, Red” teams.
Works with: TurnTaker (on whatever takes turns); Text (shows whose turn it is)
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.
teams: text = “Player, Enemy”. The teams in the order they take turns, separated by commas, e.g. “Player, Enemy”. A team with no turn takers left is skipped (unless no team has any, for a game whose scripts take the turns). They’re the teams every genre shares: a strategy faction’s, a network game’s, a Team’s. (Formerly Sides.) (Teams in order (as a list, one a line; as text, separated by commas), at least 1. The Inspector lists them a row each to rename, add, take out and reorder.) (Names a team: this entity’s own, which other fields can name.) (Field: its own editor: Name List.)computerTeams: text = “Enemy”. The teams the computer plays, e.g. “Enemy”. End Turn doesn’t end their turns: they end once their turn takers have used their actions or ComputerTurnTime runs out, or when a script ends them. (Formerly ComputerSides.) (Names teams: their names, separated by commas.) (Field: a name.)
turnTime: a number = 0. Seconds a person’s turn lasts before it passes by itself, e.g. 30 for a timer as in Worms. 0 lasts until they end it. (Field: a number.)computerTurnTime: a number = 2. Seconds a computer team’s turn lasts at most: how long its patrols, chases and shooters get to act. 0 lasts until its turn takers have used their actions. (Only used when computerTeams is set.) (Field: a number.)between: a number = 0.5. Seconds between one turn and the next, while nobody acts: a last shot lands, a swing finishes. (Field: a number.)endAction: text = “EndTurn”. The input action that ends a person’s turn: “EndTurn” is Tab or the gamepad’s Back. Empty ends turns only with an End Turn button or a script. (Names an input action.) (Field: a name.)within: text = null. The part of the scene it runs the turns of, by an entity’s name: the turn takers inside that entity or standing in its area (a Room’s, a tilemap’s, a collider’s), e.g. “Arena”. Something that walks in joins the turns, and walks out of them as it leaves. Empty covers the whole scene (but what another turn order’s Within covers). (Names an entity.) (Field: an entity’s name.)defeatMessage: text = “{0}Defeated”. A message sent once a team that had turn takers has none left (beaten: its units all destroyed), with the team’s name as its data. {0} in it is the team’s name: “{0}Defeated” sends “RedDefeated”, for a Victory panel to open on. (Names a message.) (Field: a name.)
Messages
Section titled “Messages”format: text = “{0}\u0027s turn”. What its Text says: {0} is the team whose turn it is, {1} the round and {2} the seconds left of a timed turn, e.g. “{0}’s turn ({2})”. (Text with holes the game fills in: {0} the team whose turn it is, {1} the round, {2} the seconds left of a timed turn, each with a number format after a colon if it says, e.g. {0:000}. The Inspector has a button for each and shows how it reads now.) (Field: its own editor: Format.)message: text = “{0}Turn”. A message sent with Game.Send as each turn starts, with the team’s name as its data. {0} in it is the team’s name: “{0}Turn” sends “PlayerTurn”, then “EnemyTurn”. (Names a message.) (Field: a name.)sound: text = null. A sound played as each turn starts, e.g. “Sounds/turn.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
current: text = null. The team whose turn it is. Empty starts with the first team; set it to start with another, or from a script to hand the turn straight to a team (its turn starts afresh). (Names a team.) (Field: a name.)round: a whole number = 0. How many times the turns have come round, from 1. The game counts it; it’s 0 until the game starts. (Field: a number.)timeLeft: a number = 0. Seconds left of a timed turn. The game counts it down. (Field: a number.)startsIn: a number = 0. Seconds until the Current team’s turn starts, between turns. The game counts it down. (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”).
EndTurn. Ends the current turn at the start of the next frame, whoever’s it is (a script’s own End Turn, or a computer team whose script has finished its moves). Between turns it does nothing.
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.
Turn(a name). The team whose turn it is. Empty starts with the first team; set it to start with another, or from a script to hand the turn straight to a team (its turn starts afresh).Round(a whole number). How many times the turns have come round, from 1. The game counts it; it’s 0 until the game starts.TimeLeft(a number, out of its turnTime). Seconds left of a timed turn. The game counts it down.Left(a whole number, read by a team after a colon, e.g. “Left:Enemy”). How many turn takers team has left in the scene, e.g. “Enemy”: units left in tactics, monsters left in a roguelike. Read as “Left:Enemy”.
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.
teamList: lines of text: an array of strings, or one string with line breaks. The teams in order, from Teams.sideList: lines of text: an array of strings, or one string with line breaks. What TeamList was called before every genre’s teams were one idea. Kept for scripts.isBetweenTurns: true or false. True between turns, while nobody acts.sides: text. What Teams was called before every genre’s teams were one idea. Kept for scripts.
Scripts use it as TurnOrder: its methods, events and values that aren’t saved with the scene.