Skip to main content
This guide builds a HUD that shows the line you are skating: its score in big digits drawn from a picture, its multiplier, a ring where the line started, and a badge that follows the skater. It needs the overlay, events.tricks and skater.read permissions. Every drawing function is listed on the overlay page.

1. The package

2. The draw handler

Everything a plugin draws, it draws in a draw handler. The handler gets a drawing object, d, and draws with its methods (d:text(...), d:rect(...)). It runs once a tick, and what it drew replaces what it drew the tick before: draw everything every time, and stop drawing a thing to make it go away.
The shape methods work only while the handler runs. Calling one anywhere else, or keeping d and drawing with it later, raises drawing is only inside a draw handler.
A plugin draws at most 4000 shapes and 64 KB of text a tick. Past that, the rest are left out, and a warning is logged at most once every 10 s, saying whether the shapes or the text ran out. See limits.

3. Read the line

reskate.score.current() (events.tricks) returns the score HUD as it is now: line (the line’s score), multiplier, in_trick, trick and detail (what the HUD names), and manual. It returns nil when there is no score HUD, in the menu or on foot. The trick events say when a line starts and ends. trick_started gives at, where it began; line_broken gives reason, "slam" or "wipeout". See events.

4. Screen shapes

Screen shapes take positions as vectors in pixels from the top left of the game’s window. The z of a screen position is ignored. d:size() returns the window’s size as a vector: x is its width and y its height. Put a dark panel at the bottom centre, sized from the window:

5. Styles

The last argument of every shape is a style table. Every field is optional. Sizes, thicknesses and rounding are given as they look on a 1080-line window, and scale with the window’s height. A size, thickness or rounding out of its range is clamped into it. Positions and a screen circle’s radius are plain pixels: scale them yourself, as with k above, when the layout should grow with the window. A wrong style raises an error: a colour that is not one of the three forms, a uv corner outside 0 to 1, or an align that is not one of the three. To fade something out, build the colour with its alpha:

6. Pictures and a font atlas

d:image(path, top_left, bottom_right, style) draws a PNG or JPG from your own package, stretched to the rectangle. The path is inside the package, with / between folders. A font atlas puts many glyphs in one picture, and uv picks one of them. hud/digits.png here is one row of ten glyphs, 0123456789, each the same width: the glyph for digit n runs from n / 10 to (n + 1) / 10 across.
Draw the glyphs white in the picture, and colour them with the style’s colour, which tints the picture.
A plugin draws at most 32 different pictures. Each must be a PNG or JPG of at most 512 x 512 pixels and 2 MB, or it is not drawn and the game’s log says why. Pictures load in the background, so a new one can take a few frames to appear. One atlas is one picture however many glyphs you draw from it.

7. World shapes

World shapes take positions in the world, in metres, and are drawn through the camera. Those behind the camera are left out. Mark where the line started, and join it to the skater:
reskate.skater.get() (skater.read) returns the local skater’s position, heading and more, or nil without a skater.

8. world_to_screen

d:world_to_screen(position) returns where a world position is on screen: a vector with x and y in pixels and z the distance in front of the camera. It returns nil for a position behind the camera. Use it to draw screen shapes that follow something in the world. Here a badge rides 2.2 m above the skater, shrinking with distance:
Keep z out of the result before you add it to screen positions, as at does here, so the arithmetic stays in pixels.

The whole plugin

Where to go next

  • Overlay: every drawing method, its arguments and errors.
  • Menu: your plugin’s page in the menu’s PLUGINS section, and full-screen screens, for settings rather than a HUD.
  • Skater: reskate.score.current() and the skater’s state.
  • Examples: ptest hud and ptest picture in reskate-test draw on screen and in the world. The hall-of-meat plugin draws a whole card with skate.’s own pictures (d:game_image), its fonts, d:gradient and the skater’s x-ray (d:skeleton).