Skip to content
Docs

No-code rules

How to give your game logic by picking options in the editor 0.4.0, with the Match settings, the 10 triggers, the 23 actions, characters and rules in games made with code.

DescribesEditor 0.4.0 For creating without programming

On this page

A rule is a sentence: When something happens, then the game does something. You build them by picking from lists, in the Rules panel (Alt+6). You write no code: the editor writes it.

The panel has three sections: Match, Rules and Test bot. The third is explained in Test bot.

The Match at the top and the list of rules below.

The match#

At the top of the panel is Match, with what applies to the whole game.

SettingOptions
ClockNo clock, Countdown: you lose at zero or Stopwatch: measures how long you take.
Seconds per difficultyOnly with a countdown: one value for Easy, another for Normal and another for Hard.
Final scoreThe player's points (highest wins), The time taken (lowest wins) or Points plus the time left. It is what goes into the high-score table.
Show points on screenShows the points counter during the match.
Opening messageA text that appears at the start, in Spanish and in English.

Anatomy of a rule#

  1. Press New rule.
  2. Under When, pick the trigger and fill in its data.
  3. Under Then, pick the action and fill in its data.
  4. If you want more than one thing to happen, press + Action. Each following action starts with And. The arrow moves an action up in the order and the × removes it.

The rule is written out as a sentence you can read to check that it says what you wanted. A click on the sentence opens or closes the rule.

An open rule: the trigger at the top, its two actions and, at the foot, Only once per game.
PartWhat it is
The box to the left of the sentenceTurns the rule on or off. A rule that is off stays in the list but does nothing: it lets you test the game without it without having to delete it.
WhenThe trigger: what has to happen.
ThenThe actions, in order.
Only once per gameThe rule runs the first time it is met and does not run again until the next match. Use it for notices that should not repeat.
DeleteRemoves the rule.

When the trigger or the action asks for a piece or a zone, you can pick Everything tagged, One piece (or One zone) and, in actions, the touched piece. The Selected button takes what you have selected in the scene.

Texts are written twice, in Spanish and in English, because each player sees the game in their own language.

Triggers#

There are ten.

TriggerWhat it asks forExample
the player touches…A piece or a tag.When the player touches anything tagged "moneda": remove the touched piece, add 1 point and play the moneda sound.
the player enters the zone…A zone or a tag.When the player enters anything tagged "meta": end the game (win).
the player leaves the zone…A zone or a tag.Show a message when the player leaves the start zone.
the player collects…How many (all or a number) and with which tag.On collecting three pieces tagged "llave", open a door.
time passes…The seconds and whether it repeats.Every 10 seconds, add one point.
the player reaches… pointsThe number of points.When the player reaches 5 points: show "You got them all! Run to the goal." and play the victoria sound.
the player falls offNothing.When the player falls off the world: play the caida sound.
the player presses a button…Which button: Jump, Action or Action 2.On pressing Action, launch the player up.
a character touches the player…Which character, or any character.When the guard touches the player, respawn.
the game startsNothing.When the game starts: spawn the character "Guard" at "guardia" and make "guardia" patrol between 2 points.

The examples for "touches", "enters", "reaches", "falls off" and "the game starts" are real sentences from the editor. The rest are ideas for use.

Actions#

There are twenty-three.

ActionWhat it does and what it asks for
add pointsAdds the amount you say. A negative number takes points away.
show messageShows a text. It asks for the text in Spanish, in English and a style: Normal, Success (green) or Danger (red).
play soundPlays a sound from the list.
end gameEnds with Win, Lose or End (neither win nor lose).
respawnSends the player back to the last checkpoint.
move pieceMoves a piece in X, Y and Z over the seconds you say. With Back and forth, forever it does not stop.
open doorThe piece you pick rises until the way is clear.
remove pieceRemoves a piece from the scene. It can be the touched piece.
paint pieceChanges a piece's color. It can be the touched piece.
save checkpointFrom now on, the player respawns at the spawn point you pick.
teleport player to…Moves the player to a spawn point.
launch upwardLaunches the player up with the strength you say. 20 is a high jump.
take or give timeThe seconds lost from the clock. A negative number gives them.
spawn a characterCreates a character at a spawn point. It asks for a short name, where it spawns, a color and, if you want, the label with its name.
character: patrol between pointsThe character walks non-stop between the spawn points you tick, in order.
character: follow the playerThe character follows the player and stops at the distance you say.
character: remove itRemoves a character from the match.
camera shot: show a pieceThe camera shows a piece for a few seconds and then comes back by itself. It asks where the camera goes, counted from the piece.
put a label or bar over a pieceA text, a bar (health, progress) or both, over a piece. The label follows it.
remove label from a pieceRemoves that label.
floating text over the playerA short text that floats over the player, such as "+1".
change the sky (day, night)Changes the sky to day, sunset, night or ink, over the seconds you say.
switch the view (camera and controls)Switches to another view, with a transition.

The rules that prefabs bring#

Several prefabs add their rule when you place them, and the editor tells you: "A rule was added to make it work. See it under Rules." They are rules like any other: you can open them, change them or delete them.

On placingThe rule that appears
CoinWhen the player touches anything tagged "moneda": remove the touched piece, add 1 point and play the moneda sound.
Danger zoneWhen the player touches anything tagged "peligro": play the golpe sound and respawn at the last checkpoint.
GoalWhen the player enters anything tagged "meta": end the game (win).
CheckpointOn entering its zone, save the checkpoint.
TrampolineOn touching anything tagged "trampolin", launch the player up and play the salto sound.
Door with buttonOn touching the button, open the door and paint the button green.
Character, Patrolling character, Character that follows youOne "the game starts" rule for each character placed.
Sign with labelA "the game starts" rule that puts the label over the sign.

