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.
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.
vector
required
Pixels from the window’s top left.
string
required
At most 500 characters.
table
colour, size, align, shadow, font.d:rect(top_left, bottom_right, style)
A rectangle, outlined or filled.
vector
required
One corner, in pixels.
vector
required
The opposite corner, in pixels.
table
colour, fill, thickness, rounding.d:line(from, to, style)
A straight line.
vector
required
Pixels.
vector
required
Pixels.
table
colour, thickness.d:circle(centre, radius, style)
A circle, outlined or filled.
vector
required
Pixels.
number
required
0 or more, in pixels of the window (it does not scale with the window’s height).
table
colour, fill, thickness.d:poly(points, style)
A closed polygon through 3 to 64 points. A filled polygon must be convex to fill as you expect.
table
required
A list of 3 to 64 vectors, in pixels.
table
colour, fill, thickness.d:gradient(top_left, bottom_right, colours)
A filled rectangle that shades between the colours of its four corners.
vector
required
One corner, in pixels.
vector
required
The opposite corner, in pixels.
table
required
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.
string
required
vector
required
Pixels.
vector
required
Pixels.
table
colour tints it (white draws it as it is), rounding rounds its corners, uv picks part of it.d:game_image(name, top_left, bottom_right, style)
One of skate.’s own pictures, by name: its scoring icons, the THRASHER wordmark, and the brush strokes and tiles its menus are built from. ReSkate reads them from the installed game, so your package ships none of them.
string
required
One of the 13 names below. Any other name raises an error that lists them.
vector
required
Pixels.
vector
required
Pixels.
table
colour tints it: the pictures are white or grey, so the colour you give is the colour they show. fit and edge (below) say how it goes onto the box. 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.
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.
vector
required
World metres.
string
required
At most 500 characters.
table
colour, size, align, shadow, font.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.
vector
required
World metres.
vector
required
World metres.
table
colour, thickness.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.
vector
required
World metres.
number
required
0 or more, in metres.
table
colour, fill, thickness.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.
string
required
A
.png or .jpg file in your package.vector
required
Its centre, in world metres.
number
required
More than 0 and at most 1000 metres.
table
colour tints it, uv picks part of it.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.
table
required
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.number
default:"1"
0 to 1: fades the whole skeleton.
alpha out of range raises an error. The skeleton counts as one shape.
Measuring
d:size()
The game window’s size.
vector
x its width and y its height, in pixels; z is 0.d:world_to_screen(position)
Where a place in the world is on the screen now.
vector
required
World metres.
vector or nil
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.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 13, a gradient without four colours.Toasts
reskate.ui.toast(message, level)
Shows a short notice in ReSkate’s notices, top left, titled with your plugin’s folder name.
string
required
At most 200 characters.
string
default:"\"info\""
"info", "warn" or "error".boolean
true when it is shown; false when the plugin showed 3 toasts in the last 5 seconds.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.