Gian Saß

Visual Novel Engine: Concept

· Gian Sass

Visual Novels are a cool type of game and also something nice to have programmed. Something that makes it easy for a non-engineer to write a couple of Lua code that makes his Visual Novel run on all platforms. I thought this was a nice exercise for a semi-large project that could be done in a reasonable amount of time.

Concept

Like any Game Engine, there needs to be some core connection between the Low Level Part (C++) and the High Level Part (Lua/Any Script Language). Since the Script Part is entirely up to, you can have your own pretty API. I won’t bother going through the lower part, it depends on you how you do it.

Script API example

function StartVisualNovel()
	Dialogue("Yamada", "Is there anything else you want on your Cheesburger?")
end

The function StartVisualNovel  is called by the Engine and the Script executes the function Dialogue which calls back to the Engine to execute that specific task. In this example, its to let a Dialogue appear, as in any Visual Novel you would expect. You could have the engine block the Script until the user has pressed a key or in a different way, as in explained below.

More Considerations

  • Unicode support. The Engine should also be able to display text in various languages. One example is to give each string of the Game a Key and then let the Engine translate it.
  • Load/Save system should be integrated with the Script. For example: Since we cannot save the state of a Lua Script (global variables, instruction pointer), let the Script be able to register some of its memory to the Engine. You could have a function called _SetGlobalVariableInteger _ and GetGlobalVariableInteger. This is absolutely effortless to implement on both sides.
  • The Script could run as independent thread or inside the Game Loop. To achieve this you would probably call a function of the Script each time the Game progresses and save the state in a variable, preferably with the method suggested above.

I had some problems force quitting a Lua Thread, if you know how to do it correctly, please tell me.

Afterwards, this is quite an easy project. No need anymore for baby-premade Engines. Hardcore people do it from scratch. Embrace the reinvent-the-wheel lifestyle as good as you can, Reader!