godot_parser
godot_parser copied to clipboard
Add support for typed arrays and match Godot 4 formatting.
I have been using this project to parse my .tscn files on Godot 4, which required some updates here to make things work:
- Now
.tscnfiles seem to be saved without spaces around args, soExtResource("7")instead ofExtResource( "7" ) - My files have properties like
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(4, 0, 3, 5)])that did not seem to be accounted for in the existing grammar, so I had to add new rules invalues.pyand aGDTypedArrayclass to parse these new types into. - Not all objects have arguments (e.g.,
PackedStringArray()), so made the arg list forobj_typeoptional
This isn't well-tested, but empirically, it works for my purposes, so feel free to adapt as you see fit! Even if this isn't upstreamed, perhaps it will help someone else.
I'm happy to merge this! Would just require:
- A test for the typed arrays in test_parser.py
- A simple test for typed arrays in test_objects.py
- Fix the failing tests
I think that the CI has rotted a bit in general. I'll see if I can get it back to a green state on master
@stevearc if you can get CI healthy on master, then I'm happy to add tests!
@bolinfest builds are working on master again