Random Text

For questions about using Classic.

Post » Fri Jul 10, 2009 3:18 am

I want to make the application to display a message random before at close.
How Make this?

Thanks!
B
3
G
3
Posts: 26
Reputation: 927

Post » Fri Jul 10, 2009 4:03 am

You mean choose a random message from a set of pre-made messages?
B
134
S
65
G
16
Posts: 1,765
Reputation: 19,188

Post » Fri Jul 10, 2009 4:19 am

[quote="alspal":3uj7ezku]You mean choose a random message from a set of pre-made messages?[/quote:3uj7ezku]

the two!
I was trying to use SET text,
more i not have had success!
show me how to do it using set and pre-made messages?
then I see which is better!

Thanks!
B
3
G
3
Posts: 26
Reputation: 927

Post » Fri Jul 10, 2009 7:26 am

You could add all of your messages to a list box, then get the text from a random line. Here's an example for how it could be done:

Random message example
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Fri Jul 10, 2009 10:09 am

you could also put all your messages in a hashtable, and name them message0, message1, message2, message3, for example, and then when you go to retrieve your message for the key, put in:

"message"&random(3)
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Fri Jul 10, 2009 6:53 pm

Hum LinkMan, nice example , thanks,
but, I do not understand the example of lucid :(

Lucid, you can show me your example in CAP file?
Thank you.
B
3
G
3
Posts: 26
Reputation: 927

Post » Fri Jul 10, 2009 8:07 pm

click left mouse button to choose a random string
[url:ulh6eztr]http://files.getdropbox.com/u/1013446/hashrandomexample.cap[/url:ulh6eztr]
after looking at the cap, this is how/why it works:
all you're doing is making a string by sticking together two parts
for instance [code:ulh6eztr]"hello,"&" how ya doin?"[/code:ulh6eztr]
would add the strings and make it [code:ulh6eztr]"hello, how ya doin?"[/code:ulh6eztr]
so when you get the values from the hashtable with
[code:ulh6eztr]"msg"&random(4)[/code:ulh6eztr]
it's picking a random number between 0 and 3 and sticking it on the end of the string "msg"
making it end up as one of the strings that's set in start of layout by adding the random number to the end
[code:ulh6eztr]"msg0"
"msg1"
"msg2"
"msg3"
[/code:ulh6eztr]
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Fri Jul 10, 2009 9:19 pm

Ohh :o

Very Good Lucid.
Thank you very much! :wink:
B
3
G
3
Posts: 26
Reputation: 927


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest