My current WIP requires a stupid amount of debug text for me to make sure everything is working correctly. I would, however, also like to turn OFF the debug text from time to time.
I know a couple ways to handle this:
check my global Boolean variable “debug state” every time I want to spit out another debug message
set a global text variable “debug text” every time I want to spit out another message, then call an activity that will message debug text iff “debug state” is true
So if worst comes to worst, I have options. But enclosing every debugging message in an “if” statement is three lines of code, and setting a global text variable is two, and I’d ideally like to drop it to one to make my code more readable.
I know I can do something like this with an activity:
carry out the analysing activity with the pitchblende;
Is there a way to have an activity take a text input, like this?
carry out the debug messaging activity with "This is some debug text";
I use compiler definitions for this sort of thing. They have the advantage of disappearing from the game entirely when you’re not using them, because the code between #ifdef’s is not compiled into the file if the option is undefined. I usually use three-liners so that every trace of the debug code is evaporated from the compiled game, but you could use Juhana’s method too–it trades a function call and the creation of a text or indexed text that otherwise wouldn’t be required for ease of use and cleanliness of code:
[code]Use custom debugging translates as (- Constant CUSTOM_DEBUG; -)
[Use custom debugging.]
To #if utilizing custom debugging:
(- #ifdef CUSTOM_DEBUG; -)
To #endif:
(- #endif; -)
To debug (T - an indexed text): #if utilizing custom debugging;
say T; #endif.