Is this possible in C2? How?

Get help using Construct 2

Post » Wed Dec 07, 2016 5:36 pm

Code: Select all
NAME: Set Text: List2.ItemTextAt(RANDOMNUMBER)


Except that you will occasionally get null, since you are using SMALLEST to BIGGEST+1, and BIGGEST and BIGGEST+1 will never exist, because the List2 indices start at 0.

You can condense all of that down to one row though:

Code: Select all
NAME: Set Text: List2.ItemTextAt(floor(random(List2.ItemCount)))

Like this:
Image
Note: The floor might mitigate the index issue at the top. So it might be round(random(List2.ItemCount-1) or floor(random(List2.ItemCount)) try them both.
https://www.ravenheart.ca/home
Company name changed to avoid Facebook-type shenanigans

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,415
Reputation: 4,824

Post » Wed Dec 07, 2016 6:50 pm

mnmco wrote:I appreciate your tips and the effort to reply but I hope if its ok with you that you can modify my capx a little. I find it hard to find ways. even using arrays, etc. But I will try to do it .. thanks..

Here is a modified version.

https://dl.dropboxusercontent.com/u/109921357/Problem_2/Problem_2.capx
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Thu Dec 08, 2016 3:56 am

This is a good tutorial for arrays. It even shows an example of the insertion that you are trying to achieve.

https://www.scirra.com/tutorials/307/ar ... ers/page-1
B
40
S
18
G
5
Posts: 98
Reputation: 5,651

Previous

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 11 guests