Random Choose

Get help using Construct 2

Post » Tue Dec 27, 2011 9:06 pm

I'm trying to make:

first i have to choose randomly between

[0,1,2,3,4] each one is related an object that the user have to care (apple, flower, car, house, sheep)

if the user loose one, for example 1

choose between [0,2,3,4]

if the user loose one, for example 3

choose between [0,2,4]

how do i make it dynamic?
B
4
G
1
Posts: 30
Reputation: 685

Post » Tue Dec 27, 2011 9:18 pm

If you look at the manual entry under the heading 'Values' HERE there's an entry called 'Choose' which may be what you're after.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,840
Reputation: 48,281

Post » Tue Dec 27, 2011 9:32 pm

I know how choose works, but how do i handle the conditions to make the choose dynamic, how do i delete one value of the choose.
B
4
G
1
Posts: 30
Reputation: 685

Post » Tue Dec 27, 2011 9:55 pm

You should be able to use a variable with choose like choose(global.value("list"), and then change that variable using the text expressions like tokenat.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Wed Dec 28, 2011 1:15 pm

How do I search in a text a value to replace by null or any text
B
4
G
1
Posts: 30
Reputation: 685

Post » Wed Dec 28, 2011 1:16 pm

I can't get it works :(
B
4
G
1
Posts: 30
Reputation: 685

Post » Wed Dec 28, 2011 1:25 pm

i'm thinking to change a string [0,1,2,3,4] search any number and replace then count and make a random maybe it works
B
4
G
1
Posts: 30
Reputation: 685

Post » Wed Dec 28, 2011 1:26 pm

but i don't know how
B
4
G
1
Posts: 30
Reputation: 685

Post » Wed Dec 28, 2011 1:42 pm

I think the easiest solution is to take a two-dimensional Array, fill it with the "content" in one row and use the other row to mark if an item is allready selected.
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Wed Dec 28, 2011 2:53 pm

[code]Global variable list = "1|2|3|4|5|"
Global variable picked = 0
Mouse: On Left Click
   // pick on item at random
   -> System: set picked to tokenat(list,random(tokencount-1),"|")
   // delete this token from list
   -> System: set list to replace(list,picked&"|","")[/code]
Weishaupt solution is better if you want some items back afterward.Yann2011-12-28 14:55:57
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Next

Return to How do I....?

Who is online

Users browsing this forum: CavalierBubble, Evanetot, Yahoo [Bot] and 23 guests