How to set a custom script [with line number] to open when you click on a print statement in studio output

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?

4 Likes

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’m hoping for a way that uses the studio output

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.

1 Like

What kind of magic do you do?

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.

1 Like

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.

debug.traceback() returns a string, it doesn’t output anything, so it isn’t very helpful for this

also for my scenario I am operating on the script i want to reference to (such as beautifying it) so it won’t be running at all

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.

2 Likes

if you click it it goes to where the warn() is
i dont understand how it does anything useful

It shows you the traceback, though, so you can find the relevant place where the root of the error is.

sure but idc about that

Can you rewrite what you quoted? I can’t really understand it sorry

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)

1 Like

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 :frowning:

lol dont apologize

1 Like

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.