Visual Novel using Corona

Hello everyone,

Does anyone know of a good tutorial for making visual novels using Corona? (Basically I’m interested in the dialog scenes where two characters talk, the changing of the background images and character expressions) I have been wondering how to code this and was unable to find a guide of any sorts after Googling for a long time. I would also like to know how to organize and store the dialogues available for the various chapters of the game.

Any sort of help or advice will be very appreciated. :smiley:

Thanks for reading and have a great day!

This is actually a huge topic, and something I’ve considered building a code package for. To be honest, if you just want to write visual novels and don’t really want to code, you should consider tools like Ren’Py and so on. Where coding (and Corona) makes more sense is a) you want to focus on coding and b) you really want the built in iOS/Android export systems.

From a high level though, you would need a few things:

  1. A character controller. Something with functions to call a specific character and then change their pose.

ie: local leftGuy = character.make(“Jim”, “angry”, “left”)

  1. A background controller. Same deal; something to spawn/change backgrounds.

  2. A script format. This is the hardest part. You would need to come up with a table design that can branch.

ie: [lua]local path = {}

path[1] = { script=31, leftActor=1, rightActor=2, a=32, b=33, c=34}

[/lua]

That’s a basic example, but the idea is that on step 1, you display script 31, and the a/b/c options are scripts 32,33,34. leftActor/RightActor determine which characters to use. From there, you need…

  1. Localization files. You can make it easier if you go english only, but the idea is that you would have a lua file that’s one big table, like

[lua]local script = {}

script[1] = “So we went to the bakery today and blah blah blah”

script[2] = “What a disaster!”

return script[/lua]

You could go even further and try to read XML text files, CSV, or something, but that’s even more work.

Hello,

Firstly, thank you for the reply! It’s open my eyes to a few alternatives possible to handle this. :smiley: I’ve considered using XML but yea it is gonna be more work lol

Haha, well, I asked it in a visual novel sort of way but I’m planning to code an item catching game that has a story plot to go with it. That’s why I chose to go with Corona.

Back on topic, would you have any recommendations on how to trigger the story events at certain times? Do I plot out the whole thing and call the story events via functions? i.e. When the player receives an item, an NPC will butt in to tell them about the item. What would be a good way to store the player’s progress in the plot?

Thanks again!

ps. I like your icon hahaha

The problem with XML or other alts is that you’ll need to find or write a language processor to convert the data from those files into usable Lua code. Even if you grab an already available converter it’s just a pain to work with, especially if you’re already having your hands full with Lua.

I absolutely would plot things out, or at least setup your item pickup code to look for a situation to call. Code on mobile platforms is pretty Object Oriented in that you want less of a ‘script’ and more of a bunch of co-operating bits of code.

Storing progress is best done with code from the code exchange here. I like GGdata but DMC autostore also works well. Either one can be easily setup to save data to disk whenever you like. 

Thanks again for the reply, richard! I will keep your advice in mind. Have a nice day :slight_smile:

@richard I need a little bit help as well, I am also working on a Visual Novel project and decided to go with Corona as its engine aswell

The story will be divided in arcs (4) and each arc will have chapters. Each arc/chapter will have around 300 pages~ average.

The layering of the scene is like this :

  • -Background Image
  • -Character sprite image (left or right or both if 2 chars)
  • -Dialogue background image (just a placeholder to show convestation beween characters)
  • -Dialouges (actual conversations shown above the Dail.BG)

All these things will always be present per story page, and aside these sometimes 2-3 buttons will show to ask for user choice which will change how the story unfolds.

A small minigame might also be present using the gestures of touch devices but yeah that will reside in its own scene for the sake of it.

I am a bit confused how to manage hundreds of dialogues, character sprites and background arts within a single scene and change them using touch event on the dialouge_BG actor.

 

Your approach for creating character and BG controller seems great as I can just create function which will return proper image to be used for that character, same thing for dialogue aswell with something like dialogue.make(“arc1”, “scene3”, “line31”)

