reskate.animation plays clips on the local skater’s body. A clip is an Animation Studio clip file in your plugin’s package or its data folder, one of the game’s own animations, a recording the plugin made with record, or one it made from another with trim or edit. Every function needs the skater.animation permission; calling one without it raises an error. See permissions.
How clips play
- A clip replaces the skater’s body, from the hips down every joint below them, blended in and out. The joints the game moves the skater with are never written: a clip plays in place, wherever the skater is.
- The board follows a clip only when the clip has one. Its trucks and wheels stay on the deck as they were when the clip took the board.
- One plugin plays a clip at a time.
- Nothing plays while a throwdown or a game of S.K.A.T.E. runs:
playis refused, and trick replacements wait until it ends. - When the plugin stops, its clip stops and its replacements go.
Naming a clip
Every function that takes a clip takes its name:- A path in your plugin’s package, such as
"clips/spin.fas"(with/between folders, no..). The file is read once, the first time you name it, and kept under that name.preloadreads it ahead instead. "data:"and a path in your plugin’s data folder, such as"data:anims/kick.fas", for a clipsavewrote there. It needs thefilespermission too. It is read once and kept, like a package file:forgetit to read it again after saving over it."game:"and the name of one of the game’s own animations, such as"game:animation/dingo/c_proto_onb_trick_o_kickflip_high", asgame_clips(below) lists them. It is read out of the game’s data once and kept, like a package file."rec:1","rec:2"… for a recording, asrecorded()named it."clip:<n>"for a cliptrimoreditmade, and"edit:<name>"for oneeditmade under a name.
rec:, clip: or edit: name the plugin does not hold, and a game: name that is not a clip the game’s skater can play (or while the game’s animations are still being read).
A plugin’s clips hold at most 48 MB of poses together, counted as 40 bytes a joint a frame. A clip file is at most 8 MB. Each
record needs room for 10 seconds of poses (about 9.5 MB) before it starts. forget gives a clip’s room back.reskate.animation.play(clip, options)
Plays a clip on the skater’s body from now.
The clip’s name (a package path,
"data:<path>", "game:<name>" or "rec:<n>"), at most 200 characters.Why not:
"not while a throwdown runs", "<plugin> is playing a clip" or "asked more than 4 times in a second".Needs the
skater.animation permission. Shares the budget of 4 control calls a second with skater.noclip, boost, freeze, camera.follow, ai.spawn, board.toss and outfit.set.reskate.animation.stop()
Stops this plugin’s clip; the game’s own animation takes over again. Stopping when the plugin plays nothing does nothing.
Returns nothing.
Needs the
skater.animation permission.reskate.animation.playing()
Whether this plugin’s clip is still playing.
Needs the
skater.animation permission.reskate.animation.seek(seconds)
Moves your playing clip to a time: held there when it is paused, playing on from there when not. It has no rate limit, so a timeline can call it as it is dragged.
Returns nothing. Without a clip of yours playing, it does nothing.
Needs the
skater.animation permission. A negative or non-finite number raises an error.reskate.animation.pause(on)
Holds your playing clip where it is, or lets it play on from there.
Returns nothing. Without a clip of yours playing, it does nothing.
Needs the
skater.animation permission.reskate.animation.time()
Where in its clip your playing clip is.
Seconds into the clip (within it, for a clip that loops).
nil when no clip of yours is playing.Needs the
skater.animation permission.reskate.animation.replace(trick, clip, options)
Makes one of the game’s own tricks play as your clip. When the game does that trick, the clip plays from the trick’s takeoff, its air (from the clip’s takeoff to its landing) stretched to the trick’s. Pass nil as the clip to give the trick back.
The game’s name for the trick, such as
"kickflip" or "ollie", at most 48 characters: letters, digits, space, _ and -, any case. reskate.animation.trick() tells you the names.Needs the
skater.animation permission. A plugin replaces at most 32 tricks (each trick and pop counts once). A trick and pop replaced by one plugin is refused to the others. Replacements are taken while a throwdown runs but do not play until it ends.reskate.animation.record(seconds)
Records the skater’s pose for so many seconds, from now. Ask recorded() for the clip once it is done.
Why not:
"its clips hold too much already (each recording can be 10 s of poses)", "<plugin> is recording" or "a recording is going on".Needs the
skater.animation permission. One recording runs at a time, across all plugins.reskate.animation.recorded()
The plugin’s last recording, once it is done, as a clip’s name to pass to play or replace. Each recording is handed back once.
Needs the
skater.animation permission. A recording holds memory until you forget it.reskate.animation.forget(clip)
Lets a clip go, and the memory its poses held. A clip still playing (or set as a replacement) plays on. Naming the file again reads it again.
Returns nothing.
Needs the
skater.animation permission.reskate.animation.game_clips(containing)
The names of the game’s own animations, to play as "game:<name>". They are read out of the game’s data the first time any plugin asks, which takes about a quarter of a second.
The ones a plugin can play are the skater’s clips: an animation on the skater’s rig, stored the way the game stores its trick animations. Its trick clips are animation/dingo/c_proto_onb_trick_<trick>_<pop>. <trick> is o_ and the trick (o_kickflip, o_popshuv_bs, o_360flip), or n_ for a nollie one (n_kickflip). <pop> is low, mid or high. Not every name is a clip: naming one that is not (a sequence or a blend, such as the seq_ ones) raises an error that says what it is.
The names, lower case, at most 2000.
nil while the game’s animations are still being read: ask again a moment later.Why there are none yet:
"the game's animations are still being read", or "the game's animations cannot be read: " and the reason.floor to see it as the trick looks, the board under the feet on the ground. Its takeoff and landing are found from the board’s height: the pop is the board’s first low point, and the landing its deepest one between a quarter and about 0.85 seconds later.
Needs the
skater.animation permission. A containing longer than 64 characters raises an error. Each game clip counts towards your plugin’s 48 MB of poses, about 1.9 MB for a two-second trick.Preloading a clip
A clip file in your package is read and decoded the first time you name it, inside that call. On a hard disk, that first read of a big clip in a tick can take long enough to be warned about, or even stopped (see limits).preload reads it ahead on a thread of its own, so play, sample, info and the others find it held instead of reading it.
reskate.animation.preload(path, fn)
Starts reading and decoding a clip file in your package, off the game’s thread.
The clip’s path in your package, such as
"clips/dance.fas", at most 200 characters. Only a package file can be preloaded.Called as
fn(ok, why) in a later tick, once the clip is held or cannot be: ok is true when it is held, and otherwise why says why not. Leave it out when you need no answer.fncomes at the start of a tick, before its timers and tick handlers.- A clip your plugin holds already is not read again.
fnstill comes, in the next tick. - A path being read already is read once. Each call’s
fncomes when it is done. - When the clip is handed over, it counts towards your plugin’s 48 MB of poses. Past them,
fngetsfalseand"a plugin's clips hold at most 48 MB of poses". - A file that cannot be read gets
falseand"it cannot be read: "and the reason, such asnot foundoris larger than 8 MB. One that is not a clip gets"it "and what is wrong with it, such as"it has more joints than the skater". - If your plugin stops or unloads first, the read is dropped and
fnnever comes.
Needs the
skater.animation permission. At most 8 preloads wait at once, clips and sounds together; past that it returns false and why. A "game:", "data:", "rec:", "clip:" or "edit:" name raises <path>: only a file in the plugin's own package is preloaded, and so do a path longer than 200 characters or outside your package, and an fn that is not a function.Working on clips
These read clips and make new ones from them, for a plugin that edits animations. Each clip they make counts towards your plugin’s 48 MB of poses:forget the ones you are done with.
reskate.animation.info(clip)
Needs the
skater.animation permission.reskate.animation.mirror(clip)
The clip for the other stance, as a new clip. The game’s trick clips stand goofy, and the game mirrors them for a regular skater: play one unmirrored on a regular skater and his body faces the other side of the board, half a turn round from how he rides.
Left and right trade places (every joint named Left... with its Right... twin), reflected across the upright plane along the board from its back truck to its front one, so the board keeps its nose ahead. Each joint keeps its own axes: how far it is from the skeleton’s rest pose is mirrored onto its twin’s rest. The board is mirrored as itself: it keeps its nose ahead, a board rolling one way rolls the other, and its trucks and wheels go with it. The placement joint’s turn and travel since the first frame go the other way round. Its takeoff and landing stay.
When
nil: "the game's animations are still being read" (the mirror reads the skeleton with them), "the clip has no board to mirror it along", or "only a clip of the skater's 395 joints can be mirrored".Needs the
skater.animation permission. The new clip counts towards your plugin’s 48 MB of poses.reskate.animation.sample(clip, joint, seconds)
A clip’s joints at a time, blended between the frames around it. Pass one joint for one joint, or a list of joints to read them all from one sampling of the clip.
A joint, as
reskate.skater.joint takes one (0 to 394, or a name), or "board". Or a list of them, such as {0, 1, "Head", "board"}.For one joint:
{position, rotation, scale} in the joint’s parent’s frame (the board’s: relative to joint 1, the skater’s placement). nil for a joint the clip does not hold, or "board" in a clip without the board. For a list: a table keyed by each joint exactly as you gave it (a number stays a number, a name stays a name), each value {position, rotation, scale}. A joint the clip does not hold is left out."board"), so use it when you want more than a joint or two.
Needs the
skater.animation permission. A joint that is not one of those (in the list too), or a time that is not a finite number, raises an error.reskate.animation.joints()
The joints an animation editor offers, in the order Animation Studio lists them: the board, the hips, the back and chest, the neck and head, the arms and hands, the legs and feet, then three more of the back and neck.
A list of 25 tables:
joint (its number, or "board"), label (such as "Hips") and moves (true for the board and the hips, which take an offset as well as a turn).Needs the
skater.animation permission.reskate.animation.trim(clip, from, to)
A new clip of the frames between two times, starting at 0. Its takeoff and landing move with it, and one outside it is dropped.
Needs the
skater.animation permission. A to not later than from, or a span with fewer than two frames, raises an error.reskate.animation.edit(clip, tracks, options)
A new clip: clip with keyframed edits on its joints. Each key turns a joint in its own frame and moves it in its parent’s, on top of what the clip has, and the edit is eased from each key into the next. The keys are baked into every frame, so the new clip plays, replaces a trick and saves like any other.
Needs the
skater.animation permission. At most 128 tracks and 4096 keys. A joint with two tracks, 0 or 1 as a joint, a key without a time, an ease that is not one of the three, an offset over 10 m, or a name with other characters raises an error.reskate.animation.save(clip, path)
Writes a clip to your plugin’s data folder as a clip file (FAS3), to name later as "data:<path>". It writes over a file there.
A path in the data folder, as
reskate.files.write takes one. The folders it names are made.Why not:
"a clip file is at most 8 MB", "the data folder holds 1000 files already", or why the file could not be written.Needs the
skater.animation and files permissions. A clip file is at most 8 MB; the data folder’s other files stay at most 1 MB.reskate.animation.trick()
The game’s name for the trick the skater is doing now. Use it to find the names replace takes.
Needs the
skater.animation permission.The clip file format
Clip files are what Animation Studio writes. Three versions read, each named by the file’s first four bytes:FAS1 (no board), FAS2 (with the board) and FAS3 (with or without the board, joints that never move stored once). All numbers are little-endian; a float is 4 bytes.
Every version starts the same way:
Then
FAS1 and FAS2 hold:
And
FAS3 holds:
A joint is 40 bytes: its scale (3 floats), its rotation as a quaternion
x, y, z, w (4 floats) and its position (3 floats), in its parent’s frame. Joints are numbered as the skater’s animation skeleton numbers them (the hips are 7, the spine 42, the head 103); joint 1 carries the skater’s placement in the world, and a clip never writes it. The board, when there is one, is the board’s mount relative to joint 1.
A file of the wrong size, with times out of order, or with any number that is not finite is refused (an error).