Skip to content

sf2.items

Items are weapons, armour, helmets, ranged and magic gear, consumables and item sets. Register your own while your mod loads, change existing ones with a patch, or look them up by ID. Get sf2 with local sf2 = require("sf2").

Create an item owned by your mod: equipment, a stackable consumable, a plain item, or an item set.

Signature: sf2.items.register { category, id, ... }

Parameters

Parameter Type Required
definition WeaponDefinition|ArmorDefinition|HelmDefinition|RangedDefinition|MagicDefinition|ConsumableDefinition|NonEquipmentDefinition|ChestDefinition Required

Fields every kind shares (WeaponDefinition, ArmorDefinition, HelmDefinition, RangedDefinition, MagicDefinition, ConsumableDefinition, NonEquipmentDefinition, ChestDefinition)

Field Type Required Meaning
id string Required —
display_name string|LocalizationHandle Required —

More fields of WeaponDefinition

Field Type Required Meaning
category "weapon" Required —
icon string|SpriteHandle Required —
model string|ModelHandle Required —
shop ItemShopListing Optional List the item in the shop for its slot.
perk ItemPerk|string|PerkHandle Optional The item’s built-in perk: a perk table or handle.
initial_stats WeaponInitialStats Optional Starting stats. Omit to use the normal stats for the item level.
subtype string Optional Defaults to Katana. Match the model and move family.
tactic_subtype string Optional Optional AI table group, defaults to subtype. 1-128 ASCII letters, digits or underscores.

More fields of ArmorDefinition

Field Type Required Meaning
category "armor" Required —
icon string|SpriteHandle Required —
model string|ModelHandle Required —
shop ItemShopListing Optional List the item in the shop for its slot.
perk ItemPerk|string|PerkHandle Optional The item’s built-in perk: a perk table or handle.
initial_stats ArmorInitialStats Optional Starting stats. Omit to use the normal stats for the item level.

More fields of HelmDefinition

Field Type Required Meaning
category "helm" Required —
icon string|SpriteHandle Required —
model string|ModelHandle Required —
shop ItemShopListing Optional List the item in the shop for its slot.
perk ItemPerk|string|PerkHandle Optional The item’s built-in perk: a perk table or handle.
initial_stats HelmInitialStats Optional Starting stats. Omit to use the normal stats for the item level.

More fields of RangedDefinition

Field Type Required Meaning
category "ranged" Required —
icon string|SpriteHandle Required —
model string|ModelHandle Required —
shop ItemShopListing Optional List the item in the shop for its slot.
perk ItemPerk|string|PerkHandle Optional The item’s built-in perk: a perk table or handle.
initial_stats RangedInitialStats Optional Starting stats. Omit to use the normal stats for the item level.
subtype string Required —

More fields of MagicDefinition

Field Type Required Meaning
category "magic" Required —
icon string|SpriteHandle Required —
model string|ModelHandle Required —
shop ItemShopListing Optional List the item in the shop for its slot.
perk ItemPerk|string|PerkHandle Optional The item’s built-in perk: a perk table or handle.
initial_stats MagicInitialStats Optional Starting stats. Omit to use the normal stats for the item level.
subtype string Required —

More fields of ConsumableDefinition

Field Type Required Meaning
category "consumable" Required —
description string|LocalizationHandle Optional Shown in the shop’s info panel. Default: display_name.
icon string|SpriteHandle Optional Required with stack.
model string|ModelHandle Optional —
subtype string Optional —
pack_label string Optional —
silent_receive boolean Optional —
spend_after_use boolean Optional Not with stack.
stack integer Optional Makes it a stackable consumable: the most pieces a player can hold, 1-999.
shop ConsumableShopListing Optional Sell it in the shop, count pieces a purchase. Needs stack.

More fields of NonEquipmentDefinition

Field Type Required Meaning
category "free"|"seal" Required —
icon string|SpriteHandle Optional —
model string|ModelHandle Optional —
subtype string Optional —
pack_label string Optional —
silent_receive boolean Optional —
spend_after_use boolean Optional —

More fields of ChestDefinition

Field Type Required Meaning
category "chest" Required —
description string|LocalizationHandle Required —
icon string|SpriteHandle Required —
shop ChestShopListing Required —
contents (string|ItemHandle|ChestContent)[] Required What the chest hands over, equipped.

