i want some print statements to be displayed only when a variable is true, the method i think of right away is doing:
if var then print('something') end
as you can see, this gets a a little annoying when you have like 4000 lines of code, is there a way to disable/ enable print statements through a variable without having to add the if statements??
I don’t know if I understood you’re question right (I apologize in advance if I did), but try formatting the in then statement like this so that you can fit the rest of the code.
if var then
print('something')
--lines of code
end
No need to modify any of your existing code, or create your own print with a slightly different name, simply override the print global by shoving in your own copy which respects your toggle.
local DEBUG_PRINTS = true
local oldprint = print
local function print(message)
if DEBUG_PRINTS then
oldprint(message)
end
end
print("hello")