Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add SimpleScript option #505
This is just a start to an idea that I think other people might find useful. It definitely needs some work.
In simplescript, most lines will look like this:
You can add lines of lua code by escaping using ``` like you would in markdown.
I took a look at mustache but I couldn't get what I wanted from it. I didn't want to involve my writers in using json.
I think this would be a great addition, would really speed up the writing process!
From an architecture perspective, I'd like to make this more of a core feature of FungusLua rather than a separate command. If you want to run your script in a LuaScript component you would expect to be able to use the simplescript syntax there too.
Regarding the syntax itself, we should aim to keep the style consistent with Lua, e.g.:
It should be possible to mix simplescript in with Lua freely without special code blocks, the lines with special markup on them just expand into more Lua.
To get this to work generically, I'll add an IPreprocessor interface to LuaEnvironment, and have LuaUtils implement it. LuaEnvironment will run all scripts through the preprocessor before passing them to MoonSharp for execution. That way every script that goes through FungusLua can use this syntax, and we can extend it in the future.
Sorry for all the proposed changes, but I think this could be a really powerful feature so let's nail it!
What do you think?
Ya! Nail it!
I think I see what I should do with the Preprocessor. I'll have to tinker around with it when I get home.
it would turn into...
Would that be possible?
Good stuff. For the scene change thing, you could just make a Lua utility function, e.g.
Same amount of typing, no code changes needed to support it.
Although that said, this gives me an idea. What if the preprocessor always did this:
Where SAY and SCENE can be any string and c includes everything up to the next blank line. It'd basically be a generic way to write dialog & other commands without using brackets all the time.
Ohhhhh! yeah that would be pretty good having the processing be more generic like that. I'll think about it.
I figured the regex stuff out, just took me a little time to relearn the syntax. The match group stuff is super handy. I used it in the latest commit.
can I be picky and have it be that if the first \w matches an existing character key in luabindings, it is automatically a say function?
in the script:
and have a lua function...
Hmmm... not sure about checking the LuaBindings to infer the meaning of a line of script. Feels like it could be brittle and maybe give confusing error messages when things aren't set up correctly? I'd prefer a simple, clear transformation that only depends on the text in the script, even if it needs a bit more markup. That way it could work for any Lua function call which would be super powerful.
Ok, here's another idea for a format using a special leading # character to indicate a line that should be transformed. For this to work we'd need to put string parameters in quotes, though I really like the idea of assuming that the last parameter after a colon is a long string (and no quotes needed).
Hope you don't mind bouncing ideas for this format around a bit more. Once we implement the format it'll be hard to change so worth getting it right I think!
Ok! here's another iteration!
SimpleScript blocks+keep strings (or single quotes?? Does lua do that?)
Everything in the script blocks are assumed to be scripted says
Continued on the forums: http://fungusgames.com/forum/#!/fungus-3-beta:simpler-dialog-in-lua