3 Tutorial 02 Balance Patch
bryanthaboi edited this page 2026-10-20 17:01:40 -04:00

Tutorial 02: Balance patch

Make: Set Tackle's power and accuracy, change Pidgey's base Speed, and edit Brock's party.

Before you start: Beginner. Know the edit/restart loop from Tutorial 00 and the difference between an ID and a name in Modding Basics.

Game: Red, local single-player. Use a practice save for experiments. If file creation is new to you, start with Tutorial 00; unfamiliar words are in the Glossary.

1. Set up the files

Create a new tutorial_02 folder in your mod location. Disable earlier tutorial mods for this exercise. The starting state is this empty folder; the finished state is all the files below.

This is a mod folder, not the engine root. Do not replace the engine's own main.lua. Preserve filenames and avoid an extra .txt extension.

Finished folder layout:

mods/tutorial_02/
  main.lua
  manifest.json

Each link opens a complete file you can save at the matching path. The JSON and Lua are also printed in full below; do not append them to another lesson's entry function.

File in this mod Complete example
main.lua Download main.lua
manifest.json Download manifest.json

2. Describe the mod

Complete file: replace tutorial_02/manifest.json:

{
  "id": "tutorial_02",
  "name": "Tutorial 02",
  "version": "1.0.0",
  "entry": "main.lua",
  "api": 2,
  "games": [
    "red"
  ]
}

id is the stable internal name, name is the label in MODS, and entry tells the loader which Lua file to open. games limits these examples to Red. Keep commas between JSON fields and no comma after the last field.

3. Write the change

Complete file: replace tutorial_02/main.lua:

return function(mod)
  mod.content.moves:patch("TACKLE", { power = 50, accuracy = 100 })
  mod.content.pokemon:patch("PIDGEY", { baseStats = { speed = 71 } })
  mod.content.trainers:patch("OPP_BROCK", {
    parties = {
      {
        { species = "ONIX", level = 14 },
        { species = "GEODUDE", level = 12 },
      },
    },
  })
end

Understand what you wrote

patch changes the fields you supply. The Tackle patch sets two numbers; the other move fields stay in place. power affects damage calculations and is not a fixed amount of HP lost.

Pidgey's baseStats is a named record inside its species record. Writing { speed = 71 } changes its base Speed without replacing its other base stats. An individual Pidgey's displayed Speed also depends on level and training; it will not simply display 71.

Brock's parties contains lists of Pokémon records. Supply that party in full: the first member is now Onix, followed by Geodude. Record lists are replaced as lists, not matched and merged Pokémon by Pokémon. Registry operations explain the separate rules for named records and plain lists.

4. Load and check it

Save every file, restart the app, enable the mod for Red in the launcher's MODS panel, and launch. Resolve any load error before checking gameplay. Troubleshooting shows where errors appear. With default desktop bindings, A is Z/Enter/Space, B is X/Backspace, and Start is Escape/keypad Enter; use your configured controls if different.

Optional source-checkout validation

If you have Python 3, LuaJIT, and the engine source with Red imported, open a terminal in the engine root containing tools/. For a mod installed in that checkout's mods directory, run:

python3 tools/modkit.py validate tutorial_02 --base imported

If you saved it elsewhere, replace the mod ID with the quoted full path to its folder. A validation error identifies a file or content rule to fix; a pass means you can continue to the in-game checks. It does not prove rendering, sound, or the entire playthrough works. Packaged-app users can use MODS errors and the checkpoints without setting up these command-line tools.

Checkpoint

  1. Enable the mod and launch Red. For an exact source-build check, open the developer console as described in Troubleshooting, then inspect data.moves.TACKLE.power (50), data.moves.TACKLE.accuracy (100), and data.pokemon.PIDGEY.baseStats.speed (71). These are console expressions, not lines to put in your mod.
  2. Use Tackle in battle to confirm the move still works. Do not use one damage roll as proof of the exact power change: opponent stats and random damage variation also matter.
  3. On a practice save where Brock has not been defeated, challenge him in Pewter Gym. His party should lead with level-14 Onix and then level-12 Geodude. Editing the trainer record does not reset a completed gym event.
  4. Change one number, restart, and repeat its exact inspection or party check.

Common pitfalls

What you see What to check
My Pidgey's Speed is not 71 71 is the species' base Speed. Inspect the species record, or compare newly created Pokémon with identical level/training.
Brock will not battle again Use an earlier practice save; changing his party does not clear your victory flag.

For syntax, missing-file, and restart problems, use Troubleshooting. Compare the whole finished file before changing several things at once.

Undo and continue

Disable the mod and restart to compare with the original Red behavior. Keep a copy of your finished files if you want to return to them.

To discover another move, species, or trainer ID, use Find internal IDs and Choose a Registry. Keep a copy of your original numbers for comparison.

Return to the tutorial index to choose the next lesson.