draw handler, and shows short notices with reskate.ui.toast. Both need the overlay permission.
What plugins draw sits under ReSkate’s own menus and chat, takes no input, and shows only on this player’s screen. A plugin’s server copy draws nothing.
The draw handler
draw handlers once a game tick with a drawing object, d, and keeps what they drew until the next tick; the overlay shows the latest drawing every frame. Draw everything you want shown each time: nothing carries over from one call to the next.
d’s functions are called with a colon (d:text(...)). The shape functions work only while a draw handler runs: calling one at any other time (from a timer, with a d you kept) raises an error.
Flashing
Fast flashing over a large part of the screen can bring on seizures, so the overlay holds back how fast a plugin’s drawing can brighten the screen. It adds up the light of each filled shape (rectangles, pictures, gradients, tiles and filled polygons): its colour’s brightness times its opacity, times the share of the screen it covers. That total may rise by at most 1.5 of a whole white screen a second, and fall as fast as you like. When your drawing would be brighter than that, its filled shapes are drawn more transparent until it catches up. So a full-screen white flash shown eight times a second comes out at about a tenth of its strength, and a bright full-screen picture fades in over about two thirds of a second. A HUD, text and shapes over a small part of the screen are never held back. While a plugin’s drawing covers most of the screen, the game names the plugin in the bottom corner and says that Ctrl+Shift+End switches plugins off.Coordinates
- Screen shapes take positions as vectors in pixels of the game window, from its top left:
vector.create(x, y, 0)(thezis ignored).d:size()gives the window’s width and height. - World shapes (
world_*) take positions in world metres. They are projected through the game’s camera as each frame is drawn, and a shape behind the camera is left out. Their sizes on screen (text size, line thickness) stay the same whatever the distance, exceptworld_circle’s radius andworld_image’s height, which are in metres. - Sizes in the style (text
size,thickness,rounding) are pixels at 1080 lines: they scale with the window’s height, so asizeof 18 is 18 pixels at 1080p and 36 at 2160p.
The style table
Most functions take a last, optional style table. Every field is optional.
A
size, thickness or rounding out of its range is brought into it. A colour in another form, an align or font that is not one of its names, a uv corner outside 0 to 1, or a number that is not finite raises an error.
Screen shapes
d:text(position, text, style)
Text at a point. The point is its top left, top centre or top right, as align says.
d:rect(top_left, bottom_right, style)
A rectangle, outlined or filled.
d:line(from, to, style)
A straight line.
d:circle(centre, radius, style)
A circle, outlined or filled.
d:poly(points, style)
A closed polygon through 3 to 64 points. A filled polygon must be convex to fill as you expect.
d:gradient(top_left, bottom_right, colours)
A filled rectangle that shades between the colours of its four corners.
A list of four colours, each in a form the style’s
colour takes: the top left’s, the top right’s, the bottom right’s and the bottom left’s.d:image(path, top_left, bottom_right, style)
A picture from your package, stretched to the rectangle.
d:game_image(name, top_left, bottom_right, style)
One of skate.’s own pictures, by name: its scoring icons, the THRASHER wordmark, the brush strokes and tiles its menus are built from, and its customization menu’s category icons. ReSkate reads them from the installed game, so your package ships none of them.
colour tints it: the pictures are white or grey, so the colour you give is the colour they show (loading_board keeps its own colours, and colour fades it). fit and edge (below) say how it goes onto the box; frame picks a flipbook’s picture. rounding and uv do nothing here.edge is 0 to 400, in pixels at 1080 lines (default 0). A fit that is not one of the three raises an error.
frame is for loading_board only, a flipbook of 27 pictures shown at 30 a second: a whole number from 0 to 26 (default 0), fitted into the box. A frame on another picture, or out of range, raises an error.
The scoring icons and the stopwatch are about 64 pixels in the game, so they look best drawn small; the others are larger.
World shapes
d:world_text(position, text, style)
Text at a place in the world.
d:world_line(from, to, style)
A line between two places in the world. It is left out when either end is behind the camera.
d:world_circle(centre, radius, style)
A circle around a place in the world, with a radius of radius metres at that distance: it grows as the camera comes closer. It always faces the camera: it is a ring on the screen, not one lying on the ground.
d:world_image(path, position, height, style)
A picture standing at a place in the world, centred on it, height metres tall; its width follows the picture’s shape.
The skater’s x-ray
d:skeleton(paint, alpha)
The local skater’s skeleton, seen through the skater: skate.’s own skeleton, posed as the game last drew the skater, from the camera of that picture. Each body part you paint shows in its colour, shaded by the way it faces the camera; the parts you leave out are not drawn. Call reskate.skater.xray(true) first: without it, before its skeleton is read, or without a skater, nothing is drawn.
Colours by body part, such as
{Head = "#ff4040"}. The names are those of the body_hit event, plus Left toes, Left foot, Right toes and Right foot. An empty table draws nothing.alpha out of range raises an error. The skeleton counts as one shape.
skate.’s drawn details
The touches skate.’s menus are drawn with, as the ReSkate menus draw them: no picture files.d:rough_rect(top_left, bottom_right, style)
A filled tile with skate.’s slightly rough, hand-cut edges.
colour; seed, a whole number from 0 that picks its edge (the same seed, the same edge, so it does not shimmer; default 1); and scale, how rough, 0.1 to 10 (default 1, at 1080 lines).d:halftone(top_left, columns, rows, style)
A screen-print of small dots, 7 pixels apart, every other row offset: the spray skate. puts in a tile’s corner.
d:scribble(top_left, bottom_right, style)
The dry-brush scribble skate. draws over a tile: three dark strokes across the box.
d:clip(top_left, bottom_right)
What the handler draws after it shows only inside the box, as in a list that scrolls. d:clip() with nothing ends the last one; clips nest, up to 16, and every one still open ends with the frame.
Measuring
d:measure(text, style)
How wide and tall a text is drawn, for laying out boxes and columns.
x its width and y its height, in the window’s pixels (the size scaled to the window, as it is drawn); z is 0. A wrapped text is as tall as its lines.Before the overlay has drawn its first frame its fonts are not known, and the size is a guess.
d:size()
The game window’s size.
d:world_to_screen(position)
Where a place in the world is on the screen now.
x and y in pixels from the window’s top left, and z its depth in front of the camera; nil when it is behind the camera, or so close to it and so far to the side that it lands more than a million pixels out, where the drawing functions would refuse it. Whatever comes back can be drawn.Limits
Needs
overlay, for the draw event and every d function. In one tick a plugin draws at most 4000 shapes and 64 KB of text; the rest are left out, and a warning is logged at most once every 10 s, saying which of the two limits was hit. A plugin draws at most 32 different pictures from its package in all its life (each path counts once; the game’s own pictures do not count); the next raises an error. A wrong argument raises an error: a position that is not a vector, text over 500 characters, a negative radius, a polygon of fewer than 3 or more than 64 points, a picture that is not a .png or .jpg file in the package, a game picture’s name that is not one of the 14, a gradient without four colours, a halftone outside 1 to 64 dots each way, a seed that is not a whole number from 0.Screen look
A camcorder look over the game’s whole picture, for a filming mode: a fisheye adapter’s bend and its hood’s dark edge, 4:3 bars, the camcorder’s colour, standard-definition softness, interlaced fields, tape grain and its faults, an auto-iris, a hand that slaps the lens, and burnt-in text in the camcorder’s own blocky characters. It is drawn under everything the overlay draws, plugins’ shapes and ReSkate’s menus included, and shows only on this player’s screen.reskate.screen.look(look)
Needs the
overlay permission. A look lasts 300 ms: call it every tick to keep it on. One plugin’s look is on the screen at a time; nil from another plugin does nothing. A bend or age outside 0 to 1, a fov outside 5 to 170, a negative rolling, more than 5 lines of text, a line over 12 characters or with a character the camcorder cannot show raises an error. The colour grade and the grain are left out when the game draws in HDR, and the auto-iris in HDR10. On a system that cannot build the look, it is not drawn and the log says why, once; look still returns true. When the plugin stops, its look ends.reskate.screen.slap()
A hand slaps the lens: it reaches round from a lower corner, presses on the glass a moment and pulls away, about 0.6 s in all, from the other side every second time. The iris closes down as it covers the lens and opens too wide for a moment as it comes off.
Needs the
overlay permission.Toasts
reskate.ui.toast(message, level)
Shows a short notice in ReSkate’s notices, top left, titled with your plugin’s folder name.
Needs
overlay. At most 3 toasts in 5 seconds; past them it returns false. Raises an error for a message over 200 characters or another level.