Fields of ItemSet

Field Type Required Meaning
category "set" Required —
id string Required —
title string|LocalizationHandle Required —
text string|LocalizationHandle Required —
brief string|LocalizationHandle Required —
members SetMember[] Required —
perk string|PerkHandle Optional A combo perk your mod registered (kind = “combo”) that this set stands for: the forge offers it only once the player owns every member. Default: none.

Returns: An item handle (an item-set handle for category = "set").

When: During loading, before referencing the item.

local weapon = sf2.items.register {
category = "weapon",
id = "my_weapon",
display_name = sf2.text.get("item.my_weapon"),
icon = sf2.assets.sprite("sprites/weapon"),
model = sf2.assets.model("core:gamedata/models/mdl_weapon_katana_ritual"),
subtype = "Katana",
shop = { level = 1, price = { coins = 1000 } },
}
local set = sf2.items.register {
category = "set", id = "training_set",
title = sf2.text.get("set.title"),
text = sf2.text.get("set.description"),
brief = sf2.text.get("set.brief"),
members = { { item = weapon, scale = 1 } },
}

category decides which fields apply; equipment (weapon, armor, helm, ranged, magic) is covered in the weapons guide. subtype must match the model’s move family. tactic_subtype (weapons) picks the AI table group independently, e.g. subtype = "TwoHandedBlunt", tactic_subtype = "TwoHanded"; it creates no moves.

A chest is a shop item that is bought once with gems and hands over its contents, equipped, instead of going into the inventory. A card then shows the art of everything it held. It leaves the shop when bought, and is not offered to a player who already owns everything in it:

sf2.items.register {
category = "chest",
id = "founder_chest",
display_name = sf2.text.get("item.founder_chest"),
description = sf2.text.get("item.founder_chest.description"),
icon = sf2.assets.sprite("sprites/founder_chest"),
shop = { level = 10, group = "ZONE_3", price = { gems = 500 } },
contents = {
weapon,
{
item = armor,
scale_to_player = true,
enchantments = { guard },
aspect_by_level = { base = 40, per_level = 3 },
},
},
}
Field Required Meaning
display_name, description Yes Text handles shown in the shop.
icon Yes A sprite handle.
shop Yes level (shop level), price = { gems = n } and an optional group: a shop group the save has unlocked: the game unlocks ZONE_2 to ZONE_6, ZONE_7, ZONE_7_2, ZONE_7_3 and ZONE_IM (the Intermission) as the story reaches each act. Leave it out for anything sold from Act 1. Any other name is never unlocked, so the item never shows.
contents Yes A list of what the chest gives: an item (a handle or ID), or a table with the fields below.
Content field Required Default Meaning
item Yes The item to give.
scale_to_player No false Raise the item to the player’s level when it is opened.
enchantments No Keep its own Replaces the item’s enchantments, in the same form as enchantments in sf2.items.patch.
aspect_by_level No Enchantment power for entries with no aspect of their own: base + per_level * player level. base is required; per_level defaults to 0. Used only with scale_to_player.

A consumable with stack is a stackable consumable: the player holds it as a count of pieces, up to stack. The shop can sell it one piece at a time, and your script uses pieces up with sf2.profile.take_item. It is never equipped and has no upgrades or power of its own; the effect of a piece is whatever your script does when it takes one.

local elixir = sf2.items.register {
category = "consumable",
id = "healing_elixir",
display_name = sf2.text.get("item.healing_elixir"),
description = sf2.text.get("item.healing_elixir.description"),
icon = sf2.assets.sprite("sprites/healing_elixir"),
stack = 9,
shop = { price = { coins = 250 } },
}
Field Required Default Meaning
stack Yes, for a stackable consumable The most pieces a player can hold, 1 to 999.
icon Yes, with stack A sprite handle: the shop tile and info panel show it.
description No display_name A text handle shown in the shop’s info panel. Any consumable can have one.
shop No Not sold price (exactly one of { coins = n } or { gems = n }, at least 1, for one purchase), count (pieces one purchase gives, 1 up to stack, default 1), level (1 to 52, default 1: the player level from which the shop lists it) and an optional group, as for a chest. Needs stack.

