MovingBlocks / Terasology

Terasology - open source voxel world
http://terasology.org
Apache License 2.0
3.67k stars 1.34k forks source link

No indication of Syntax Error in BehaviourTree #5099

Open Jacob-Rueckert opened 1 year ago

Jacob-Rueckert commented 1 year ago

Motivation

I feel confused when there is no syntax error shown but the game crashes because of one. Twice I had a comma after the last child of a selector which gave a NullPointerException. But it crashed on two different spots in the engine code the first in org/terasology/engine/logic/behavior/DefaultBehaviorTreeRunner.java:37 and the other in org/terasology/engine/logic/behavior/core/SelectorNode.java:23

Proposal

It would be wounderful if there was a indicator to tell you the syntax error like a red mark in the IDE.

Alternatives

A message in the console or a hard crash on behaviour Tree load would be helpful.

Cervator commented 1 year ago

This is a very good topic that recurs fairly regularly and I too badly want this :-)

It was actually a GSOC idea for a few years - #1402 has more details and related ideas!

jdrueckert commented 1 year ago

In this case it's not even logged and the behavior tree is actually parsed, so we even would have a point in the code to do some kind of syntax check. As behavior trees are (especially considering the in-game behavior tree editor is broken atm) nothing that would be expected to change except in development, I think we can even create a hard crash here. In the particular example the child is even created as null by the behavior tree parser, so it deliberately "decides" not to complain about it although there's not reasonable use case for having a null child.

If we introduce a hard crash of course eventually it would be great if a hard crash like that on world start wouldn't actually crash all of Terasology but only abort and clean up (as in roll back) the world start and bring the player back to the main menu. Then they could fix the tree and just try starting new world again, which would highly accelerate the development feedback cycle.