The coin, danger, goal and trampoline rules talk about a tag: they are added only once and apply to every piece that carries it. The second coin does not add another rule. If you make a box and give it the tag peligro, it also sends the player back to the last checkpoint.

Those of the characters and the signs are one per copy, because each one names its character or its sign.

Characters#

A character is someone else in the scene, besides the player: a neighbor, a guard, a friend who follows you. It always appears at a spawn point and is named by its short name.

The quickest way is to place one of the three prefabs in the Characters group. Each one puts its spawn points in the scene and its rule in the panel:

PrefabWhat it placesWhat its rule does
CharacterOne spawn point.Spawns it there, standing.
Patrolling characterTwo spawn points, guardia and ronda.Spawns it and makes it patrol between the two.
Character that follows youOne spawn point.Spawns it and makes it follow the player.
The rule of the Patrolling character, just placed.

To change the round, move the spawn points in the viewport like any piece, or add more with the Spawn point prefab and tick them in the character: patrol between points action. At least two are needed.

Switching the view#

The switch the view (camera and controls) action goes from one view to another in the middle of a match: third person, first person, isometric, top-down, side (2D) or flat (2D from above). The option the scene view (go back) returns to the original view. Transition seconds says how long the change takes.

It switches the camera and also the way of moving. If a player triggers the rule, only theirs changes; otherwise, everyone's.

To switch views when passing through a place you do not need a rule: a zone can carry its own view switch. That is in Kinds of game.

How rules become code#

Rules are not a separate system: the editor translates them into code, the same a person would write. The See the code these rules write link, at the end of the list, opens the script at the exact place.

The code goes in scripts/principal.ts, between two marks: // <reglas> and // </reglas>. Each rule appears with its sentence as a comment. This is the fragment for rules 3 and 4 of the tutorial's game. The example was made with the editor in Spanish, so the sentences are in Spanish:

ejemplos/patio-de-monedas/scripts/principal.ts
	// Regla 3: Cuando el jugador toca algo con la etiqueta "moneda": quitar la pieza tocada, sumar 1 punto y reproducir el sonido moneda.
	mundo.alTocar('#moneda', (pieza, jugador) => {
		pieza.eliminar();
		sumarPuntos(jugador, 1);
		sonido.tocar('moneda', { para: jugador });
	});

	// Regla 4: Cuando el jugador toca algo con la etiqueta "peligro": reproducir el sonido golpe y reaparecer en el último punto de control.
	mundo.alTocar('#peligro', (pieza, jugador) => {
		sonido.tocar('golpe', { para: jugador });
		jugador.reaparecer();
	});

And rule 5, "reaches 5 points", ended up inside the function that adds points:

ejemplos/patio-de-monedas/scripts/principal.ts
/** Suma (o quita) puntos y actualiza lo que se ve. */
function sumarPuntos(jugador: Jugador, cantidad: number): void {
	const antes = jugador.puntos;
	jugador.puntos = Math.max(0, jugador.puntos + cantidad);
	mostrarPuntos(jugador);
	// Cuando el jugador llega a 5 puntos: mostrar "¡Tienes todas! Corre a la meta." y reproducir el sonido victoria.
	if (antes < 5 && jugador.puntos >= 5) {
		interfaz.mensaje(interfaz.t('r_regla_5_1'), { tipo: 'info', para: jugador });
		sonido.tocar('victoria', { para: jugador });
	}
}

You do not need to understand this code to make games. But if you want to learn to program, reading what your own rules write is a good place to start.

Games made with code#

The Coins against the clock (with code) template and the First person, 2D platformer, Top-down, Isometric, Hybrid, Open world and Local multiplayer examples have their logic written by hand. In them the Rules panel starts empty and shows this notice:

"This game is made with hand-written code (Code tab). If you add rules, the editor writes them in a separate block inside the same file, without deleting what is there. Both work together."

Two things change in these games:

  • Prefabs do not add their rule without asking. Placing a Coin puts the piece with its moneda tag, but the editor does not add logic to a game made with code on its own. What it does is check whether your code names what you placed (its tag, its piece or its zone). If it does not, it tells you: "This game is made with code and its code does not use "Coin": it does nothing this way. You can add its rule or program it by hand." The Add its rule button, inside the notice, creates the rule and opens the Rules panel. If your code does name it, there is no notice.
  • The first rule turns Rules on. From that moment the editor writes its block in the script, the Match settings (clock, final score) take effect and prefabs bring their rule again, as in any other project.

The editor looks for the name in the code and nothing else: it does not know what you use it for. In the isometric example, for instance, placing a Coin does not show the notice, because its script already names moneda (it is the sound it plays). There you create the coin rule by hand, with New rule.

When Rules are turned on, the editor takes the existing code into account:

  • The score tables of your code are kept. The Match needs its own high-score table. The editor leaves the ones your code names as they are and adds its own at the end. Up to 0.2.0 it replaced them, and the isometric example was left with a GB323 error: that no longer happens.
  • The "No rule ends the game" notice does not appear if your code ends it. The editor also counts the ending set by the hand-written code (a call to juego.terminar), besides the rules with end game and the countdown clock.

Next#