LiminaliaLiminalia
Technical docs: Writing scenarios: Sprites

Sprites

Open in Claude (new tab)
On this page
@chara Yuika normal at=left time=500ms
@chara Yuika smile time=300ms
@chara Yuika normal appearance=casual at=center flip=true
@chara Ren angry at=auto if-hidden=true
@chara Haru normal x=120 y=40
@chara-hide Yuika time=300ms

Sprites work the same way as the sprite plugin Tyrano Tatie (tatie). They’re defined in three levels in cast.json (chapter 10), and the scenario refers to them by name.

LevelParameterExample
CharacterUnnamed (the first)Yuika
Sprite set (outfit, era, condition and so on)appearance=casual
Variant (expression, pose). Has an image, and a position and size (frame)Unnamed (the second)smile

Showing and changing

  • @chara both shows and changes a sprite. If the character isn’t on screen, it fades in; if it is, the sprite changes.
  • if-hidden=true shows it only when it isn’t on screen (if it’s on screen, nothing happens; mode=show in tatie).

Automatic layout by order of appearance

To use automatic layout by order of appearance in the whole game, set "auto-layout": true in commandDefaults.chara in liminalia.json. A newly shown character without at is placed in the center when alone. Two are placed left and right in the order they appeared, three left, center and right, and more are lined up from the left in the order they appeared. Changing the expression doesn’t change the order. A character with an explicit at, x or y keeps that position. The older at=auto remains as a separate way of placing characters.

When the number of characters in the automatic layout changes, the characters on screen fade out, are rearranged, and fade back in. The time to hide them is auto-fade (default 300ms), and the time to show them is time. With wait=true, it waits until the rearranging is done.

The automatic layout is kept in saves. In a save made before the setting was turned on, characters already on screen are restored fixed in their original positions. They join the automatic layout only after they leave and are shown again without a position.

You can change how characters are lined up for each game with autoLayout in liminalia.json. Each character’s home side goes in side for that character in cast.json.

"autoLayout": {
  "positions": {
    "2": ["left", "center"],
    "4": ["15%", "38%", "62%", "85%"]
  },
  "enter": "start",
  "exit": "keep"
}
"Yuika": { "side": "left", "appearances": { … } }
ItemMeaning
positionsPositions for each number of characters. Use the number as the key and list the positions from the left. A position is a name from positions in the sprite frame, or a fraction of the screen width ("30%"; the center of the sprite goes there). Numbers you don’t write use the default layout above
enterWhere a newly arriving character goes. end is the right end (default), start the left end, middle the middle
exitWhat happens when someone leaves. reflow (default) lines up the remaining characters again. keep leaves the slot empty without moving anyone, and the next character to arrive takes that slot. A character who arrives when there’s no empty slot makes the row one longer, and everyone is lined up again
side (cast.json)The character’s home side. left keeps them at the left end of the row and right at the right end. Characters on the same side keep their order in the row. When taking an empty slot with keep, they take the one closest to that side
  • The order of the row is kept in saves, so loading brings back the same row.
  • replace= also accepts the position names written in positions.
  • The syntax check reports an error (bad-auto-layout) when the number of positions doesn’t match the number of characters in positions, when enter or exit has an unknown value, and when a position name isn’t in any sprite frame.
  • When a rule’s position name isn’t in that character’s sprite frame, it’s also reported at runtime (unknown-position; the sprite is shown at the center). This covers not only the character being shown but also the others who moved when the lineup changed.
  • Sprites placed by a position name (at=left and so on) can be remapped to another position by headcount with byCount. Key it by headcount and map each written position name to the position to use. The remap applies only while exactly that many sprites are on screen; when the headcount changes, the sprites move to their new positions the same way as any position change. Sprites whose frame lacks the target position, sprites with x, and auto-layout characters aren’t remapped.
"autoLayout": { "byCount": { "3": { "left": "left-wide", "right": "right-wide" } } }
  • The syntax check also reports an error (bad-auto-layout) when a byCount key isn’t a headcount, when a name is empty, or when a target position isn’t in any sprite frame. The same goes for a written name (the name you write in at=) that isn’t in any sprite frame (you can’t write it in at=, so the mapping never applies).
  • The syntax check reports an error (bad-cast) when side in cast.json is anything but left or right (it would be ignored, and the character placed in order of entrance).
  • replace= accepts the remapped position name from byCount (the name shown in Studio’s scene info) as well as the written one.
  • During development, changes to autoLayout or side take effect without reloading the game. Sprites on screen move to their positions under the new rules. Studio’s scene information and VS Code’s “Play from here” use the same rules.

Replacing a character

@chara Mayu oops replace=Tsuzuri time=500ms hides Tsuzuri and shows Mayu, taking over Tsuzuri’s position and place in the order of appearance. The other characters stay on screen without moving. replace=left, center or right replaces the character at that position. A name in the sprite frame’s positions, a name written in autoLayout’s positions, and the name after byCount remaps it also work (choose a character placed with x or y by name). left, center, right and the names in autoLayout’s positions are treated as positions even if a character has the same name. For other position names, a character with the same name comes first.

