Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

lealeelu
Copy link
Contributor

@lealeelu lealeelu commented Jun 26, 2016

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:

r: Hi there!
r/sad/right: I'm feeling sad today.
r/happy: but I have something that always cheers me up!
The destruction of my enemies!

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.

@lealeelu lealeelu force-pushed the simplescript branch 2 times, most recently from 8935f88 to a362e81 Compare June 26, 2016 18:34
@chrisgregan
Copy link
Contributor

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.:

s = sherlock
w = watson

-- comments!

s,angry,right: What are we doing here again?
w,annoyed,left: I don't know.
You're the one who called me out here.
s,bored: I can't be bothered to remember every appointment I arrange.
s,angry: That's why I have you.
w: ...

stage.hide(sherlock)
stage.hide(watson)
wait(1)

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?

@chrisgregan
Copy link
Contributor

Just added the preprocessor support for LuaEnvironment / LuaUtils if you want to hook into that.

@lealeelu
Copy link
Contributor Author

lealeelu commented Jun 27, 2016

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.
Another thing that I was wanting to add in later, but we can wait on it was a scene change. Basically, if I had a line like...

SCENE: train_station

it would turn into...

camera.changeToView(train_station)

Would that be possible?

@chrisgregan
Copy link
Contributor

Good stuff. For the scene change thing, you could just make a Lua utility function, e.g.

scene(train_station)

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:
SAY a,b,c: => say(a, b, c)
SCENE y: => scene(y)

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.

@chrisgregan
Copy link
Contributor

Btw I can help with the regex if you like

@lealeelu
Copy link
Contributor Author

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.

@lealeelu
Copy link
Contributor Author

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:
[ character_watson ] [ w ] [ Fungus.Character ]

in the script:

w,happy,left: la la la la la la la la la 

converts to:

say(w, "happy", "left", "la la la la la la la la la")

and have a lua function...

function say(character, mood, location, text) {
  --set character, stage function, and say function
}

@lealeelu
Copy link
Contributor Author

And the second+ arguments would be assumed to be strings.

@chrisgregan
Copy link
Contributor

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).

-- This transformation would work for any Lua function call
#wait 1
wait(1)

-- You can use a colon before the last parameter to indicate a long string
#say w, "happy", "left": La la la
say(w, "happy", "left", "La la la")

-- Leaving out the #say at the start is interpreted as a say command (special case)
w, "happy", "left": La la la
say(w, "happy", "left", "La la la")

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!

@lealeelu
Copy link
Contributor Author

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?

@chrisgregan
Copy link
Contributor

Yup, good idea!

@lealeelu
Copy link
Contributor Author

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.

@lealeelu
Copy link
Contributor Author

lealeelu commented Jun 29, 2016

Ok! here's another iteration!

SimpleScript blocks+keep strings (or single quotes?? Does lua do that?)
edit: it does http://stackoverflow.com/questions/17202195/difference-between-and-within-lua

--some standard lua
wait(1)

#say
  w: Hi!
  s,'angry','right': Don't "Hi!" me!
#end

#wait 2
stage.hide(s)
#say w: What was that for??

Everything in the script blocks are assumed to be scripted says

@chrisgregan
Copy link
Contributor

Interesting! Gives me another idea, but let's continue on the forum thread and see what others think.

@lealeelu
Copy link
Contributor Author

@lealeelu
Copy link
Contributor Author

lealeelu commented Jul 3, 2016

Moved to #510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants