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

Get help using Construct 2

» 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
B
77
S
44
G
49
Posts: 713
Reputation: 35,393

» 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

» 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
99
S
35
G
20
Posts: 438
Reputation: 17,940

» 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

» 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
23
S
9
G
4
Posts: 500
Reputation: 4,417

» Mon Apr 17, 2017 4:13 pm

but append works only in text object
but it will not work on other like
choose() & others
B
77
S
44
G
49
Posts: 713
Reputation: 35,393

» 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.
B
57
S
28
G
115
Posts: 1,712
Reputation: 65,172

» 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
B
77
S
44
G
49
Posts: 713
Reputation: 35,393

» 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
23
S
9
G
4
Posts: 500
Reputation: 4,417

» Mon Apr 17, 2017 4:39 pm

B
71
S
22
G
273
Posts: 3,822
Reputation: 150,787

Next