The item’s ID is <mod id>:items/consumable/<id>. A stackable consumable for sale is listed in the shop tab that also holds chests and the game’s other consumables. Its tile shows how many the player holds (x3) and its price; the info panel says how many they have out of the stack. Each purchase adds count pieces (one unless you set it) and pays the price once, with the coins or gems of the save; the info panel says how many a purchase gives, and buying stops once a whole purchase no longer fits under the stack. For a pack, such as ten tickets for 30 gems, write shop = { price = { gems = 30 }, count = 10 }. Without shop it is not sold, and the shop lists it only while the player holds some.

Pieces come from the shop, from fight rewards (an items entry can carry a count, see sf2.battles.register) and from sf2.profile.give_item. No grant goes past the stack. sf2.profile.item_count reads the count. The count is saved with the player’s inventory; while your mod is off, the save keeps it, and it is back when the mod is on again. If an update lowers stack, players keep the extra pieces but cannot get more until they are below it. spend_after_use does not apply to a stackable consumable.

consumable items without stack, free and seal items are plain content (such as a mode entry ticket) with no power, shop price or on_use callback. A set only groups items for display: no bonus, no grant, no shop listing. A shop listing is what puts equipment in a shop.

A set can also stand for a set enchantment: give perk, a combo perk your mod registered earlier (kind = "combo" in sf2.perks.register). The forge then treats that enchantment like the game’s own set enchantments: it is ready, undimmed and unlocked only while the player owns every member, and it is not offered at all otherwise. One set per perk.

sf2.items.register {
category = "set", id = "dragon_set", perk = stone_fetters,
title = sf2.text.get("set.dragon"), text = sf2.text.get("set.dragon.text"),
brief = sf2.text.get("perk.stone_fetters.description"),
members = { { item = dragon_knives }, { item = dragon_carapace }, { item = dragon_helm } },
}
Set field Required Meaning
title, text, brief Yes Text handles of your mod: the set’s name, its collect line and what its enchantment does.
members Yes The items, each { item, scale?, rotate?, x?, y?, icons_y? }.
perk No The combo perk this set stands for. Default: none.

Change an existing item (core, another mod’s, or yours) field by field.

Signature: sf2.items.patch { item, perks?, subtype?, tactic_subtype?, icon?, model?, initial_profile?, enchantments?, price?, secondary_price?, shop?, visibility?, required_group?, minimum_level?, borrowable? }

Parameters

Parameter Type Required
definition ItemPatch Required

Fields of ItemPatch

Field Type Required Meaning
item string|ItemHandle Required —
perks (string|PerkHandle|InnatePerk)[] Optional Replaces the item’s innate perks (at most 64).
subtype string Optional Case-sensitive weapon subtype; needs matching moves.
tactic_subtype string Optional AI table group; an empty string selects the fallback.
icon string|SpriteHandle Optional Replacement shop icon.
model string|ModelHandle Optional Replacement fighter model.
initial_profile ItemInitialProfile Optional —
enchantments (EnchantmentHandle|string|PerkHandle|DefaultEnchantment)[] Optional Replaces the enchantments a newly acquired copy gets (at most 64).
price Price Optional The shop price. Replaces the item’s price. Equipment takes at least 1; a consumable (the core Perk Reset, a stackable one) also takes 0, which sells it free and labels it FREE.
secondary_price Price Optional Optional positive price in the other currency; needs price.
shop ItemShopListing Optional Adds a shop listing for the item.
visibility "inherit"|"force_visible"|"force_hidden" Optional —
required_group string Optional Shop group the save must have unlocked (ZONE_2 to ZONE_6, ZONE_7, ZONE_7_2, ZONE_7_3 or ZONE_IM, unlocked as the story reaches each act; other names never unlock). Also the unlock-notification label for mod-owned equipment.
minimum_level integer Optional —
borrowable boolean Optional false: opponents that copy items from the player’s inventory (the dojo disciple) never pick this item. Default true.

Returns: nil.

When: During loading, with an item handle. Apply & Restart to load or remove a patch.

sf2.items.patch {
item = sf2.items.get("core:items/weapon/WEAPON_KNIVES"),
price = { gems = 39 },
visibility = "force_visible",
}

Give item plus at least one field; each is applied independently. A second patch to the same field of the same item, even from another mod, fails the later mod; different fields coexist. Copies already built keep old values. See the weapons guide for shops, prices and visibility.

