A function of this sort would be most convenient (but modifying studio stuff is okay with me too)
myPrint(string msg,Instance script,Number line)
such that in the studio output when I click on a print statement it opens up a script of my choice with the specified line number instead of the line of the script the print is outputted from?
The closest way of doing this I can think of is to use Plugin:OpenScript. You would make an output window plugin using LogService which lets you open scripts using your custom way of doing it.
I too want this. I have a custom print function which does some behind-the-scenes magic to make it easier to use, but I tragically lose the click-print-statement-to-visit-code functionality. Still worth the tradeoff, but it would be best to have both.
Mostly cast everything to a string for some printf style printing.
My loggers can also be turned on/off, because I like debug-level logs when I’m, well, debugging, but I don’t want them to spit my garbage into the output window when I deploy.
And I have special handlers to print tables. This is super convenient for debugging.
I also made a request like this:
One thing I didn’t think of is that getting the script/line number is somewhat difficult. A parameter like error’s backtrace level would be way more usable in my opinion.
You can use the debug.traceback() function to print out the stack trace. In studio it links up to a script so you can click on the message and it will open the script.
print(debug.traceback()) does add something to the output, and is clickable though.
Check this code out for an example:
local throw = function(...) warn(debug.traceback(...)) end
throw("user EmeraldSlash doesn't have a dominus")
Which actually prints…
user EmeraldSlash doesn’t have a dominus
Stack Begin
Script ‘ServerScriptService.Script’ Line 1 - local throw
Script ‘ServerScriptService.Script’ Line 3
Stack End
But yeah, now that I think about it, it doesn’t fix your issue. It’s the closest you’ll get in Roblox, though.
I have a plugin that, through the press of a button, beautifies all of the scripts in my game
When it beautifies a script, I want it to output that script’s path and I want that clicking on this text will open up that script for me
So I don’t care about a stack trace (which anyways does not exist here too because the script that is being operated on is not running)
Ah, I understand. I think the only way you could do that would be using a custom output plugin, which has already been suggested. Sorry for wasting your time
Not possible. You’ll need a custom implementation to handle this. You could also write a Feature Request for this to be made available as a tool for developers.