Skip to content

Make your first mod

You will make Training Blade, a katana that appears in the weapon shop at level 1 for one coin. You need Eclipse, a text editor and one sample image. You do not need Unity or a Lua installation; Eclipse runs the script for you.

If code is new to you, keep Lua basics open alongside this page. Copy each file first, get the mod working, then experiment. If you use VS Code, the editor extension can create all of these files for you with Create Mod.

Open the game’s Mods folder (see Install and enable mods if you are not sure where it is) and make a folder called tutorial.blade. Inside it, create these folders and files:

Mods/
tutorial.blade/
mod.toml
scripts/
main.lua
localizations/
eng.toml
assets/
sprites/
weapon.asset
textures/
weapon.png

Show file extensions in your file manager so you do not end up with main.lua.txt or mod.toml.txt. Save text files as UTF-8. mod.toml must be directly inside the mod folder, with no extra folder around it.

Create mod.toml:

mod.toml
schema = 1
id = "tutorial.blade"
name = "Training Blade"
version = "1.0.0"
authors = ["Your Name"]
entrypoint = "scripts/main.lua"
[[dependencies]]
id = "core"
version = ">=2.0 <3.0"

id is the mod’s permanent identity and name is what players see. entrypoint names the first script to run. The core dependency lets your mod reuse the game’s own katana model. How mods work explains every field.

Create localizations/eng.toml:

localizations/eng.toml
weapon.training_blade = "Training Blade"

The left side is a key your script asks for. The right side is the text players see. To translate the name later, add another file such as pol.toml with the same key. For this first test, select English in the game.

Download the sample weapon PNG and save it as assets/textures/weapon.png. If your browser opens the image, use Save image as and keep the .png extension.

Create assets/sprites/weapon.asset:

assets/sprites/weapon.asset
type=sprite
texture=textures/weapon.png
pixels_per_unit=100

A texture is the picture file. A sprite tells the game how to use a picture. The texture line points at the PNG, starting inside assets/. The .asset file is a small text file, not a Unity file. The PNG becomes the shop icon. The weapon in the fight looks like the katana model you borrow in the next step.

Create scripts/main.lua:

scripts/main.lua
local sf2 = require("sf2")
sf2.items.register {
category = "weapon",
id = "training_blade",
display_name = sf2.text.get("weapon.training_blade"),
icon = sf2.assets.sprite("sprites/weapon"),
model = sf2.assets.model("core:gamedata/models/mdl_weapon_katana_ritual"),
subtype = "Katana",
shop = { level = 1, price = { coins = 1 } },
}
sf2.log.info("Training Blade registered")

What the script does:

  1. require("sf2") loads the Eclipse API into a variable called sf2.
  2. sf2.items.register with category = "weapon" creates the item.
  3. sf2.text.get finds the translated name from step 3. sf2.assets.sprite finds your sprite file (write the path without .asset).
  4. sf2.assets.model borrows the core katana model. Keep subtype = "Katana" with this model, because the subtype decides which moves the weapon uses.
  5. shop puts the weapon in the weapon shop from level 1, and price = { coins = 1 } makes it cost one coin. Without shop, the weapon exists but nobody can buy it.
  6. sf2.log.info writes a line to the game log so you can tell the script reached the end.

The weapon’s full ID becomes tutorial.blade:items/weapon/training_blade. register also returns a handle, a value standing for the item. This script does not need it, but you can keep it for later with local blade = sf2.items.register { ... } to use the weapon in a reward or a rule.

  1. Start Eclipse and open Mods on the title screen.
  2. Switch on Training Blade. Open Details if it reports a problem, then choose Apply & Restart.
  3. Enter Campaign and open the weapon shop. Use a profile that has reached the shop.
  4. Buy Training Blade for one coin, equip it and enter a fight. It uses the borrowed katana model.

If something fails, see Troubleshooting. A missing mod usually means the folder or mod.toml is wrong. A listed mod with an error usually means a dependency, a script line, a translation key or a file path needs fixing.

Exit the game, change the name in eng.toml and launch again. The shop shows the new name. Next, change the price from 1 to 5. Saving a script never updates a running game; restart to see changes (while developing, F9 reloads your Lua).

To share the mod, change the folder name, id, name and authors. Use a unique ID such as yourname.training, and keep it and the item’s local ID the same once other people use them, because saves refer to them.