ScriptEditor.get_current_script() is return Script object, and that it. ScriptEditor.goto_line() will go to line, not return current line. If it is not possible in GDScript, is it possible in GDNative C++?

Off-topic, while I investigate engine source code, I found

return script != nullptr ? script : nullptr;

Is not it same as this?

return script;

Try this function:

func debug(text):
    var frame = get_stack()[1]
    print("%30s:%-4d %s" % [frame.source.get_file(), frame.line, text])

Yeah, those lines evaluate to the same thing, but the first line is more clear that the value can be nullptr.

@cybereality I state ScriptEditor for this reason, get current line that cursor currently in in Godot build-in IDE in tool plugin.

BTW, still that print debug function look useful to me.

2 years later