Jump to content

[Quick Tip] Don't forget about your debug code


CarlZalph
 Share

Recommended Posts

For those trying to make a mod and are experiencing issues, sometimes it's easier and quicker to have random print statements everywhere to help show you at what point some assumption in your code goes wrong.

An example is a long series of function calls or some if/then/else chains that has some heavy expression evaluation.  Break it up into multiple lines if possible and shove print statements in between to help diagnose things.

 

However, doing so will require you to remove the lines so the player's console logs don't get spammed up when having your mod installed.

So to help you keep your mod clean of these expressions, put a comment after each line that should be removed that reads:

-- sponge

Why sponge?  A good doctor makes sure to check for all of their sponges before sewing their patient back up.  A good mod maker ought to do the same by cleaning up after they're done but before stitching up the mod by removing the debug code and then shipping it off to other users.

It's not a generic "TODO" or "HACK" but something unique that tells you to clean your sponges, and it's easy to 'find in files' for the word.

 

Getting into the habit of doing this will decrease the odds of something like this from happening in your shipped mods:

 

Edited by CarlZalph
  • Like 5
  • Sanity 1
  • GL Happy 1
  • Potato Cup 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...