![]() |
RigsofRods
2023.09
Soft-body Physics Simulation
|
We have multiple formats with very similar syntax: rig def (truck), odef, tobj, race, addonpart, dashboard. This parser supports all these formats and adds new features:
The bundled 'demo_script.as' showcases them. There's a button "View document" (changes to "Close document" after pressing) which opens separate window with a syntax highlighted truck file.
script API:
GENERIC_DOCUMENT_OPTION_*
) - This is important to cover the many quirks that our pre-existing formats have, see subsections below.Tips to retrieve live documents:
To test, open game console and say loadscript demo_script.as
.
This is the most frequented file type, also known as 'truck file format', see reference documentation.
Note the option 'ALLOW_NAKED_STRINGS' must be on at all times, because otherwise the parser requires all strings to be in quotes. Also see these special cases:
forset
, single node numbers are parsed as NUMBER. Node ranges are not valid numbers so they decay to STRINGs. axle
and interaxle
keyword have a quirky abc(1 2)
syntax. I added an option 'PARENTHESES_CAPTURE_SPACES' which make the whole expression parse as one string. Originally I only planned to cover fileformats which are similar to each other (truck, odef, tobj) but now I wanted the demo script to display TOBJ files too, but I didn't want to clog the Terrain API with getFileWhatever()
funcs. I wanted to use the GenericDocument
to parse the TERRN2 file, get TOBJ filenames from there and parse those as well. It turned out to be pretty straightforward, the tokenizer is already robust so it could take a few extra options.
This is an INI-like format so it needs these special options: "ALLOW_HASH_COMMENTS", "ALLOW_SEPARATOR_EQUALS", "ALLOW_BRACED_KEYWORDS" and of course "ALLOW_NAKED_STRINGS".
Needs just "ALLOW_NAKED_STRINGS" and "ALLOW_SLASH_COMMENTS".
This page was archived from GitHub PR #2953.