Troubleshooting
Work on one problem at a time, and fix the first error before looking at anything else. Later errors are often caused by the first.
Start with a fresh load
Section titled “Start with a fresh load”After editing files, save them and restart Eclipse. Changing which mods are on
uses Apply & Restart in the mod menu. Registered content, text and
mod.toml are only read at startup. Saving a script never changes a running game
(unless you use the developer reload below).
The file name looks right but nothing loads
Section titled “The file name looks right but nothing loads”- Show file extensions in your file manager and look for accidental
.txtendings such asmain.lua.txt. - Save text files as UTF-8.
- Make sure there is no extra folder between the mod folder and
mod.toml. - In Lua, check for a missing comma, quote, brace or
end. Inmod.toml, put every main field above the first[[dependencies]]line.
See How mods work and Lua basics.
The mod is missing or cannot be switched on
Section titled “The mod is missing or cannot be switched on”Check that Mods/<folder>/mod.toml exists, the id is unique, and entrypoint
points at your Lua file. Open Details in the title-screen mod menu to read
unmet requirements: every dependency must be installed at a compatible version.
Choose Apply & Restart after changing the selection, then enter Campaign.
See Install and enable mods.
Registration fails
Section titled “Registration fails”Read the error that names your mod ID. It says which function and which field inside your table is wrong, for example a field misspelled, a value of the wrong type, an ID that does not exist, or a missing dependency. Check these first:
- a duplicate ID (two things registered with the same name);
- an ID without its
core:prefix, or acore:ID without acoredependency inmod.toml; - a handle of the wrong kind (a sprite where an item is expected).
When one definition fails, the mod’s whole load is rolled back, so nothing from it appears. Fix the first error before hunting for “missing” content.
Two mods cannot both claim the same asset, the same text entry or the same move. Resolve the clash: changing the order of mods does not pick a winner. See Sharing and combining mods.
A picture or sprite does not load
Section titled “A picture or sprite does not load”- The sprite file needs
type=spriteand atexture=path that starts insideassets/and ends in.png. - From Lua you write the sprite path without
.asset. - Keep PNGs in
textures/and sprite files insprites/. - A crop (
rect) must fit inside the image. - For a picture from the base game, check both the atlas name and the icon name.
See Reskin the game.
A callback never runs
Section titled “A callback never runs”Callbacks only run when they are attached to something the game uses. Check that:
- the behaviour is attached to a perk, enchantment, rule or actor;
- that perk or rule is actually active for the fighter you are watching (a
player’s perk must be learned or on equipped gear; an opponent needs it in its
perks); - you used a callback name from the callbacks reference.
The dojo punchbag does not use the normal fight flow, so test in a real fight.
Add a line such as sf2.log.info("on_hit ran") to the callback to prove it fires.
The performance overlay and report
Section titled “The performance overlay and report”When a mod loads but a rule or button behaves oddly, the game can show how long each Lua callback takes and which ones failed:
- Press F3 (or use Options > Display > Performance overlay) to cycle Off, Compact and Detailed. Detailed includes a Lua summary.
- Reproduce the problem once. Turn the overlay on before the action you want to inspect.
- Press F4 while it is on. The game saves a text report into its
Diagnosticsfolder, copies the path to the clipboard and shows it on screen. - Open the report and look under Lua callback diagnostics for failures and slow callbacks.
Saving a report sends nothing anywhere. Review it before sharing it, because error messages can contain your own text.
Reload without restarting
Section titled “Reload without restarting”In the Unity editor and in development builds you can reload your Lua without restarting. Release builds always need a restart.
- Press F9, or press F1 in a fight and choose RELOAD MODS.
- Reload mods on save reloads by itself shortly after you save a file in an
enabled mod’s
scripts/,localizations/ormovesets/folder. It is on by default in the editor and can be switched in the same debug menu.
The result appears at the top of the screen and in the log, on a line starting
with [ModReload]. A reload never interrupts a running function, so it is safe in
the middle of a fight.
| You changed | After a reload |
|---|---|
| Code inside functions (callbacks, AI, mode and story handlers, UI callbacks) | Used from now on. |
| Edits to the game’s own moves and moveset files | Applied again. |
| Anything you register (items, perks, battles, shop listings, settings…) | Restart required. |
Text in localizations/, mod.toml, or which mods are on |
Restart required. |
| Pictures, sounds and models | Restart to be sure you see them. |
If the message says Restart required, it names the first thing that changed.
A reload is refused, and nothing changes, when a script fails to load (fix the
error and save again), when something you register changed, or when an online
match is active. Values kept in local variables at the top of a file start
fresh on each reload. Online play stays unavailable until you restart, so restart
and test once more before you share the mod.
Your own debug buttons
Section titled “Your own debug buttons”Some things are slow to reach while testing: a tutorial that plays once per save, a
screen deep in a story. In the editor and development builds, press F1 outside a
fight for the debug menu. Next to RELOAD MODS it lists buttons mods add with
sf2.debug.action, each running a function of
yours, for example one that clears your “tutorial seen” flag or opens the screen
straight away. Release builds never show them.
Content is missing after you turn a mod off
Section titled “Content is missing after you turn a mod off”Content from a mod you switched off is kept in the save but unavailable. Turn the mod back on and reload the profile to get it back. Do not delete a save to fix this. Keep the original mod ID and content IDs so saves keep working; see Saving and options.
Still stuck?
Section titled “Still stuck?”Check the log for lines tagged with your mod ID, and compare your tables with the example on the function’s reference page. When asking for help, share the first error message and the file it names.