How to convert 10 with 1,2,3,4,5,6,7,8,9,10

Get help using Construct 2

Post » Mon Apr 17, 2017 10:54 am

Is their any way of doing this
if i type only 10 and construct convert it to 1,2,3,4,5,6,7,8,9,10
Image
B
64
S
39
G
45
Posts: 651
Reputation: 32,214

Post » Mon Apr 17, 2017 12:01 pm

No idea what you mean... Convert into what? Loop 10 times?
B
33
S
10
G
2
Posts: 46
Reputation: 3,063

Post » Mon Apr 17, 2017 12:02 pm

@luckyrawatlucky

You could create a function to do that. Pass in the number entered by the user as a parameter, and then have the function pass back the string of numbers up to that value.
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Mon Apr 17, 2017 12:06 pm

AllanR wrote:You could create a function to do that. Pass in the number entered by the user as a parameter, and then have the function pass back the string of numbers up to that value.

How do you return multiple values (unless you're calling it multiple times then store each value)?

EDIT: Ah nvm... String of numbers...
B
33
S
10
G
2
Posts: 46
Reputation: 3,063

Post » Mon Apr 17, 2017 2:34 pm

Assuming that you will always start at 1, and going up to number X:

Set text object text to "1"

For "i" = 2 to X
> append text to text object ", "&loopindex("i")

Make sure your text object is wide enough to see all the numbers (if you're feeling clever you could set the width of the text object based upon the value of X ;))
B
19
S
8
G
3
Posts: 425
Reputation: 3,968

Post » Mon Apr 17, 2017 4:13 pm

but append works only in text object
but it will not work on other like
choose() & others
Image
B
64
S
39
G
45
Posts: 651
Reputation: 32,214

Post » Mon Apr 17, 2017 4:22 pm

If you're looking to use it for randomization purposes, you can't use choose() for a variable set of numbers. You would want to use floor(random(0,ChosenNumber).

For all other purposes, use a counter or reverse counter in a loop, where the number of repetitions is your chosen number. If you really need to, you can take the additional step of pushing each consecutive number to an array, although this should be necessary.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Mon Apr 17, 2017 4:34 pm

i have a global variable
i want that to be change
suppose variable is 10
then i want random between 1 to 10
Image
B
64
S
39
G
45
Posts: 651
Reputation: 32,214

Post » Mon Apr 17, 2017 4:36 pm

@luckyrawatlucky

Ah ok, my misunderstanding. If you want to keep the values as integers as you could push them to a 1D array, as @oosyrag says.
B
19
S
8
G
3
Posts: 425
Reputation: 3,968

Post » Mon Apr 17, 2017 4:39 pm

ImageImageImage
B
71
S
21
G
230
Posts: 3,688
Reputation: 128,852

Next

Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, R0J0hound and 4 guests