Skip to content

Cookbook Tweaks

bryanthaboi edited this page Jul 19, 2026 · 1 revision

Cookbook — tweaks

Content changes to things that already exist. Mechanism: Concepts: Registries. All code goes in main.lua inside return function(mod) ... end unless noted.

R01 — Recolor a battle sprite

Ship a recipe, not pixels: declare "assets_transforms": "transforms.lua" in the manifest and write the transform.

-- transforms.lua
return function(ctx)
  local front = ctx.readImage("battle/front/mew.png")
  ctx.writeImage(ctx.recolor(front, {
    { 255, 255, 255 }, { 255, 170, 200 }, { 180, 60, 120 }, { 40, 0, 20 },
  }), "battle/front/mew.png")
end

The derived file shadows the cache path everywhere it is drawn. Checkpoint: Mew renders recolored in the dex and in battle. Full walkthrough: Tutorial 01.

R02 — Rewrite one dialogue line

mod.content.text:override("_PalletTownSignText", "MODDED SIGN.")

Checkpoint: reading the Pallet Town sign shows the new text. Find label names in the merged registry: mod.content.text:each().

R03 — Buff a move's power

mod.content.moves:patch("TACKLE", { power = 50 })

Checkpoint: Tackle deals more damage; every unnamed field stays vanilla.

R04 — Rebalance a species' stats

mod.content.pokemon:patch("PIDGEY", { baseStats = { speed = 71 } })

Checkpoint: the baseStats sub-table merges — only speed changes. base_stats is the classic typo; api = 2 rejects it with a suggestion.

R05 — Change a wild encounter table

mod.content.encounters:patch("ROUTE_1", {
  grass = {
    rate = 30,
    slots = { __prepend = { { species = "EKANS", level = 5 } } },
  },
})

Checkpoint: Route 1 rolls Ekans in its most common slot; rate (of 255) governs how often grass rolls at all. Ten slots weight front-to-back per constants.encounterBuckets.

R18 — Change a trainer's party

mod.content.trainers:patch("OPP_BROCK", {
  parties = { { { species = "ONIX", level = 14 },
                { species = "GEODUDE", level = 12 } } },
})

Checkpoint: Brock leads Onix 14. parties is an array of parties — arrays replace wholesale, so state the full party list.

Clone this wiki locally