How do I use function return the same value

Get help using Construct 2

Post » Sun Aug 23, 2015 7:57 am

Hi,

I make a function to random select the value between 0 to 100, I need the result for two method, like: the function return value 10, I need the text to show 10 also I need another variable to add 10, I mean whatever the return value is, I need the same value for text and variable, if I call the function both in text and variable it will return different values, sorry for english is not my mother language, if you got confuse please let me know, thanks
B
11
S
3
Posts: 172
Reputation: 1,178

Post » Sun Aug 23, 2015 8:48 am

you can convert text to a number :

number=int("10")

you can also do thing like

text=""&10

so you could return your value as a number and then set your text to

text=""&(returned variable)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Sun Aug 23, 2015 7:08 pm

https://www.dropbox.com/s/ftqi83ngte220 ... .capx?dl=0

@RamPackWobble thanks, but your way is not what I mean, please see the file, when you touch the black box , both text will get a result from the function"Random", right now the 2 values are different, I want every time the 2 texts get the same value from the function. thanks
B
11
S
3
Posts: 172
Reputation: 1,178

Post » Sun Aug 23, 2015 7:21 pm

Why don't you use a global variable or do I understand something wrong?

Image
B
24
S
3
G
1
Posts: 451
Reputation: 2,165

Post » Sun Aug 23, 2015 7:39 pm

then set text2 to equal text rather than call the function again
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Sun Aug 23, 2015 11:21 pm

@Asmodean @Asmodean thanks, yeah forgot to set a global variable, thanks so much
B
11
S
3
Posts: 172
Reputation: 1,178

Post » Mon Aug 24, 2015 7:57 am

quick edit of your demo capx

http://1drv.ms/1JeGvYw
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Mon Aug 24, 2015 8:54 am

@RamPackWobble your method is cool, thanks bro
B
11
S
3
Posts: 172
Reputation: 1,178


Return to How do I....?

Who is online

Users browsing this forum: oosyrag and 31 guests