Global Variables (Text)

Get help using Construct 2

Post » Sat Aug 17, 2013 5:05 pm

Hello!

I am often using global variables as 0/1 for booleans, or in fact for any global variable. I would like to use the other option 'text', however I'm not sure if I'm using it in the right way. e.g. if i set global variable to text and by default "used" then i want to later change it to global variable = "not used" within compare global variable, it doesn't like my text. I'm probably missing out some well known syntax here for using the text, can anyone assist?

Thanks
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Sat Aug 17, 2013 7:47 pm

1.- yes they should work as you state
2.- do not use " when defining the variables

B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Sat Aug 17, 2013 8:28 pm

@ghost

They don't work as I state and with or without " around the initial value it doesn't matter. If i set the intial value in the global variable CheckKey to used. Later on when I come to compare it, global variable CheckKey = used, it doesn't like the variable and I receive an error 'Unknown expression 'used' This is not a system expression or variable name in this scope'
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Sat Aug 17, 2013 8:43 pm

capx?
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Sat Aug 17, 2013 8:47 pm

@ghost

Adding a capx is useless as it's 0 events but I will explain the exact steps.

- Add a global variable called CheckKey, set to text, set the initial value as 'used'
- Add an event, system > compare global variable
- Attempt to set CheckKey equal to used, you receive an error and can't do it
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Sat Aug 17, 2013 11:33 pm

I made this and it works.

https://www.dropbox.com/s/uy7v9moapk298mc/Test.capx
B
10
S
4
Posts: 133
Reputation: 1,543

Post » Sat Aug 17, 2013 11:40 pm

So I do have to use " when defining the variables :P
Also, the red text implies there is an error with the variable selected, maybe a minor suggestion perhaps? Cheers for assistance!
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Sun Aug 18, 2013 1:04 am

Remember to use @ followed by the name of the person you are responding to or they wont know you replied. I saw it just by chance. :)
B
10
S
4
Posts: 133
Reputation: 1,543

Post » Sun Aug 18, 2013 1:08 am

@Imchucho
I usually do! My bad
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Post » Sun Aug 18, 2013 1:10 am

@lmchucho
You have a difficult name. I think it starts with an L. Troublesome for trying to write @you !
B
47
S
18
G
84
Posts: 2,273
Reputation: 49,800

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests