What is this thing?
A recursive parser written in C# that converts strings written in a particular syntax into randomized content.
I made this because I was spending too much time writing individual methods to do the same thing. I made it during #ProcJam 2016 specifically to be used in my app the Tartle RPG Tool. The parser stands on its on as being a useful thing and it is not Unity specific.
How to use it:
It is a DLL file. Drop it into you project's folder and import it inside your code like this:
then call it like this:
RPGParser.ParseString("RPG Parser is [awesome|cool|[the best|the worst]]");
anything within [...] will be parsed, including nested brackets like this: [...[..[..]]]
within the brackets options delineated by '|' will be picked from randomly.
the final result is returned as a string.
- I saw a [frog|robot|lizard] eating a [biscuit|hotdog] -> I saw a robot eating a hotdog
- Do you [enjoy|hate] being attacked by [lobsters|cats with [hammers|forks]] -> Do you enjoy being attacked by cats with forks
Want to try it out?
try it here on this page :)
also note that you don't have to wrap your sentence in string quotes above. You only do that from your source code.
Want the source code?
Currently the parser handles the patterns outlined above but it doesn't do everything I want it to be capable of. I plan on updating it to allow saving choices in-line such that the parser remembers the random picks that it makes.
Click download now to get access to the following files:
Leave a comment
Log in with your itch.io account to leave a comment.