An engine that can be used to manage and play Visual Novels with limited interactivity. It supports a simple scripting language so you can control the story from within your XML file (which is the actual story).

Post tutorial Report RSS How scripts work.

Script are an essential thing when making something others can use. Not everyone wants or has to time to learn everything about a programming language to change how a certain engine does it's thing or add to it. This is where scripts come in.

Posted by on - Basic Client Side Coding

Script are an essential thing when making something others can use. Not everyone wants or has to time to learn everything about a programming language to change how a certain engine does it's thing or add to it. This is where scripts come in.

This tutorial will give you an overview of what functions you can actually use when making your scripts.

For this first release of the engine the scripts are still very basic, but the way it's set up now does allow you to do everything without looking into any kind of actual code.

How the scripts internally get converted is of no concern to you, if you do want to know look at the engine's code. What you do need to know is this:

  • it's case sensitive
  • arguments can be given by including them in '()', if needed
  • wrong functions or arguments will not crash the engine

Here's the actual function list:

  • playSound(id:String, willLoop:Booelan) - plays a sound, can be looped
  • stopSound(id:String) - stops a sound
  • stopAllSound() - stops all sounds
  • proceedStory() - proceed to the next frame in the story
  • gotoFrame(id:String) - proceed to a given frame in the story
  • proceedDialog() - proceed the dialog in the frame
  • gotoDialog(id:String) - proceed to a given dialog in the frame
  • changeBack(id:String) - change the background image
  • changeFront(id:String) - change the foreground image
  • end() - ends the story (dispatches the EVENT_END event)

Some of these functions require an ID, this ID is the one you give in the assets listing. internally the assets get called by either an automatically given number, or by the actual ID name that's given in the XML.
So how do you implement them in the actual story?

Well that's really easy to do. There are about 3 places where scripts can be initiated.

  • When the cover image get's shown
  • When a frame is created
  • When a dialog is created
  • When an answer from a dialog is selected

Here's an example of the XML:

<frame id="" image_backid="calm" image_frontid="f1" script="playSound(ambience, true)">
	<dialog id="" character="Circle" script="">
		<text>
What a wonderful day for playing outside!
		</text>
		<answer text="Continue..." script="proceedStory()"/>
	</dialog>
</frame>

This part of the XML shows all but the first places where scripts can be processed. A script should be written in the "script\" tag of an object.

You can have multiple functions in 1 script tag, you have to divide them with an ';'.
Here are a few examples of what you can do.

Change the background image:

changeBack(angry)

Play a sound:

playSound(angryShout, false)

Loop a sound and change the foreground image:

playSound(ambience, true); changeFront(calm)

Proceed with the story (basic continue button functionality):

proceedStory()

Go to a certain frame in the story:

gotoFrame(kick)

End the story, always end all sounds so they don't go on in the credits (if there are any):

stopAllSounds(); end()

End the story, change the sound:

stopAllSounds(); playSound(creditSong, false); end()

That's about it. With these functions you can control the story flow and have multiple endings if needed. Or keep it linear and just use "proceedStory()" all the time. It's all up to you.

Thanks for reading.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Platforms
Windows, Mac
Company
IntoGames
Contact
Send Message
Release date
Engine watch
Follow
Tutorial
Browse
Tutorials
Report
Report
Share
Related Engines
Visual Novel Engine
Visual Novel Engine Creative Commons
Related Groups
IntoGames
IntoGames Developer & Publisher