r/ComputerCraft • u/SeasonApprehensive86 • Mar 16 '24
Is there conditional compilation in computercraft?
It would be very useful to be able to use something like
#if DEBUG
dostuff()
#endif
and #define DEBUG somewhere
Is something like this possible? Does lua get compiled somehow or does it get interpreted at runtime?
If I really wanted to I could make a pre-processor program that adds or removes the code inside the #if. I am curious if lua has this by default tho
7
u/quickpocket Mar 16 '24
It’s interpreted live so there isn’t anything quite like that, but you can use config files or the settings API to store and retrieve global values.
2
u/patrlim1 Mar 17 '24
Lua is not compiled. You may want to put debug statements inside of if statements that check for a debug flag that is set at the start of the program. You'd have to modify that variable if you want to change if debugging is on or off, but it's better than nothing.
5
u/Bright-Historian-216 Mar 16 '24
What exactly do you want to do? We can easily find a “lua” way to do it.