To be more clear, the hard part is the “path”. It’s basically your movie script (this happened, and then this, and then etc) but its calling lines from your script file rather than just having the text itself (saving you tons of localization headaches, and letting you or someone else write the script seperately without breaking your lua code)
- local path = {}
- path[1] = { script=31, leftActor=1, rightActor=2, a=32, b=33, c=34}
- return path
In this case, the path file starts off as a table, and ends as one. Each numeric entry is a “moment” or scene, so to speak. For example, in this example, “moment 1”, the game will use script 31, show actors 1 and 2 onscreen, and at the end offer three choices; to go to script 32, 33, or 34.
But to “flow” time you need to know what scene to goto next too, so you could add that. Here’s what a normal entry might look like:
- path[2] = { script=27, leftActor=1, rightActor=2, next=3 }
Play script 27, show actors 1 and 2…and then goto path[3] when done.
The basic theory is that your scene (as in storyboard/composer) doesn’t know anything about this. Every time you enter the scene, you load some part of the story, say like this: story:load( next ) which would load path 2 and all of the stuff mentioned above. ‘next’, in this case, is a variable you pass (storyboard and composer both let you pass in parameters when you enter a scene).
Another option (instead of params) is to use a globals file. This is a great way to manage savegames and keep track of progress.
- – globals.lua
- local globals = {}
- globals.name = “George”
- globals.currentScene = 1
- return globals
Just include that where you need it. Then you can call ‘globals.currentScene’ instead of params.next, and just update it as necessary.
Anyway, to answer your question, no, don’t duplicate your controllers. Theoretically you can get away with even a single storyboard scene and reloading it where appropriate. You just need to simplify the complexity by building multiple levels of lua files (controllers) to handle it.
ie:
/localization/en.lua – english script
script.lua – script controller, calls script from active localization using script.get()
path.lua – contains the path (game flow)
story.lua – path controller, uses path.get() to fetch the path step and then can use that to grab the right text from script.get()