Debugging

From The Stardew Modding Wiki
Jump to navigation Jump to search

No matter how simple or clear your code is, somehow there's always something that goes wrong when you first try to run it. Don't worry, that happens to literally every programmer ever. On this page you'll find some tips and other helpful suggestions to try when debugging your mod.

Check your formatting[edit | edit source | hide | hide all]

If your mod uses json files, you can try running them through https://smapi.io/json for a quick check of your brackets and commas. It won't catch everything, but it's faster than loading SMAPI and waiting for red text to appear.

Use Debug Mode[edit | edit source | hide]

Can't figure out what tile you're on or what event is happening? Want to quickly test conditions? Debug Mode is the mod for you!

Ask the community[edit | edit source | hide]

Stardew Valley has a wonderful community of fellow modders. Get links to the Discord and other hangouts at the official wiki.

Talk to a duck[edit | edit source | hide]

No, really! Rubber Duck Debugging is a real thing. Basically, you explain your code to a rubber duck, or your cat, or your mom, or anything/anyone willing to listen. As you do, you will often figure out the problem yourself.

Break it down into steps[edit | edit source | hide]

If you're having trouble with a process, break it down. Don't worry about making sure every aspect of your new crop is right, start by just seeing if you can buy the seeds. If you can't buy the seeds, try adding some Vanilla seeds and seeing if that works. Use giant red rectangles as placeholders to see if your art is doing something; they'll be easy to spot even if they got hidden somehow.

Test multiple conditions at once[edit | edit source | hide]

Can't get an event to trigger? Try creating multiple instances of a short event, such as Clint stopping by the farmhouse door in the morning, and setting the conditions for each one slightly differently. If you see the Clint and Shane events you created but not the Alex event, now you know the problem is in the trigger you used there. Include at least one event that should work absolutely no matter what to make sure your code is working at all.

Got a tip? Add it here or link to an article describing it!