When there’s no one to replace, when there’s more than one character at that position, or when the character to show is already on screen, an error is reported at run time and nothing changes. Don’t use replace together with at, x, y, clear or solo. time is both the time to hide the character leaving and the time to show the character coming in.

Entering and leaving, sliding to a new position, one character at a time, stacking order

@chara Yuika smile time=500ms enter=left
@chara Yuika at=right time=600ms slide=true
@chara Ren time=300ms solo=true
@chara Yuika at=left clear=300ms time=500ms
@chara Haru z=2
@chara-hide Yuika time=400ms exit=bottom
ParameterMeaning
enter (@chara), exit (@chara-hide @chara-hide-all)How it appears and leaves. fade (default; in place), left right top bottom (slides in from that side or out to that side, by distance px; default 160), zoom (from a small size, or to a small size). The time is time. enter only applies when the character wasn’t on screen
slide=trueWhen the position of a character on screen changes, slide it over the time time instead of hiding and showing it again (if the image changes too, it cross-fades while sliding)
solo=trueHide the other characters’ sprites over the time time before showing. In a game that always shows one character at a time, write "solo": "true" under chara in commandDefaults
clear=300msHide everyone, including the character themselves, over the given time, and show the new sprite. It works like @chara-hide-all time=300ms followed right away by @chara in one line, and doesn’t wait for the hiding to finish. The time to show is set separately with time
zStacking order. Higher values are in front; with equal values, the one shown later is in front (default 0). If not written, a character on screen keeps its current order
  • Only z is kept in the state (how a sprite enters, leaves or slides isn’t).
  • lim backport writes solo=true back as two lines, @chara-hide-all (with the same time) and @chara (in .ks, the character also disappears once and reappears).
  • clear is also written back as two lines, @chara-hide-all with the written time, and @chara. enter exit slide z aren’t in TyranoScript’s sprite tags, so they’re reported as things it can’t write back.

What you don’t write is decided as follows.

Variant, sprite set and flip not writtenPosition not written (none of at x y)
Character on screenStays as isStays as is. If you write any of them, it’s placed again by what you wrote
Character not on screenBase variant, default sprite set, not flippedcenter

To change only the expression, @chara Yuika smile is enough.

When a sprite on screen is replaced, it changes as follows, depending on what differs from before.

ImagePosition and size (frame)How it changes
SameSameAt once (only the flip changes)
SameDifferentDisappears in half of time, changes position and size, and appears in the rest
DifferentSameCross-fades only the image. With cross=false, the new image is shown fully before the old one is removed
DifferentDifferentCross-fades the whole sprite

If the next @chara comes in the middle of a change, the change in progress jumps to its end state before the next one starts.

Reducing flicker

Hiding a sprite and showing it again every time the speaker changes makes the screen flicker, and only one of the characters in the scene is ever standing. Keep the characters in the scene standing, change only their expressions with @chara name variant, and show who is speaking with speaker focus.

"ui": { "chara": { "focus": "dim-lower", "dim": 0.7, "lower": 10 } }
MechanismHow to write itWhat it does
Speaker focusui.chara in liminalia.json, @chara-config in the scriptTones down the sprites of characters who aren’t speaking. focus is dim (darker), lower (a little lower), dim-lower (darker and lower), blur (blurred), dim-blur (darker and blurred) or none (unchanged; the default). The strengths are dim (brightness 0 to 1; default 0.6) and lower (px; default 12)
Replacing at the same positionswap of @charaWhen another character’s sprite at the destination position is still disappearing, after (the default) shows the new one once it has disappeared. When a character already on screen moves there with at=, it leaves its old position right away and appears at the destination once the other has disappeared (with slide=true, it slides once the other has disappeared). cross shows the two overlapping, as in the earlier version
The name box while waiting for a character to appearwait=true of @chara, ui.chara.keepTextWhile waiting for a character who isn’t on screen yet to appear, the name box and text are cleared if the speaker of the previous page isn’t that character. With keepText set to true, they aren’t cleared. Since 0.4.1, though, the name and text are also cleared at the first command after a page turn (ui.message.keepText in player.md), so to keep them as in earlier versions, set ui.message.keepText to true too
  • Speaker focus works automatically by tying the speaker in the name box to a character (the character whose ID or speaker in cast.json matches the speaker). During narration, and when the speaker’s sprite isn’t on screen, no one is changed. Even if the display name is changed ({name …}, @name), the speaker is what counts.
  • Items written with @chara-config take priority over the game settings (@chara-config focus=none turns it off from that point). They’re kept in the state, so loading gives the same.
  • To make replacing behave as in the earlier version for the whole game, write "swap": "cross" under chara in commandDefaults.
  • The name box and text aren’t cleared while waiting for a character to appear after narration or after that character’s own dialogue. They aren’t cleared on the NVL or chat screens either.
  • The syntax check warns about showing a character again right after hiding them (chara-reshow) and about hiding everyone for every line of dialogue (chara-hide-per-line) (chapter 9). Where one character is shown on the line right after hiding everyone, it adds a suggested fix (info, chara-solo) that makes them one line with solo=true, and lim check --fix chara-solo fixes them all across the project at once.