Free consumables. price also reprices a consumable, such as the core Perk Reset. Only a consumable can be made free: { gems = 0 } sells it for nothing, and the shop shows FREE instead of a price. A free consumable takes no secondary_price.

sf2.items.patch { item = sf2.items.get("core:items/consumable/perk_reset"), price = { gems = 0 } }

Presentation. icon and model swap the shop icon and fighter model but keep identity and purchase state:

sf2.items.patch { item = sf2.items.get("core:items/weapon/WEAPON_KUNAI"),
icon = sf2.assets.sprite("core:ui/items/weapon_kunai") }

Initial profile. initial_profile replaces the starting level, upgrade level and stat snapshot, not identity or price. Omit upgrade_template or legacy_paid_item to keep current values; legacy_paid_item is only a marker for older conditions, not a price or shop rule. A different upgrade_template can change upgrade prices and power; clear_local_upgrades = true drops the item’s one-off upgrade rows. Saved inventory is not re-leveled.

sf2.items.patch { item = sf2.items.get("core:items/weapon/WEAPON_BP_S1_GUARDIAN"),
initial_profile = { level = 15, upgrade_level = 1500, initial_stats = { weapon_damage = 342 } } }

Subtypes. subtype changes the combat family of a weapon, ranged or magic item (not armor or helms). It does not create missing animations: the family needs compatible moves, so switching to ChineseSwords also needs its stance and attack graph. tactic_subtype changes only the AI table group; "" falls back to subtype.

sf2.items.patch { item = sf2.items.get("core:items/weapon/WEAPON_TWO_HANDED_MACE"),
tactic_subtype = "TwoHanded" }

Innate perks. perks replaces the permanent perks (empty array removes them). Each entry is a perk handle or { perk, parameters? }; each perk once. Lua-backed perks take parameters at registration, so list them with none. They apply to already-owned copies in newly built fighters, separate from saved enchantments. Callbacks see fighter.source = "innate"; if the same perk is also learned or enchanted it runs once per event (learned, then innate, then enchantment). Innate perk state lasts one fight; use mod save data for progress. See sf2.perks.register.

sf2.items.patch { item = sf2.items.get("core:items/weapon/WEAPON_KNIVES"),
perks = { { perk = sf2.perks.get("core:perks/PERK_ITEM_SPECIAL_PRECISION_WEAPON"),
parameters = { Aspect = 100 } } } }

Default enchantments. enchantments replaces the enchantments an item comes with when acquired (shown in shop previews); it does not touch owned items. Each entry is a perk handle or { perk, aspect? } with a fixed integer aspect. Innate perks and default enchantments can coexist. An item you registered needs a shop listing for these to show.

Borrowing. Some fights hand the opponent random items from your own inventory: the dojo disciple’s sparring fight picks one of your weapons, ranged items and magic. Set borrowable = false to keep an item out of that pick, for example gear that should stay the player’s alone. Items are borrowable by default.

sf2.items.patch { item = my_boss_sword, borrowable = false }

Retire an item ID that no longer exists so saved copies still resolve.

Signature: sf2.items.retire { id, replaced_by? }

Parameters

Parameter Type Required
definition ItemRetirement Required

Fields of ItemRetirement

Field Type Required Meaning
id string Required The item that no longer exists, as a local ID or a core ID.
replaced_by string|ItemHandle Optional The item saved copies become. Leave out to drop the item without a replacement.

Returns: nil.

When: During loading, after registering the replacement.

sf2.items.retire { id = "weapon/old_blade", replaced_by = weapon }
sf2.items.retire { id = "weapon/retired_blade" } -- no replacement

id is the old local path including its category. With replaced_by (same category, owned by your mod), saved copies become the new item. Without it, the ID stays reserved and saved copies are untouched but unavailable. Nothing is deleted from saves.

Get a handle to an existing item, including a core item.

Signature: sf2.items.get(reference)

Parameters

Parameter Type Required
reference string Required

Returns: An item handle. A missing ID is an error, never nil.

When: During loading, before using the handle.

local katana = sf2.items.get("core:items/weapon/weapon_katana")

Use the full definition path (items/weapon/...), not a model path or legacy name. For your own item, keep the value returned by registration. See finding core content.