New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SimpleScript option #505
Conversation
8935f88
to
a362e81
Compare
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? |
Just added the preprocessor support for LuaEnvironment / LuaUtils if you want to hook into that. |
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. SCENE: train_station it would turn into... camera.changeToView(train_station) 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. |
Btw I can help with the regex if you like |
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 luabindings: in the script:
converts to:
and have a lua function...
|
And the second+ arguments would be assumed to be strings. |
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! |
I like where this is headed. I don't mind bouncing ideas back and forth. Maybe we should mention this convo on the forums and get other opinions too? |
Yup, good idea! |
Now I'm kind of back tracking. I don't want to confuse new users to Lua by conflicting syntax. My original intention was to have this be a logic-less language for pure dialog previews. I threw in the extra lua code blocks to be convenient. |
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 |
Interesting! Gives me another idea, but let's continue on the forum thread and see what others think. |
Continued on the forums: http://fungusgames.com/forum/#!/fungus-3-beta:simpler-dialog-in-lua |
Moved to #510 |
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.