How the sprite set and variant are decided

  • Sprite set: the first one that exists, in this order: the one written → the character’s defaultAppearance → default → the first one.
  • Base variant (the variant used when only a sprite set is written): the sprite set’s defaultVariant → normal → default → the first one.

If none of these exist, the choice falls to the order they’re listed in, so the syntax check warns (cast-ambiguous). It applies to:

  • Sprite sets without defaultVariant that have neither normal nor default
  • Characters whose default sprite set can’t be decided
  • Variants whose frame has no left center right

Position

How to write itPlacement
at=nameA position in positions of the variant’s frame. A variant with a frame always has left center right. At run time, an unknown name is shown at center (like tatie), but the syntax check treats it as an error
at=autoAutomatic placement. auto sprites are lined up side by side (see below)
x= y=Top-left coordinates (px). An axis you write takes priority over at (at=auto y=40 places it automatically only horizontally). When you write both x and y, don’t write at (it’s an error)

Automatic placement (the same as TyranoScript’s pos_mode):

  • The later a sprite is shown, the further left it’s placed.
  • Their centers are placed at points that divide the screen width into (count + 1) equal parts, and their bottom edges are aligned with the bottom of the screen.
  • Each time a sprite is shown or hidden, the remaining auto sprites slide to line up again.

Layered sprites

For layered sprites (layers in chapter 10), you can add layer pictures to a variant by joining them with +.

@chara Yuika smile+blush
@chara Yuika +closed
  • The first adds the cheek layer’s blush on top of the variant smile. If you omit the variant as in the second, it’s added to the base variant.
  • What follows + can be the name of a picture in any layer. If you write two pictures from the same layer, the later one wins.
  • An unknown name is a syntax check error, just like an unknown variant.

Color tone, depth, depth of field

Color tone

  • @tone night time=1s: changes the color tone of all sprites (including ones shown later).
  • @tone sepia who=Yuika: changes only that character.
  • @tone none: resets it (if the background has a color tone, back to the background’s tone).
  • The built-in tones are sepia mono night evening dark, and plain, which doesn’t change the color. You can add or replace them with ui.tones in liminalia.json.
  • Backgrounds can have a color tone too. Set it with @bg room_night.jpg tone=night or with ui.backgroundTones in liminalia.json (background file name → tone name), and while that background is shown, its tone is applied to the sprites (even without writing @tone, sprites don’t stand out against a dark room or an evening background). When @bg changes the background, the sprites’ tone changes with the same time as the background, and changing to a background without a tone removes it. tone= of @scene-change works the same way.
  • The tone applied to a sprite is decided in this order: the per-character one from @tone, the one for all sprites from @tone, then the background’s tone. For a character who shouldn’t get the background’s tone, write @tone plain who=…. tone=none in @bg doesn’t apply a tone at that point, even for a background listed in ui.backgroundTones.

Backgrounds with depth (@plane)

  • @plane name image depth=0.9 layers a bgimage picture over the background.
  • When you move @camera, it moves less according to its depth (0 to 1). 0 moves with the sprites, and values closer to 1 move less. Negative values are in front and move more.
  • front=true places it in front of the sprites. Farther planes are layered further back.
  • While the camera is moving, it also moves with the same time and easing as the camera. At every point along the way, it moves less according to its depth.
  • @plane-hide or @bg removes it.

Depth of field (@dof)

How to write itIn focusBlurred
@dof spritesSpritesBackground and foreground images
@dof backgroundBackgroundSprites and foreground images
@dof who=YuikaThat characterBackground and foreground images. Other sprites at half strength
@dof noneResets it

You can write blur= (px; default 6) and time=. It doesn’t replace a filter from @filter; both apply.

Face window

The expression in the face window (ui.face in liminalia.json) is decided in this order.

  1. If that character’s sprite is on screen, the sprite’s variant
  2. If not, the one set with @face Yuika smile (you can also write appearance=)
  3. When the sprite is hidden, the variant from before it was hidden carries over
  4. If there is none of these, the base variant

State and loading

  • Only the variant, sprite set, at, x / y, flip and stacking order (z) are kept in the state. The actual coordinates and size are calculated each time by the drawing side, from the state of the sprites on screen and the character definitions. Loading gives the same screen.

What the syntax check can and can’t find

  • If a character, sprite set, variant or position isn’t in cast.json, it’s an error with candidates of similar spelling (unknown-cast unknown-appearance unknown-variant unknown-position).
  • Combinations that come from keeping values you didn’t write (changing only the outfit when that outfit doesn’t have the current expression, and so on) can’t be found by the syntax check. They’re checked on every @chara at run time and become runtime diagnostics (you can find them with lim coverage and on Studio’s Check screen).