๐ŸŽข Episode 7 ยท Advanced ยท Debug

Make It Solid
Episode 7: Test and Debug

Real modders spend a lot of time reading error messages. In this episode you learn to read the console like a detective, fix the common mistakes, and protect your plugin against crashes.

๐Ÿ‘ถ Ages 10+ โฑ๏ธ ~45 mins ๐ŸŽข OpenRCT2 โœ“ Free workshop
๐Ÿ” Read the log ๐Ÿงฏ Common errors ๐Ÿ›ก๏ธ Guard the code โ™ป๏ธ Reload safely
โญ
0 XP
Level 1
๐Ÿ”ฅ0
Your Progress 0 / 5 steps
Build it in our OpenRCT2 Studio too: set up a park plugin, wire up events, read the park and export real plugin files in the browser, with no install. Open the OpenRCT2 Mod Studio →
๐Ÿ”ฅ
Ember says: an error is not a failure, it is the engine telling you exactly where to look. The console is your friend.
1
๐Ÿ”
Read the Console
Where errors appear
Active
๐ŸŽฏ
Goal for this step

Open the console and find the first error line.

  • 1Open the developer console from the toolbar.
  • 2Errors are marked clearly and usually name the file and line.
  • 3Always fix the first error first; later ones are often caused by it.
๐Ÿง 
Knowledge Check
+15 XP
Which error should you fix first?
AThe last one
BThe first one
CA random one
2
๐Ÿงฏ
The Usual Suspects
Fast fixes
Locked
๐ŸŽฏ
Goal for this step

Recognise the five common mistakes.

  • 1Missing or extra bracket or quote.
  • 2A file ending in .js.txt instead of .js.
  • 3A plugin name that clashes with another plugin.
  • 4Calling something that does not exist (like a typo in park.postMsg).
  • 5Code running too often and slowing the game.
โœ๏ธ
Fill in the Blanks
+15 XP
A very common mistake is a file saved with a hidden . ending.
๐Ÿง 
Knowledge Check
+15 XP
Your plugin does nothing at all. First thing to check?
AThe file is .js and in the plugin folder
BThe park has enough guests
CThe weather
3
๐Ÿ›ก๏ธ
Guard Your Code
Never crash the game
Locked
๐ŸŽฏ
Goal for this step

Add a check so your code only acts when it is safe.

  • 1Before using something, check it exists: if (guest) { ... }.
  • 2Wrap risky sections in try/catch so one bad guest cannot break the whole plugin.
  • 3Fail quietly, never crash the park.
try {
  // risky work
} catch (e) {
  console.log("Skipped one: " + e.message);
}
โœ๏ธ
Fill in the Blanks
+15 XP
We wrap risky code in try / so the plugin keeps running.
๐Ÿง 
Knowledge Check
+15 XP
Why wrap risky code in try/catch?
ASo one error cannot break the whole plugin
BTo make it longer
CTo slow the game
4
โ™ป๏ธ
Reload Safely
Change, reload, repeat
Locked
๐ŸŽฏ
Goal for this step

Learn the quick test loop.

  • 1Save your file, then reload plugins from the plugin manager.
  • 2Watch the console for errors after each reload.
  • 3Keep changes small so you always know what caused a break.
โœ๏ธ
Fill in the Blanks
+15 XP
Keep each change so you know what caused any break.
๐Ÿง 
Knowledge Check
+15 XP
Why make one small change at a time?
ASo you know what caused a new bug
BIt looks nicer
CThe computer requires it
5
๐ŸŽจ
Write a Helper
Tidy code is easy code
Locked
๐ŸŽฏ
Goal for this step

Move repeated code into one helper function.

  • 1If you write the same lines twice, make a function.
  • 2Give it a clear name like rescueGuest(g).
  • 3Use it everywhere you need that job done.
โœ๏ธ
Fill in the Blanks
+15 XP
If you write the same lines twice, make a .
๐Ÿง 
Knowledge Check
+15 XP
Why pull repeated code into a function?
AFix it once, use it everywhere
BTo hide the code
CTo make the file bigger
๐ŸŽ‰โœจ๐Ÿ†๐ŸŽ‰
Rock Solid!
You can read the log, fix the common errors and keep the game safe. Now let us make it yours and share it.
0
Total XP
1
Level
0
Best Streak
0%
Accuracy
Next: Episode 8: Design and Share โ†’