Dialogue best practices - and where to store text

Get help using Construct 2

Post » Thu Mar 28, 2013 8:52 pm

If we could i think a way to store the text in a sprite and then create multiple frame for a text and then just use code and variable for easy. An example is the feature in Liveswif i think 2.0 had a way to create sprite text along with different frames to use. Thus is lots easier to deal with then just multiple text box raw json and or too many set text events. I still have the liveswif program if anyone want to take a look at what i am talking about.
B
7
S
2
G
3
Posts: 58
Reputation: 2,284

Post » Thu Apr 04, 2013 4:45 pm

@dragoonblade I don't think your idea is a very good one. Storing text as an image isn't going to be very helpful. What if you want to change it later on?

Thanks @jayderyu for your insight, I'm hoping to use JSON, but I'll be careful now after what you've said!

@Arima I haven't used the dictionary object yet, bth I didn't know what it's for! Was it originally intended for storing dialogue? (hence the name 'dictionary')
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Post » Thu Apr 04, 2013 5:18 pm

Not sure why the namesake "dictionary", but it's like the idea of a hash table, where you refer to data instantly by its key instead of trying to find the data by looping through the entire table. (Dictionary is still different than a hash though, hash cannot be looped and dictionary can.)

The difference between array and dictionary only start to show when you're handling thousands of data. I don't know if Mass Effect even has that many dialogues. So it's a personal preference on how you want to search the dialogue.

XML is made to be a tree structure. I didn't mention XML because I thought it's still having problems with CocoonJS for mobile conversion. Not sure if there's any update about that now.
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Thu Apr 04, 2013 6:54 pm

@onion - think of the dictionary object as a dynamic variable object that can create or destroy named variables (keys) at runtime.

I tested it with 100,000 keys and retrieving info from it didn't affect the framerate, so it seems plenty fast.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Apr 04, 2013 7:42 pm

Besides my own

XML is a good format. I tend to lean towards JSON as I find it has less tag over head. However, either structure JSON/XML will do the same job. Also if your creating your own tool. Then there is no difference to the end user.

Arima model I think is also easy to work with. using a coded key based on the parameters.

Also with C2 current beta release. There is an ajax fix for CJS. So for mobile devices this makes XML/JSON files now possible :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Thu Apr 04, 2013 8:11 pm

Yeah the ajax fix is a blessing, but XML object is still listed as incompatible in Ashley's export to Cocoonjs page. I think XML is incompatible on CocoonJS's end.

A finite state machine (spreadsheet) style model should still be a good alternative though. Something like this:


      |Normal|Happy |Sad   |
Joe   |Yo.   |lol   |Nope |
Doe   |Sup. |rofl |gtfo |
Mary |Hi.   |Haha |...   |
Sue   |Hello.|Teehee|...   |
B
19
S
6
G
1
Posts: 116
Reputation: 2,730

Post » Sat Apr 06, 2013 4:37 pm

@onion you can go back and edit the sprite. The one that liveswif had you could rewrite the text box without it being painted so to speak.
B
7
S
2
G
3
Posts: 58
Reputation: 2,284

Post » Tue Apr 09, 2013 10:07 pm

Hey guys I'm back on this now and still haven't found an elegant solution for what I want to do. I know I'm probably overthinking this solution, but I want something a bit better than having to manually use an event for each line of dialogue.

What I'm trying to do is have 2 characters have a chat at the start of each level. Character 1 says something in a speech bubble, then char 2, then char 1 etc, then the game starts. I want to do this at the start of each level (I have 10 levels).
So a repeatable method would be very handy.

@Arima the dictionary isn't really a good solution in my opinion. You have to give it named keys, and I don't think this will work for what I want. You'd have to know the name of each key when retrieving them in order. Arrays seem like a better solution, although arrays in C2 just seem... weird!! I'd have to add data to the array using separate actions, which would take ages, and I'd have to know where they end up. I know C2 usually has a visual and simlistic way of doing things, but the way we have to add data to an array actually seems more complicated than just writing it out in code.
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

Post » Tue Apr 09, 2013 10:28 pm

Hi guys here's what I've got so far. This is a monologue by 1 character, although I think it's a bit clumsy tbh. Although it does work!

https://dl.dropbox.com/u/24767479/c2%20project%20files/scripted%20dialogue.capx

Is this a sensible way of doing scripted dialogue?

The next step is to get character 1 talking too,but I've no idea how I'm going to do that using this method. Any ideas?
B
12
S
2
G
3
Posts: 86
Reputation: 2,955

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
B
14
S
4
Posts: 33
Reputation: 2,283

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 30 guests