Hi
If you have statements like
print("var x is " .. x)
in your code, should you remove them or comment them out before you build for distribution, or doesn’t it matter?
thanks,
david
Hi
If you have statements like
print("var x is " .. x)
in your code, should you remove them or comment them out before you build for distribution, or doesn’t it matter?
thanks,
david
Before distribution just do this
print = function() end
That will make the print function do nothing. Then after release, uncomment the aforementioned line and your good to go.
Much quicker than all that commenting out
Do I just write that once, at the top of the program?
thanks.
Correct, at the top of main.lua will do nicely
Just thought I’d add something to this, since it is in the newbie forum so some people might not know.
As @euphoriacorona mentioned, you can overwrite the print statement to make it do nothing. However you can also overwrite it to make it do extra things if you want.
E.g.
origPrint = print print = function(string) origPrint(storyboard.getCurrentSceneName()..string) end
Would change the print function to add the current storyboard scene name to the start of every print statement. Obviously you could add whatever you wanted to the print statement.
Then when you are ready to release the app, just comment out the inside of the print function so that it is the same as euphoriacorona’s example.
You may notice that the original print function is cached to “origPrint” so if you want you can still call the regular print function by calling origPrint(“some text”), but I don’t see there would be much point unless you really need to.
Someone did also post an example once where each print statement would print out the lua file + line number that it was called from, but it never worked for me.
Before distribution just do this
print = function() end
That will make the print function do nothing. Then after release, uncomment the aforementioned line and your good to go.
Much quicker than all that commenting out
Do I just write that once, at the top of the program?
thanks.
Correct, at the top of main.lua will do nicely
Just thought I’d add something to this, since it is in the newbie forum so some people might not know.
As @euphoriacorona mentioned, you can overwrite the print statement to make it do nothing. However you can also overwrite it to make it do extra things if you want.
E.g.
origPrint = print print = function(string) origPrint(storyboard.getCurrentSceneName()..string) end
Would change the print function to add the current storyboard scene name to the start of every print statement. Obviously you could add whatever you wanted to the print statement.
Then when you are ready to release the app, just comment out the inside of the print function so that it is the same as euphoriacorona’s example.
You may notice that the original print function is cached to “origPrint” so if you want you can still call the regular print function by calling origPrint(“some text”), but I don’t see there would be much point unless you really need to.
Someone did also post an example once where each print statement would print out the lua file + line number that it was called from, but it never worked for me.