0 Favourites

# How do I make text to show result of another text

• 11 posts
• 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.

• 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.

• 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.

• 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!

• 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)

• 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

• Thanks for your response R0J0hound, it worked!

Thank you all for your help!

Construct 2 really has a great community!

• ## Buy Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• 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?

• 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.

• Can you please explain it a little bit?

• GR8 R0J0hound always there to help very good of you R0J0hound. Keep up the good work R0J0hound

• 11 posts