godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.29k stars 21.05k forks source link

Suggestion: Do not halt if Script.reload() fails and return a ScriptParseResult object #20421

Closed Kinsman closed 3 years ago

Kinsman commented 6 years ago

Godot version: 3.0.2

Issue description: I'm writing an event scripting engine in GDScript, suitable for visual novels or similar games. I had a thought that instead of interpreting line-by-line, I could write code that would transform what I wrote into GDScript (with post-processing that could have the code, for instance, block for input after certain lines) and attach it as a script to my game.

The documentation says that Script.reload() will return an error code. It can return an OK code, but Godot halts if there's a parsing error. If I'm using the editor, I can read what the error was; but if I or a modder was running my game and trying to edit a script, they'd need to have their script either be perfect, or crash the game without explanation.

Could you please add an extra argument where Godot will not halt if Script.reload() fails - and instead of an Error code, return a "ScriptParseResult" object, similar in structure to JSONParseResult?

Thank you.

zx013 commented 3 years ago

I am also looking forward to this feature. I expect to edit the gdscript on Android, so Script.reload() halt which will cause me some troubles. This makes it difficult for me to locate script errors.

Calinou commented 3 years ago

Take a look at how GDScript Online handles script loading at run-time in an exported project. That said, if you want proper error reporting, being able to use get_stack() in an exported project is an entirely separate issue.


Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.

The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.

If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!

zx013 commented 3 years ago

I went to see the source code of reload in godot3.3 and tested it. I found that Script.reload will call the debug_break_parse function to halt only when debugging. When the project is exported, reload will return the correct error value.