Mod Side Story : a walkthrough of a text dialog mod

2

Index

Attached Files

The following files have been attached to this tutorial:

.capx

dialogs-tutorial-part-1.capx

Download now 174.52 KB
.capx

dialogs-tutorial-part-2.capx

Download now 176.49 KB
.capx

dialogs-tutorial-part-3.capx

Download now 178.38 KB
.capx

dialogs-tutorial-textadventures.capx

Download now 251.02 KB

Stats

11,049 visits, 25,020 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 27 Jan, 2014. Last updated 19 Feb, 2019

Part 3 : Expansion and Implementation

So here we go for the part 3. We will start by modifying/formalizing the Dialog library itself. On this road, we will also expand a little on the Speech dialog, to trigger another action on completion.

In a second time, we will implement it in a prototype of mine. We will detail how it is done step by step, and play around a little with the possibilities.

In the end, we will come to this.

3.1 Formalization : the user guide

The part 3 .capx is quite different of the part 2.

The Dialog event sheet is now separated in 2 parts :

The Dialog group is the one with all the functions. No changes are needed inside this group for the module to work.

The Template group is the one you will have to complete for the implementation in the game to work.

The Dialog group gives multiple public functions now witch are the one you are supposed to use. Those functions are :

- Dialog__Start(DialogID) : this function will start a dialog based on the DialogID. It's the dispatch function, routing depending on the dialog Type.

- DIalog_Speech_Continue() : this function is the one that pushes the Speech type dialog forward, from part 1 to part 2 then 3.

- Dialog__Choice_Next, Previous and Valid are the 3 functions to call during a Choice type dialog, to switch between the possibilities and valid.

Those functions have not changed a lot, we only made this part the most independent possible, meaning we will only need the following objects to import this Event sheet :

- CSV (with ";" as a separator)

- Function (I named mine "F", it must correspond)

- AJAX (for loading the CSV file)

I added a possibility to the Speech type dialog. If there is an action in "Action1" column, it will be called after the last screen of text.

Now that we know what our tools are, let's use them !

3.2 Formalization : Template and implementation

The second part of the Dialog event sheet is a template, the minimum code you will need to complete, and also exhaustive possibilities with explanation. Let's go through it in more details :

Event 39 : A function called when the Dialog CSV is loaded. Usefull if you have a menu to feed for example.

Event 40 : Dialog__Output is the function that will display the text in your game. If you don't complete this one, nothing will ever be displayed in the game. Previously, we had "Text->Set text to F.Param(0)'

Event 41 : the Game Functions group. I let 2 examples inside to describe how the CSV Action's column is interpreted here. The events 42 and 43 are only here to document.

Event 44 : the Key map Group. The 4 functions that need a key maping are here. You can directly put the "On [Key] pressed" here.

So, now let's go on the implementation. How to use the system in your game :

- 1/ make sure you have the needed objects : CSV, Function, AJAX. All those objects are globals, so their will be available in every layout.

- 2/ import a CSV file in your game, named "dialog.csv"

- 3/ create a new Event Sheet in your project, name it Dialog

- 4/ copy/past all the content from my capx Dialog event sheet to yours.

- 5/ import the sheet in the event sheet where you need dialogs.

- 6/ complete the Template.

3.3 Implementation example

The prototype I used don't do a lot, there isn't much content, but we can see the possibilities, and a complete implementation.

As I used this sprite shet, let's take a line to thank the author.

Other sprites are, sadly, by me...

A character runs in an infinite cave, with objects in its path. For the example, I only put a door and 2 torches. Also because I hate to make art, and didn't find anything fitting.

When the characters is close enough to those obstacles, a dialog will be triggered.

After I followed the 6 step method described just over here, I got to the completion of the Template. After quickly mapping the Keyboard (up, down, space/return) :

I got to the Dialog__output, the function that updates the text effectively. In our case, I choose a spriteFont, witch I put in front of a 9patch to have a nice look. But in the Dialog__output, we only need to update the text :

Now, the implementation is over. We don't have any Dialog up yet, but we can display one whenever we want, by calling our functions. Let's try.

This needs explanation :

- First, in event 47 and 48, we just handle the background and text appearance and disappearance. We could also use a fade behavior, or else.

- Event 49 and 50 are 2 functions made to handle different types of dialog.

The first type is the "dialog_temp", a temporary dialog that will disappear a second after appearing.

*The second type is the "dialog_pause", a dialog where the player stops and listen. Useful for speach and choices.

- Events 51 - 53 : The last 3 functions are called through the CSV to handle specific behavior, in response of a choice made by the user. If we had an inventory system, or a quest system, we would put here the corresponding triggers. In this case, we play an animation, launch another dialog, or just exit the dialog.

Last, the CSV :

So we have 3 dialogs (poor content as promised).

- the random one will be triggered by the torches.

- the choice once will be triggered by the door. Depending on the choice made, it will call the functions of the events 51-53 we just saw, for jumping, attaching, or running.

- the speech one is a single page long, and will call the function "dialog_pause" with parameter "1", to start over the door dialog.

You can now see how adding content is simple. Each time, you just have to trigger a dialog when needed, for displaying story, to be used as an escape menu, to talk to a pnj, or even for a point and click.

Ho, and here is the game demo to test it yourself.

3.4 3rd part finished already ?

Well, no, the prototype now being used, we will expand on the display itself, with progressive display functions. We will may be expanding this module in direction of quests in the next parts,.... we will see, tell me you would like !

A shorter but more practical part in the end !

.CAPX

dialogs-tutorial-part-1.capx

Download now 174.52 KB
.CAPX

dialogs-tutorial-part-2.capx

Download now 176.49 KB
.CAPX

dialogs-tutorial-part-3.capx

Download now 178.38 KB
.CAPX

dialogs-tutorial-textadventures.capx

Download now 251.02 KB
  • 0 Comments

Want to leave a comment? Login or Register an account!