I didnt got your explanation for that creating a script controller though, can you please explain it a bit more ?

The only thing I am confused is if I can handle atleast 1 story arc by using 1 scene controller using loops or tap events (tap reloads the controller) or will I need to create 1 scene controller per page/chapter and jump from one scene to another per tap

@zenkyren sorry my intention isn’t to hijack your thread but rather then creating another thread for same question as yours, I thought it will be better to ask @richard in this thread itself for future references

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)

  1. local path = {}
  2. path[1] = { script=31, leftActor=1, rightActor=2, a=32, b=33, c=34}
  3. 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:

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

  1. – globals.lua
  2. local globals = {}
  3. globals.name = “George”
  4. globals.currentScene = 1
  5. 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()

I’m actually wanting to program a visual novel engine as well and i just saw your post today. Would you be willing to collaborate on a project together richard9?

Wow this is really weird, I was checking this topic for your reply each 2 hours the day I posted my comment but after that I didn’t got any notifications on mail for any new replies. Do we need to manually subscribe to a thread to get mails on new replies ? Is there any option to auto-follow whenever I reply to a thread ?

So by script you mean script as in the outline of story (dialouges etc.) or the code script that determines whats happening in a scene.

Like the example you gave, script 31 loads a xx background image, after 2 secs adds chara 1 on left, after 3 secs adds chara 2 on right, plays audio file etc. Is that what you meant by script ? Aka creating common code for scenes depending on what will happen in it ? 1 Script for dialouge scenes, 1 script for any cutscenes, 1 for any mini events, 1 when the user needs to enter a choice which will determine next scene etc., is it like that ?

Sorry that I might be a bit confused, as am not sure if script is what you mean in general as just a step to create a game or if its something related and specific to lua itself (like some function or controller etc.)

mikey0: Maybe if it’s a github thing? My time is pretty restricted though, tempted to just build the framework myself quickly but with a baby sometimes I just am too busy!

shub: script = ie: movie script. Lua is a programming language is far as I’m concerned and anyone calling it scripting can flog off. :wink:  So you should basically have the:

path: the ‘code’, controlling how the game progresses

script: the ‘text’

actor: the ‘people’ who appear onscreen

and so on…terminology is usually the first thing that gets put in the fire when working on a framework!

But yes, common code means doing similar things once. I’d probably have a file that specifically handles showing multiple-choice dialogue windows, for instance. And another that shields you from making audio calls directly. Anything you have to do more than once can probably be given a lua file somewhere.

Ah I see, you meant the dialouges, I am still feeling a bit reserved to go for Corona since I have always worked in C#, Java, PHP, ObjC and Lua just gives me a weird feeling.

I think for the cutscenes and special events after specific scenes, it will be something like if(path==31) or if(script==31) (ofc in LUA code) and then perform the custom mini-event like playing audio, displaying video or w/e.

2 small things I would like to ask you last are :

Do Corona has a GUI interface builder ? I don’t have problem setting margins and X-Y manually but a GUI certainly helps a lot (dibs on XCode Interface builder). And do Corona has any good IDE like Xcode (for Objc), VS (for .net) or Eclipse (for java)

Do the textview or textbox element in corona provides ability to scroll text ?

Again, really appreciate you taking your time to answer my doubts and help me getting one step closer to try out Corona.

Corona doesn’t have an interface builder. But you have a ton of flexibility when working with GUI’s. Check out the API. Composer for changing scenes, Widgets for UI, and Text/DisplayObjects for everything else pretty much.
As far as IDE you can use Xcode for Corona SDK. I would personally recommend Outlaw if you’re on a Mac. If not don’t use it because the Windows version won’t even run.

Richard9 I’m going to put it on GitHub once i have a decent framework set up. Congrats on the baby. If you can build the framework quickly that would be really helpful. I figured doing a collab project would be easier though since they say 2 heads are better then one.

