Scan Behavior
This is the expected behavior of scanning tokens.
Default Behavior: readers.scan.mode='tap'
When readers.scan.mode='tap' (default setting) and a game is launched using a card:
- Removing the card from the reader won't close the game.
- Leaving the card on the reader will have no effect.
- Tapping another card to launch a game will start the new game without returning to the core menu.
- Tapping a card whose launch resolves to the game already running leaves that game uninterrupted. This applies to different cards, mappings, and scripts that resolve to the same target, not just repeated scans of one card.
- A repeated random or dynamic script still resolves normally; a different target launches, while the current target is a successful no-op.
- Tapping the card of a playlist that is already playing moves it on to the next item, wrapping after the last one, instead of starting the playlist again. A card naming a different playlist still starts that playlist at its first item, and a playlist that is paused picks up where it left off.
**playlist.goto:1goes back to the first item. A playlist is recognised by its ID, which is the path ordeck://URI it was named by; one written inline as JSON is recognised only when it carries anid, and starts again without one. - A card that has to rebuild the playlist rather than move through it — to change its repeat mode, or to pick up items added to it since it started — uses
**playlist.load:<playlist>||**playlist.play, which loads the playlist again every time and starts it at its first item. - A skipped launch does not run launch/exit hooks, reset playtime, clear the active playlist, or transfer hold ownership. Other commands on the card still execute.
- Scanning a utility card does not reset this protection. After the game stops, tapping its card launches it again.
- Tapping a command like
input.coinwill execute the command without interrupting the game. - Exiting the game manually through the internal menu will reset the state, allowing you to tap any card to launch a different game.
- Exiting the game manually while the card remains on the reader will not cause the game to relaunch once in the menu.
Restoring restart-on-tap behavior
To allow tap-mode reader scans to restart the current game:
[readers.scan]
allow_relaunch = true
The default is false, including when this key is absent from an existing
configuration. It applies to the token's effective tap mode, including per-reader
overrides and #tap. Hold mode, API/hook launches, automatic playlist progression,
and audio/video repeat behavior are unchanged. System-only and platform-specific
commands without a resolved media target also retain their existing behavior.
Explicit changes of launcher or
MiSTer setname, and non-run actions such as details, are not suppressed.
This key does not change what a playlist card does. **playlist.play naming the
playlist already playing moves to the next item either way, because it acts on
the playlist rather than relaunching media.
Matching uses resolved launch paths and systems, not display names. Different ROM files remain different targets, even when they share a title. MiSTer ZIP launches are compared after selecting the contained file.
With launch guard enabled, a single resolved tap-mode launch only asks for confirmation if it would change the game. Confirmation resumes the selected target without resolving it again. Compound scripts and HTTP(S) ZapLinks retain whole-token confirmation before execution.
Behavior: readers.scan.mode='hold' and readers.scan.exit_delay=0.0
When readers.scan.mode='hold' with readers.scan.exit_delay=0.0 and a game is launched using a card:
- Removing the card from the reader will close the game immediately after
on_removecompletes, including when removal happens before launch initialization finishes. Ifon_removecontains a delay, that hook delay completes before the zero-delay hold exit starts. - The
before_exitscript, if configured, runs afteron_removeand immediately before the game closes. - Scanning and removing a command card will execute the command without closing the game; only the launch card owns Hold mode exit.
- Exiting the game manually while the card is still on the reader will not cause the game to relaunch when returning to the menu.
- Exiting the game manually via the internal menu and then removing the card won't trigger a core menu reload.
Behavior: readers.scan.mode='hold' and readers.scan.exit_delay=N
When readers.scan.mode='hold' with readers.scan.exit_delay=N and a game is launched using a card:
- Removing the card from the reader runs
on_removefirst, then starts the N-second hold-exit countdown after the hook completes. Any hook delay therefore precedesexit_delayrather than overlapping it. - The full order on a hold-mode exit is
on_remove, thenexit_delay, then thebefore_exitscript, then the game closes. - Removing the card and reinserting it before the N-second countdown ends will not interrupt the ongoing game.
- When
on_removecontains adelaycommand, reinserting the removed card during that delay cancels the remaining hook commands without relaunching the game. - Removing the card and tapping a different game card will immediately launch the other game.
- Removing the launch card and tapping a command card will execute the command without resetting or transferring the countdown. Removing the command card will not trigger another exit.
- Exiting the game manually while the card is still on the reader will not cause the game to relaunch when returning to the menu.
- Exiting the game manually via the internal menu and then removing the card won't trigger a core menu reload.
- Exiting the game manually during the N-second countdown cancels the countdown and returns to the menu.
Behavior: the before_exit hook
A before_exit script runs just before media stops or is replaced. It can be
written at three scopes: a [[systems.default]] entry, a [[launchers.default]]
entry naming a launcher or one of its groups, and the global [launchers] key.
[launchers]
# Everything not claimed by a more specific scope.
before_exit = "**input.keyboard:{f12}"
# Every launcher in a group, in one entry: all the MiSTer RetroAchievements
# cores, every Kodi launcher, every LLAPI core, and so on.
[[launchers.default]]
launcher = "RetroAchievements"
before_exit = "**input.keyboard:{f2}"
[[systems.default]]
system = "SNES"
before_exit = "**input.keyboard:{f4}"
Scopes resolve narrowest first, and an unset script falls through to the next:
- a
[[launchers.default]]entry naming the outgoing launcher exactly - a
[[systems.default]]entry for the outgoing media's system - a
[[launchers.default]]entry naming one of that launcher's groups - the global
[launchers] before_exit
A named launcher is narrower than a system; a group spans many launchers across many systems, so it sits below one. A system entry is found by the outgoing media's own system, then by the system of the launcher that started it, and aliases resolve on either side.
- Tapping a second card runs
before_exitbefore the new game starts. -
**stop,**playlist.stopand thestopAPI method each run it before returning to the menu. -
**mister.mglruns it before the MGL replaces the running core. - A playtime limit runs it before it stops the game.
- Removing the card in hold mode runs it after
on_removeandexit_delay. - Quitting the game from the emulator or frontend does not run it; by then the media is already gone.
- Background-slot audio does not run it, and a primary launch does not run the hook for background media.
- A script that fails still lets the game exit, and the failure is logged.
- A script that stalls stops the exit for at most 30 seconds.
- Only one
before_exitscript runs at a time, so a script that itself stops or launches media does not trigger another. - One
[[launchers.default]]entry for a group runs for every system its launchers cover, with no[[systems.default]]entries configured. - An entry naming a launcher exactly beats a
[[systems.default]]entry for that media's system, which in turn beats a group entry. - The global
[launchers] before_exitruns for media no other scope claims, including media a platform reports without a launcher, such as a game started from the MiSTer menu.
Per-reader mode: [readers.drivers] and [[readers.connect]]
A reader can override the global mode, so a cartridge slot can hold on a device
whose NFC antenna taps. scan_mode on a [[readers.connect]] entry applies to
that one device; on [readers.drivers.<id>] it applies to every reader using
that driver. An empty or unrecognised value falls through to the next level.
Driver IDs are matched with neither case nor underscores significant, so
pn532, PN532 and pn_532 all name the same driver, wherever one appears —
a [readers.drivers.<id>] section, a [[readers.connect]] entry's driver,
or an enabled or auto_detect override. Scan mode values are read the same
way, so hold, HOLD and " hold " are one value.
[readers.scan]
mode = "tap"
[readers.drivers.opticaldrive]
scan_mode = "hold"
[[readers.connect]]
driver = "pn532"
path = "/dev/ttyUSB1"
scan_mode = "hold"
- A reader with no
scan_modebehaves exactly asreaders.scan.modesays. - A
[[readers.connect]]entry'sscan_modewins over its driver's. - A driver's
scan_modewins overreaders.scan.mode. - With one hold reader and one tap reader, removing from the tap reader leaves media running and removing from the hold reader exits it.
- Setting
scan_modenever changesreaders.scan.mode, and the app's Scan mode setting still reads and writes only the global value. - The
readersAPI method reports each reader's effective mode. - A driver named in a different case, or with underscores, still resolves:
[readers.drivers.PN532]configures thepn532driver, and a connect entry withdriver = "PN532"opens. -
settings.updaterejects ascanModethat is neithertapnorhold, and stores any accepted spelling canonically.
Two readers at once
Each reader's presence is tracked separately, so what one reader reports never decides what another reader's report means.
- With a card on each of two readers, removing one exits (or not) according to that card and that reader, and leaves the other alone.
- Scanning a command card on a second reader, with or without removing it again, does not stop the first reader's removal from exiting its media.
- The same card presented to both readers is two presences: removing it from one does not clear the other.
Per-token override: the #tap and #hold traits
One token can override the mode it would otherwise inherit, without changing any setting. Both traits are boolean, so the shorthand form is the normal one:
#tap||/media/games/SNES/Mario.sfc
#hold||**launch:/media/games/SNES/Mario.sfc
The value form works as well, since #hold=false means the same as #tap.
Trait keys are case-insensitive, so #hold and #HOLD are one trait; writing
it twice is the same as writing its last value once.
- With
readers.scan.mode='hold', removing a#taptoken leaves the game running, and itson_removehook does not run. - With
readers.scan.mode='tap', removing a#holdtoken closes the game afterreaders.scan.exit_delay. - A token's trait wins over its reader's
scan_mode. - A
#taptoken that launches media takes over hold ownership, so removing the card that launched the previous game does not close the new one. - A
#taptoken that runs only a command leaves the current hold owner alone; removing the owner's card still exits. - A token carrying both
#tapand#holdis treated as carrying neither, and inherits the normal mode. - A playlist started by a
#taptoken keeps tap behavior across every track, and a playlist item's own traits do not change it.
A misspelled trait is silent: #taap||... is not an error, it is simply not an
override. This follows ZapScript's existing rule that an unrecognised trait key
mixed with other content falls back to being launch content.
Traits are settled once, when the token enters the system, and describe the token rather than a step in running it:
- A hook script or an injected command that declares
#tapor#holddoes not change the mode of the token that triggered it. - Every track of a playlist runs under the mode the card that started the playlist declared.
- Under hold mode, removing the card that started a playlist clears it, so scanning that card again starts the playlist from its first item. Moving through a playlist by scanning its card again is tap-mode behavior.
Toy traits
A toy-to-life figure has no ZapScript on it, so Core reads what figure it is and
attaches that to the token as traits. A mapping of type traits can then run a
script for every figure that matches, and scanned.traits and
last_scanned.traits expose the same values to expressions.
| Family | Token type | Readers |
|---|---|---|
| Amiibo | Amiibo | PN532, libnfc, PC/SC (ccid) |
| LEGO Dimensions | LegoDimensions | PN532, libnfc, PC/SC (ccid) |
| Skylanders | Skylanders | PN532, libnfc, PC/SC (ccid) |
| Disney Infinity | DisneyInfinity | PN532, libnfc, PC/SC (ccid) |
Trait keys, shared between families where the meaning is the same:
| Key | Families | Value |
|---|---|---|
toy | all | amiibo, lego_dimensions, skylanders or disney_infinity |
name | all | The figure's name, such as Isabelle - Winter |
character | all | The character, without the variant |
type | all | The kind of figure, such as Figure, Card or Vehicle |
game_series | Amiibo | The character's franchise |
series | Amiibo, Disney Infinity | The product line or franchise |
game | Skylanders | The game the figure was released for |
element | Skylanders | The figure's element |
variant | Amiibo, Skylanders | The variant number the tag stores |
amiibo_id | Amiibo | The 16-digit hex ID |
skylander_id | Skylanders | The toy ID number |
dimensions_id | LEGO Dimensions | The character or vehicle ID number |
infinity_id | Disney Infinity | The figure number |
toy and the ID keys are always set on a recognised figure. The names come
from a table built into Core, so a figure the table does not know carries only
those. Reader traits win over a trait of the same name declared in ZapScript.
traits mappings
The pattern is ZapScript trait syntax, and a token matches when it has every key in the pattern with a matching value:
#toy=amiibo #game_series="Super Smash Bros."
#character=spyro
#amiibo_id=01000000000b0002
- Names compare as slugs, so case, spacing and punctuation do not matter:
#game_series=super_smash_brosmatchesSuper Smash Bros.. - ID keys compare exactly, ignoring case. Numbers compare by value.
- A list matches any of its members:
#character=[Mario,Luigi]. - The match type is ignored and stored as
exact. An invalid pattern is rejected when the mapping is created or changed. - Only traits the reader read are matched, never ones a script declared.
When several mappings match a token, the most specific wins: uid, then data,
then text, then traits. Among traits mappings, the one
with more keys wins. A tie goes to the first, database mappings before those in
the mappings folder. In a TOML mapping file, use token_key = "traits".
- Scanning a figure reports its traits in
tokens.added. - A
traitsmapping for a figure's character launches its script. - A UID mapping for the same figure wins over the
traitsmapping. - NTAG and MIFARE Classic cards written by Zaparoo still read as before.
Launch modifier cards
A **launch card with no path and only modifier arguments changes how other
cards launch instead of launching anything itself. The modifier arguments are
launcher, set_name, set_name_same_dir and action (run or details),
and one card can carry several, separated by &:
**launch?launcher=RetroArch
**launch?action=details
**launch?set_name=GBC&set_name_same_dir=yes
A **launch card that has a path keeps its arguments to its own game and never
sets a modifier. A no-path card carrying any other argument is an ordinary launch
and fails for the missing path.
- A modifier with an unknown launcher, an action other than
runordetails, or an empty value is refused when its card is scanned, with the fail sound. - A modifier only applies to launches from reader scans (
**launch,**launch.random,**launch.search,**launch.title,**launch.lastand plain paths), never to API, hook or playlist launches. Its values replace the launching card's own values for the same arguments.
How long a modifier lasts follows the card's scan mode, settled the same way as
any other token's (trait, then reader, then readers.scan.mode):
- In tap mode, or on a reader that cannot detect removal, the modifier applies to the next launch only, and expires unused after 5 minutes.
- In hold mode on a reader that detects removal, the modifier applies to every launch while its card stays on the reader. With two readers, leave the modifier card on one and scan games on the other.
- Lifting a hold-mode modifier card that has applied at least once ends it. Lifting it before any launch turns it into a one-shot modifier for the next launch, so a single reader still works: place the modifier, lift it, place the game.
- A read error or disconnect on the modifier card's reader ends its held modifier. A one-shot modifier waiting for its launch is kept.
- Modifier cards on several readers stack. For each of
launcher,actionand theset_namepair, the newest card that sets it wins.set_nameandset_name_same_diralways come together from one card; a card setting only one of them leaves the other unset. - A pending one-shot modifier wins over held ones for the launch that uses it, and a new one-shot replaces an older unused one.
- The
tokensmethod lists active modifiers, and thetokens.modifiersnotification is sent whenever the list changes.
Optical drives: discs as tokens
Inserting a disc is a scan, and ejecting it is a removal, so a disc follows the same tap and hold rules as a card. The drive is checked once a second by asking it whether the disc changed, without reading the disc; the disc is read once each time it changes.
A mapping for the disc, or a zaparoo.txt on it, always wins. Otherwise the
drive's settings decide what plays:
[readers.drivers.opticaldrive]
# image_first (default): a matching image in the library, else the disc itself
# disc_first: the disc itself, else a matching image
# image_only, disc_only: never the other one
launch_order = "image_first"
# Launcher ID that plays audio CDs; empty means the platform default
audio_cd_launcher = ""
# Read the disc once a second while it is in the drive. Off by default:
# reading can make a disc that is playing from the drive skip, in a disc
# core or as an audio CD.
keep_reading = false
- Inserting a disc with a mapping or a
zaparoo.txtruns that, whateverlaunch_ordersays. - With
image_first, a disc whose game is in the library launches the image; one whose game is not launches the disc from the drive. - With
disc_first, the disc launches from the drive when something can play it, and the library image otherwise. -
image_onlynever launches the disc from the drive, anddisc_onlynever launches a library image. - An audio CD plays with
audio_cd_launcherwhen it is set, and with the platform default when it is empty. A launcher that is set but missing or unavailable plays nothing. - With
keep_readingoff, a disc in the drive is not read again until it changes. - When nothing can play the disc, Core logs it and shows no error.