godot-escoria / escoria-issues

Central Escoria issue tracker
3 stars 0 forks source link

Validate all objects referenced in scripts at parsing stage #167

Open balloonpopper opened 2 years ago

balloonpopper commented 2 years ago

Is your feature request related to a problem? Please describe. I just had an error come up working on room 10 where the "walk_block" command was used. When the script executed it was trying to run this command :

walk_block player accept_input_location

except that the location "accept_input_location" didn't exist in my version of the room, so when Escoria got to that line in the script it errored with

Errors in file walk_block: invalid second object
Object with global id accept_input_location not found

I'd like to put forward a suggestion that once all the room scripts have been parsed, there's a second parsing round that checks the validity of all the objects. If Escoria knows the content of the scripts, and knows all the ESCitems in the room, is there a reason it can't check that the scripts are only referencing objects that exist, and errors when it finds an invalid one?

Checking this automatically has the potential to save a lot of time tracking down bugs in scripts.

Describe the solution you'd like As above

Describe alternatives you've considered None

Additional context I appreciate this might not be feasible for multiple reasons

dploeger commented 2 years ago

Hm. IMHO this is okay as it is currently. The error message is verbose enough to track down the wrong script.

@StraToN @BHSDuncan what's your opinion?

balloonpopper commented 2 years ago

Currently testing every permutation of your room's scripts is the only way to find spelling mistakes. The problem is that with complicated rooms, testing every permutation of scripts and item states will be very time consuming. That all becomes unnecessary if Escoria immediately picks up any spelling mistakes.

BHSDuncan commented 2 years ago

Yeah, there are tradeoffs. In a full-blown editor, this would be a great feature. Maybe we could make a plug-in or tool script to do this on a room-by-room basis from the IDE? Or perhaps an optional compile-time check?

But as we've seen, there are known limits to what the current parser/Escoria compiler can (and should) do. No reason we can't discuss the future, though.