How do I random list

Get help using Construct 2

Post » Wed Aug 03, 2016 10:47 pm

how to set value text from listbox random
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

Post » Wed Aug 03, 2016 11:09 pm

Set Text to List.ItemTextAt(floor(random(List.ItemCount)))
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Wed Aug 03, 2016 11:25 pm

@oosyrag

ty alot:) and how to set selection list from variable text?

if sprite Instance variable name is eric set list selection eric

i use before the command
sprite Set Name To List.ItemTextAt(floor(random(List.ItemCount))) work perfect

and when mouse click object sprite set List.selection from sprite name < how this can be work?
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

Post » Wed Aug 03, 2016 11:52 pm

Then you want to save the index of the list item instead of directly setting the text to the sprite.

floor(random(List.ItemCount)) gives you the index. So add a instance variable to your Sprite - ListIndex

So first set Sprite.ListIndex to floor(random(List.ItemCount))
Then Set Sprite.Name to List.ItemTextAt(Sprite.ListIndex)

When you click sprite, use the list action Set Selection to Sprite.ListIndex.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Thu Aug 04, 2016 12:00 am

@oosyrag

im confused :( can you make a simple capx please ?
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

Post » Thu Aug 04, 2016 12:15 am

@oosyrag
ok i got it :) after 3-4 time read it again .. now is work perfect :)
ty very very much
B
17
S
7
G
7
Posts: 205
Reputation: 5,335

Post » Thu Aug 04, 2016 12:19 am

Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458


Return to How do I....?

Who is online

Users browsing this forum: guannstar and 20 guests