I downloaded Corona Editor and LuaGlider for now, will take a look at Outlaw since I have a macbook too.

I am still a bit worried how UI elements can be exactly arrange and positioned without calculating their exact X-Y origins, not to mention this is specially difficult to do if you use particle system

However I might be wrong as I have yet to use Lua and check the APIs, my comments are from my exp. of creating a UI by using code for Objc only

Read the API, there’s a ton of ways to do that. display.contentWidth and display.contentHeight gets the correct sizes of the screen. however, depending on how you want to lay things out, it might be better to put in actual pixel coordinates.

Yeah I just use SublimeText3 with the Corona Editor plugin. Works great. I suppose if you want a serious debugger or IDE stuff like Outlaw/Glider/etc might be more relevant but ST3 is literally an Apple-grade interface. 

And generally speaking you should be developing somewhat resolution-agnostic, which means most of your X/Y code is going to be variable fractions rather than outright placement. (Although Corona builds so fast neither method is particularly difficult)

mikey, I’ll give it some thought. I have a contract to push through right now though so it all depends how much non-baby time appears during the day.

I completely understand. Hopefully you get some time. But either way good with the new baby. :slight_smile:
I actually am working from the beginning. Setting up an easy to use menu as a base. Then going from there, I’m going to work on saving and loading. After that, then I’m going to figure out how to set up the actors, scripts, etc

This is actually a huge topic, and something I’ve considered building a code package for. To be honest, if you just want to write visual novels and don’t really want to code, you should consider tools like Ren’Py and so on. Where coding (and Corona) makes more sense is a) you want to focus on coding and b) you really want the built in iOS/Android export systems.

From a high level though, you would need a few things:

  1. A character controller. Something with functions to call a specific character and then change their pose.

ie: local leftGuy = character.make(“Jim”, “angry”, “left”)

  1. A background controller. Same deal; something to spawn/change backgrounds.

  2. A script format. This is the hardest part. You would need to come up with a table design that can branch.

ie: [lua]local path = {}

path[1] = { script=31, leftActor=1, rightActor=2, a=32, b=33, c=34}

[/lua]

That’s a basic example, but the idea is that on step 1, you display script 31, and the a/b/c options are scripts 32,33,34. leftActor/RightActor determine which characters to use. From there, you need…

  1. Localization files. You can make it easier if you go english only, but the idea is that you would have a lua file that’s one big table, like

[lua]local script = {}

script[1] = “So we went to the bakery today and blah blah blah”

script[2] = “What a disaster!”

return script[/lua]

You could go even further and try to read XML text files, CSV, or something, but that’s even more work.

Hello,

Firstly, thank you for the reply! It’s open my eyes to a few alternatives possible to handle this. :smiley: I’ve considered using XML but yea it is gonna be more work lol

Haha, well, I asked it in a visual novel sort of way but I’m planning to code an item catching game that has a story plot to go with it. That’s why I chose to go with Corona.

Back on topic, would you have any recommendations on how to trigger the story events at certain times? Do I plot out the whole thing and call the story events via functions? i.e. When the player receives an item, an NPC will butt in to tell them about the item. What would be a good way to store the player’s progress in the plot?

Thanks again!

ps. I like your icon hahaha

The problem with XML or other alts is that you’ll need to find or write a language processor to convert the data from those files into usable Lua code. Even if you grab an already available converter it’s just a pain to work with, especially if you’re already having your hands full with Lua.

I absolutely would plot things out, or at least setup your item pickup code to look for a situation to call. Code on mobile platforms is pretty Object Oriented in that you want less of a ‘script’ and more of a bunch of co-operating bits of code.

Storing progress is best done with code from the code exchange here. I like GGdata but DMC autostore also works well. Either one can be easily setup to save data to disk whenever you like. 

Thanks again for the reply, richard! I will keep your advice in mind. Have a nice day :slight_smile: