Skip to content
FREN

Lap times

The last lap, the best one and its number, and the gap from one to the other, coloured by an Expression.

  • 12 min
  • no game needed
  • at the end: your first Expression

The two tiles under the delta carry the lap times. Start from your dash from chapter 3, or from its checkpoint.

Step 1 / 4

The last lap

The label: T, LAST, Exo 2, 12, Bold, letter spacing 0.7, #b9b9c2, X 22, Y 182.

The time: N, last_lap_time. Under Format, Time on m:ss.ccc; When empty -:--.--- and 0 counts as empty: before the first completed lap, the game sends 0. Exo 2, 34, Bold, italic, #f5f5f7, X 22, Y 197.

Step 2 / 4

The best lap and its number

The same block lower down, for best_lap_time, in purple #cdb2ff: label BEST at Y 268, time at Y 278.

Right of the label, the lap number: N, best_lap_num. Prefix LAP , When empty a single space, 0 counts as empty: nothing until it is known. Exo 2, 12, Bold, #b9a0ea, aligned right, the anchor at the top right, X 244, Y 268.

Step 3 / 4

The gap, in colour

The gap from the last lap to the best has to be worked out: a job for an Expression. First its text: T, +0.406, Exo 2, 16, Bold, italic, aligned right, the anchor at the top right, X 244, Y 182.

With the text selected, F frames its node in the graph. Hover the empty space on its left, Tab, Expression, Enter. In its editor, write:

ok = @last_lap_time > 0 && @best_lap_time > 0 ;
d = @last_lap_time - @best_lap_time ;
$gap = ok ? (d > 0 ? "+" : "") + timefmt(d, "s.ccc") : "" ;
$color = d > 0 ? rgba(255, 115, 99) : rgba(92, 240, 154)

Two sockets appear on the node’s right: gap and color. Drag gap to the text’s value, color to color. A slower lap shows in red, an equal or faster one in green.

Step 4 / 4

Put the block away in a group

Last label, then Shift+click Last gap, Ctrl+G, Lap times. The Expression goes into the group with the text it colours: it serves nothing else.

  • @last_lap_time reads a channel, like data placed with the Number tool.
  • ok and d are working names: they don’t leave the node.
  • What starts with $ comes out: each $name becomes a socket, to wire wherever you like.
  • a ? b : c chooses: b if a is true, c otherwise.
  • timefmt(d, "s.ccc") writes a time with three decimals, with its - when it is negative; (d > 0 ? "+" : "") adds the + of a slower lap, and + between two texts joins them.
  • rgba(…) makes a colour.
  • Each statement ends with ;, except the last.

Download first-dash-4.slxd: the dash at the end of this chapter.

The node has no gap socket. The program doesn’t read: a ; is missing at the end of a line, or a bracket. The editor underlines the error.

The wire won’t land on color. The output you dragged isn’t a colour: $color must end with an rgba(…).

Layer Tool Channel or text Format X Y Size Colour Alignment
Last label Text LAST 22 182 12, Bold #b9b9c2 left
Last lap Number last_lap_time m:ss.ccc, -:--.--- if 0 22 197 34, Bold, italic #f5f5f7 left
Best label Text BEST 22 268 12, Bold #b9b9c2 left
Best lap Number best_lap_time m:ss.ccc, -:--.--- if 0 22 278 34, Bold, italic #cdb2ff left
Best lap number Number best_lap_num LAP before, empty if 0 244 268 12, Bold #b9a0ea right
Last gap Text wired to the Expression 244 182 16, Bold, italic wired right

Labels with a letter spacing of 0.7; all in Exo 2, Vertical on line, top.