Dialogue best practices - and where to store text

Get help using Construct 2

Post » Fri Jul 12, 2013 2:41 pm

Hi Onion,
I have been going through the same wringer as you it seems. This certainly appears to be a gap in construct 2`s functionality.
My first impulse was to use Arrays (object gives an array index to look up the appropriate text) or Dictionary (same but dictionary key passed). First major problem with this is that these can only be populated at run time from the event sheet, not much use when I want to define dialogues for each level.
Also for my game I want occasional events to start the dialog, with sets of dialogues chained together to make conversations, possible with arrays but not ideal.

My current solution is to use just one pipe separated string like:
Hello Joe|Hi how are you|Not too good can you help?|Sure, I`m the hero aren`t I?|{end}
Then my events pass an ID to the dialogue text object (which has an 'is ID >0' event waiting) and that uses tokenat(dialogue.txt,ID,"|") to get the correct string. The rest of the conversation goes in sequence from that until it gets to a {end} string.
This way I can have a different instance of the dialogue text object per level with several different conversations in it.

Still a little clumsy to edit the string so not ideal (although you could read it from a text file and use newline as a separator). * - Also not too sure how many characters the text object allows?
Hopefully Scirra will see the need and implement something more useful.

I hope this helps someone with similar problems.
RRRattyRat2013-07-12 15:07:21
Posts: 33
Reputation: 2,283

Post » Fri Jul 12, 2013 3:07 pm

Well, I'll give away my aproch of the problem too.
I used a CSV to store all the dialogs according to this format :
Each and every dialog is then called using the PNJ.UID and the dialogID.
- the type of dialog is "story", "random" or "choice" and will change how the columns are used.
- in story mode, dialog1 will display first. If there is an action1/param1, I'll do a call function on the action1, giving param1 as parameter. If not, I'll display dialog2, then dialog3 using the same logic.
- random will trigger a random dialog between the 3 present. It will then execute the action1 if it is mentioned.
- choice will make the 3 lines appear and let the player choose one. It will then call the action corresponding to the dialog.

It was quite long to program in events (around 50 to handle everything) but worth it, as it can easily accept a new type of dialog, and can be used in a lot of ways.
The CSV was also a pretty easy choice to store the datas as rexrainbow's plugin is so simple to use and quite fast in runtime. Plus, it lets you prepare dialogs in excel ^^
Posts: 461
Reputation: 5,867


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 30 guests