Need help with text problem?

Get help using Construct 2

Post » Sat Dec 10, 2011 5:21 pm

Question1

I have an offscreen text object(1) that is made up of 10 paragraphs.

When the player clicks on a button (1 to 12) I want the a second text object to display the chosen paragraph (button number)

Couldnt find anything on the forums.

Question 2

If the above cannot be done, can i use the webstorage or ajax object to achieve this?

Thanks in advance
B
19
S
6
G
7
Posts: 1,203
Reputation: 7,294

Post » Sat Dec 10, 2011 8:13 pm

Sounds like you could use an array there.
One paragraph/cell.

When clicking a button, you set text(2) to the value of the correct cell (the paragraph you're aiming for).

You would have to fill the array at some point, but your question doesn't let know much about your implementation, so hard to tell.

You could always fill a text object and "analyze" its content with system expressions like tokenat.

Question2
Webstorage would allow you to store the paragraphs as 10 keys, and be able to (like with an array) to pull out the value/paragraph when needed.
Nevertheless, you would have first to save the 10 keys for this to work.
Ajax would allow you to send only the paragraph you need.
Ex: click button 3
Send a request to your webserver "I_Want_Paragraph", parameter 3
Returns the paragraph.
Get this data and display it in the text(2).

I hope I make sense and that my explanation is clear.

From what you ask/tell, I'd say the array is the better solution.
But I might be wrong. Hope I gave you some clues.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,786

Post » Sat Dec 10, 2011 11:38 pm

Last edited by Yann on Sun Sep 14, 2014 10:48 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Dec 11, 2011 4:48 pm

Kyatric@
'You could always fill a text object and "analyze" its content with system expressions like tokenat.'

This sounded like the best(easiest) option, but i doesnt seem to work.

As a test, I tried the example in 'system expressions':

tokenat(src, index, separator)

Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.

Here is a screen shot after i entered the information in my project:



Yann@

http://dl.dropbox.com/u/23551572/C2/paragraphDisplay.capx (BUILT IN R71)

Thanks for the example, but I am still using R70. I downloaded R71 but not installed it yet, after seeing a few ' fixed in next build ' posts about it.



B
19
S
6
G
7
Posts: 1,203
Reputation: 7,294

Post » Sun Dec 11, 2011 5:05 pm

I just got it to work.

tokenat("one/two/three", 2, "/")

gave me the result: three


Cheers
B
19
S
6
G
7
Posts: 1,203
Reputation: 7,294

Post » Sun Dec 11, 2011 5:21 pm

Well... That's what I did, but using newline as a separator... Yann2011-12-11 17:21:49
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests