# How do I create random math formula

Get help using Construct 2

### » Thu Aug 28, 2014 2:27 am

Hello,

I was looking in tutorials and in forum but there was no joy, so question how do you create random math formula like this to display in a game: 5+5=10, 5*5=25 .... etc, my game will be math calculating game.

Regards,

Aurimas
B
8
S
2
Posts: 25
Reputation: 552

### » Thu Aug 28, 2014 3:09 am

Edit: ignore, misread the OP sorry

Local number MyVar = 0
System:Every Tick -> System: Add 5 to MyVar

Note you don't really want 'every tick', I used that as a 'placholder' event. The above will add 5 to MyVar about 60 times a second

Edit:
This is probably where you should start in the manual https://www.scirra.com/manual/83/variables

And also the word 'random' has many connotations, maybe 'arbitrary' would be better. Also you'll see references to 'expressions' in the manual which is what you meant by 'formula'. Good luck
Last edited by codah on Thu Aug 28, 2014 8:42 am, edited 1 time in total.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Thu Aug 28, 2014 6:25 am

floor(random(0,10))&choose("+","-","*","etc")&floor(random(0,10))
foor is whole numbers
random is 0 to 10
choose is select either of the given options

Better to store each in variable
number1 = floor(random(0,10))
formula = choose....
number2 = floor(......

Then calculate as integar to give answer.... can't calculate text
You think you can do these things, but you can't, Nemo!
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,743

### » Thu Aug 28, 2014 8:10 am

viewtopic.php?f=147&t=111211 check what @LittleStain said there.
B
14
S
3
G
1
Posts: 69
Reputation: 950

### » Thu Aug 28, 2014 8:40 am

looks like I misinterpreted the OP He did want random equations!
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

### » Thu Aug 28, 2014 10:19 am

@Aurimas

Here's a simple example of a basic math quiz.

BasicMathQuiz.capx

Logic is basically the same as LittleStain posted in the link roteam shared.
You do not have the required permissions to view the files attached to this post.
Find all the Construct 2 games that were on Steam Greenlight here
B
38
S
10
G
7
Posts: 501
Reputation: 7,129

### » Thu Aug 28, 2014 2:52 pm

Thanks, that it is what I need for my new project , just last thing in my game I will one to show correct answer in separate text box if answer was wrong, how do I add auto sum for this BasicMathQuiz.capx?
B
8
S
2
Posts: 25
Reputation: 552

solved it
B
8
S
2
Posts: 25
Reputation: 552

### » Thu Aug 28, 2014 9:40 pm

How did you solve?
B
7
S
1
Posts: 16
Reputation: 471

### » Fri Aug 29, 2014 5:35 am

i did set new text box to answer every 5 seconds
B
8
S
2
Posts: 25
Reputation: 552