How do I make text to show result of another text

Get help using Construct 2

Post » Fri Sep 19, 2014 6:45 pm

I just wanna know, how do I make one text to show a result of a math task in another text?
This is a text for a math task: round(random(1,100)) & choose("+","-","/","*") & round(random(1,100))
Now, I want to make another text, which will show a result of that mathematical task.
How do I do that?
I appreciate your response and help.
B
4
Posts: 10
Reputation: 220

Post » Sat Sep 20, 2014 1:04 am

That's quite straightforward. You can store the result of math task in a global variable, then retrieve the variable's value and display it in another text object.
B
23
S
9
G
3
Posts: 114
Reputation: 3,794

Post » Sun Sep 21, 2014 4:39 pm

Ok thanks. But I am having problems doing that.
Can you help me out a little with doing that.
I am still a beginner at Construct 2.
A little help would be appreciated. :)
B
4
Posts: 10
Reputation: 220

Post » Sun Sep 21, 2014 4:48 pm

what do you need the first text for ?? you areleady have the math task just set it to the second text ? please explain so we can help!
B
12
S
6
Posts: 118
Reputation: 1,466

Post » Sun Sep 21, 2014 5:14 pm

I want to have a mathematical task in one text, and the solution (result) of that math task in another text.
Example:
First text: 6 & "/" & 2
Second text: result of the first text. (3)
B
4
Posts: 10
Reputation: 220

Post » Sun Sep 21, 2014 7:20 pm

Instead of building the first text right away store the two numbers in variables and the operator in another variable. Then you can build the first text with number1&operator&number2. Then just add some conditions checking what the operator and set the second text depending on the operator.

global number number1=0
global number number2=0
global text operator=""

Start of layout
--- set number1 to round(random(1,100))
--- set number2 to round(random(1,100))
--- set operator to choose("+","-","/","*")
--- set Text1 to number1&operator&number2

operator = "+"
--- set text2 to number1+number2

operator = "-"
--- set text2 to number1-number2

... etc
B
91
S
31
G
103
Posts: 5,234
Reputation: 67,754

Post » Mon Sep 22, 2014 9:22 am

Thanks for your response R0J0hound, it worked!
Thank you all for your help!
Construct 2 really has a great community! :)
B
4
Posts: 10
Reputation: 220

Post » Fri Sep 26, 2014 9:19 pm

Ok now I have another question.
I set some objects to spawn in random positions on the screen, but there is a problem.
Sometimes some of them spawn on top of each other (because they spawn at a random location,and sometimes that random location is on top of another object)
Can I make them spawn in random positions, but prevent them from spawning on top of other objects?
B
4
Posts: 10
Reputation: 220

Post » Sat Sep 27, 2014 12:11 am

Feljo130 wrote:Ok now I have another question.
I set some objects to spawn in random positions on the screen, but there is a problem.
Sometimes some of them spawn on top of each other (because they spawn at a random location,and sometimes that random location is on top of another object)
Can I make them spawn in random positions, but prevent them from spawning on top of other objects?


You need to choose random x,y values then check if they coincide with existing object positions, in which case, try again. In other words, write some code to do it.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Sep 30, 2014 2:48 pm

Can you please explain it a little bit?
B
4
Posts: 10
Reputation: 220

Next

Return to How do I....?

Who is online

Users browsing this forum: ivanski1983 and 14 guests