Is this possible in C2? How?

Get help using Construct 2

Post » Thu Dec 01, 2016 8:49 am

Image

IS THIS POSSIBLE HERE IN C2? HOW? I MADE A RANDOM NUMBER CAPX BUT I FIND IT HARD TO THIS FLOW.. I HOPE YOU CAN HELP WITH A CAPX. THANKS.
B
8
S
1
G
1
Posts: 26
Reputation: 958

Post » Thu Dec 01, 2016 10:40 am

mnmco wrote:IS THIS POSSIBLE HERE IN C2? HOW? I MADE A RANDOM NUMBER CAPX BUT I FIND IT HARD TO THIS FLOW.. I HOPE YOU CAN HELP WITH A CAPX. THANKS.


You can do it in several ways, either with a list, array, dictionary or from a file etc.

To do it with a list (Which is the easiest to explain I think), you can use "Add to list" and then insert a String. The list will automatically give each item an index, starting at index 0.

0: James
1: Robert
2: Jack
3: ... so on

The String you insert could come from a Textbox and you can retrieve the name from the list at an given index using get "ItemTextAt" and you can change the index that you want to get with an "Int(Random(List.Itemcount))" to make it choose a random index from the list.

Here is an example:
https://dl.dropboxusercontent.com/u/109921357/Add%20and%20get%20names/Add_and_get_names.capx
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Mon Dec 05, 2016 10:20 am

Thank you for the reply pls help me as I am lost with my events.. as seen below..
Last edited by mnmco on Mon Dec 05, 2016 10:24 am, edited 2 times in total.
B
8
S
1
G
1
Posts: 26
Reputation: 958

Post » Mon Dec 05, 2016 10:22 am

nimos100 wrote:
mnmco wrote:IS THIS POSSIBLE HERE IN C2? HOW? I MADE A RANDOM NUMBER CAPX BUT I FIND IT HARD TO THIS FLOW.. I HOPE YOU CAN HELP WITH A CAPX. THANKS.


You can do it in several ways, either with a list, array, dictionary or from a file etc.

To do it with a list (Which is the easiest to explain I think), you can use "Add to list" and then insert a String. The list will automatically give each item an index, starting at index 0.

0: James
1: Robert
2: Jack
3: ... so on

The String you insert could come from a Textbox and you can retrieve the name from the list at an given index using get "ItemTextAt" and you can change the index that you want to get with an "Int(Random(List.Itemcount))" to make it choose a random index from the list.

Here is an example:
https://dl.dropboxusercontent.com/u/109921357/Add%20and%20get%20names/Add_and_get_names.capx



First of all, Thank you for the reply and sample capx. But I hope you can help me as I got lost as Im doing my codes in the events.

Image
Image


Im using a global variable for the random number and I find it hard to connect the random number and the list .. is this possible or my coding is just complicated? or maybe there is much more simple logic than what im doing? Thanks again for the future help..

https://www.dropbox.com/s/adjeivnm7xdph ... .capx?dl=0
B
8
S
1
G
1
Posts: 26
Reputation: 958

Post » Mon Dec 05, 2016 6:33 pm

Yeah you are mixing up things.

If you look in my Capx I use a functionality that allow you to extract the text at a given index. This index goes from 0 to the number of items In the list. So you don't need a global variable its already being taken care of by the list internal index.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Mon Dec 05, 2016 9:47 pm

You should be using an Array. That is your missing link. You can make this list work using List.IndexOf, etc. But an Array object has more functionality.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"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
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Tue Dec 06, 2016 7:53 am

gumshoe2029 wrote:You should be using an Array. That is your missing link. You can make this list work using List.IndexOf, etc. But an Array object has more functionality.


Thank you for the advice but Im not really good in coding. Can you give me sample capx using arrays? Thank you ..
B
8
S
1
G
1
Posts: 26
Reputation: 958

Post » Tue Dec 06, 2016 7:57 am

nimos100 wrote:Yeah you are mixing up things.

If you look in my Capx I use a functionality that allow you to extract the text at a given index. This index goes from 0 to the number of items In the list. So you don't need a global variable its already being taken care of by the list internal index.


In your capx, Is it possible that the number text and the name text will appear separately. Random Number at the top then the Name at the bottom..
B
8
S
1
G
1
Posts: 26
Reputation: 958

Post » Tue Dec 06, 2016 8:09 am

mnmco wrote:
nimos100 wrote:Yeah you are mixing up things.

If you look in my Capx I use a functionality that allow you to extract the text at a given index. This index goes from 0 to the number of items In the list. So you don't need a global variable its already being taken care of by the list internal index.


In your capx, Is it possible that the number text and the name text will appear separately. Random Number at the top then the Name at the bottom..

Yeah you would have to modify it a little, but you can get the index number of a selected name as well or you could store the random index number in a local variable first which you then use to get the name as well as the number you want to place in the separate textbox.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Wed Dec 07, 2016 7:03 am

nimos100 wrote:
mnmco wrote:
nimos100 wrote:Yeah you are mixing up things.

If you look in my Capx I use a functionality that allow you to extract the text at a given index. This index goes from 0 to the number of items In the list. So you don't need a global variable its already being taken care of by the list internal index.


In your capx, Is it possible that the number text and the name text will appear separately. Random Number at the top then the Name at the bottom..

Yeah you would have to modify it a little, but you can get the index number of a selected name as well or you could store the random index number in a local variable first which you then use to get the name as well as the number you want to place in the separate textbox.


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..
B
8
S
1
G
1
Posts: 26
Reputation: 958

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, Julot135 and 37 guests