Assign Text Objects to Array for Random dialouge?

Get help using Construct 2

Post » Wed May 02, 2012 11:42 pm

OK! As I traverse the landscape of Construct 2 I am having a difficult time wrapping my head around the array node. Is it possible to take several text objects, assign them to an array, and randomly call them upon interaction?

The basis of the game I am working on is like a quiz. the Goal is to have 25 variant questions and 5 People asking them. any Ideas? Thanks!

~~The New Guy.. haha
B
6
S
2
G
2
Posts: 6
Reputation: 1,801

Post » Thu May 03, 2012 9:00 am

Hmm, if you're just looking to store text, the array would be perfect. You could then pull the text from the array at random with something like:

Array.At(int(random(Array.Width)))

There are at least a couple ways to store questions and answers in the array as well. You could use the other axis (y,z) of the array to store more data.

Or you could tokenize the strings, which is what I'd typically do. Basically, you could store the quiz questions like "An apple is what color?|Red|Orange|Yellow|Purple".

Given that, you could use the tokenat() expression to get the multiple parts of the question/answer string.
B
126
S
7
G
4
Posts: 185
Reputation: 7,233

Post » Thu May 03, 2012 6:01 pm

Awesome! Now I just need to know how to push the text into the array. Thanks for the info!
B
6
S
2
G
2
Posts: 6
Reputation: 1,801

Post » Fri May 04, 2012 8:54 am

I was working out creation of an example quiz game when I came across the following thread, where Yann kindly provides an example, using tokenat() ironically enough:

http://www.scirra.com/forum/making-a-quiz-game_topic50656.html

Perhaps that'll help ya get started. :)
B
126
S
7
G
4
Posts: 185
Reputation: 7,233

Post » Fri May 04, 2012 4:28 pm

Thanks a ton Ugotsta! you have been a great deal of help in handling this aspect of the design!
B
6
S
2
G
2
Posts: 6
Reputation: 1,801

Post » Tue Apr 30, 2013 7:35 am

HI..
@Ugotsta

This was a great help sample file - thanks

But I have trouble in getting the vestern letter shown
guess it somehow has to be formatted right in utf8 but dont know how

Also ... how can I read/load the txt.file from a server

REGARDS
Flemming


B
23
S
12
G
10
Posts: 323
Reputation: 7,382


Return to How do I....?

Who is online

Users browsing this forum: SpartCrafter and 23 guests