# How do I click on numbers?

Get help using Construct 2

### » Thu May 05, 2016 5:08 pm

Hi,

I am having trouble figuring out the right construct 2 code for the following psuedocode:

1.) Generate a random set of numbers so: Generate between 4 and 10 different random numbers.

2.) The tricky part I am struggling with: If user clicks on these numbers in order of sequence then start the sequence from beginning, if one of them is not clicked on in the right order then start the sequence from the beginning but the use gets no point.

Also how do I generate the numbers as negatives additionally?
B
10
S
3
Posts: 112
Reputation: 1,086

### » Fri May 06, 2016 11:17 pm

Bump.
B
10
S
3
Posts: 112
Reputation: 1,086

### » Sat May 07, 2016 1:24 am

1. Generate a random set of numbers using the random() expression. To determine the number of random numbers generated, you can use a loop - repeat random(4,10) times. Create text, set text to random(x,y). Random() can be set to a negative number

2. One way to sort your randomly generated numbers in order, probably in an array. There are multitudes of ways to do this. Ref: https://en.wikipedia.org/wiki/Insertion_sort Edit: Just use the sort action!

A simple way I can think of to simulate the effect you are looking for, is to compare the selected number with ALL the other numbers. If ANY other number is less than the selected number, then fail and start over, set points, ect. Else if no numbers are less than the selected number, then delete that number and move on.

This will only work for numbers, and in order from smallest to greatest or vice versa.
Last edited by oosyrag on Mon May 09, 2016 6:47 pm, edited 1 time in total.
B
60
S
30
G
132
Posts: 1,931
Reputation: 74,339

### » Sat May 07, 2016 11:54 am

I choosed for lazy coding ( = no calculating positions, no arrays, and a lazy flow)
Most of this code is making sure that they spawn on random positions, but not on the same place
+ making sure each number is unique. Take that out, and its gets really simple.
The number shown is not the actual number, wat it shows is just a little trick to include negative numbers without much hassle. (= lazy coding too)

But, you know, be able to code in the most possible lazy way, that is the strenght of c2.

B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Mon May 09, 2016 4:13 pm

Um 99Instances2Go your code is good, but surely there is a shorter and simpler way of doing it as oosyrag mentioned but I have no idea how to implement, still better than what I can do. I find your code hard to understand.
B
10
S
3
Posts: 112
Reputation: 1,086

### » Mon May 09, 2016 6:36 pm

Just found out the array object had a sort action that I never even realized was there, sorry if I made it sound more complicated than it was. The sort action makes it much simpler!

Here are two examples, one using an array and one without using arrays.

https://www.dropbox.com/s/bve7b9dnxsh7o ... .capx?dl=0
https://www.dropbox.com/s/69rfiiabmfv9t ... .capx?dl=0

I didn't add the actions for what happens on success or failure besides destroying the text on success to show it works, try to give your best shot at implementing a scoring system on your own.
B
60
S
30
G
132
Posts: 1,931
Reputation: 74,339

### » Tue May 10, 2016 1:21 pm

Thanks overall
B
10
S
3
Posts: 112
Reputation: 1,086