Are Global Variables active only for particular eventsheet

Get help using Construct 2

Post » Fri May 22, 2015 3:51 pm

Hi

I am Making a quiz game with construct 2..., i added a lifeline for user and i want that user can use it only once in a game....,

NOW THIS IS WHAT I HAD DONE..., PLEASE LET ME KNOW IF I HAVE DONE ANYTHING WRONG

On my main Layout's event sheet i added a global variable "HELP"
My every question have different Layouts and different event sheets., I added various groups to my eventsheets for eg:- GROUP"1" to 1st eventsheet , GROUP"2" to 2nd eventsheet , GROUP "3" to 3rd eventsheet and so on.....

{now i will give you example of my 1st eventsheet}

in GROUP"1":-
System - On start of layout == System - Wait 1 sec.
System - Create object "lifeline" on Layer__________

after that
Mouse - On left click on "lifeline" == System - Add "1" to "HELP"
(this is not included in Group)

{same way i done in all other eventsheets}

Now in main eventsheet
System -"HELP" is equal to "1" == System - set GROUP"1" deactivated
System - set GROUP"2" deactivated
System - set GROUP"3" deactivated
and so on......
[it is done so that the object"lifeline" could not be created in any other layout., once it is clicked.]

THIS ALL I HAD DONE...... But i am not getting the result..., the object"lifeline" gets created in 2nd layout., even when i clicked on it in 1st layout.....the group do not gets deactivated....... I also tried by adding Instance Variable to object"lifeline" with different settings....... But still HELPLESS :( :( ...

Are Global Variables active only for particular eventsheet., dont they react on whole project....????

Please HELP ME.... I provided so much detail so that you can properly understand my issue.....

i would be really thankful to you... If you sot out my this issue......
B
4
Posts: 13
Reputation: 226

Post » Fri May 22, 2015 5:32 pm

I just read this in the manual which (to me anyway) suggests that they stay active once initiated even when you load a new event sheet..

Global variables store their values between layouts. Events in any layout can access any global variable, even if it was created in a different event sheet that is not included.


[url]
https://www.scirra.com/manual/83/variables
[/url]
B
54
S
7
G
8
Posts: 150
Reputation: 5,817

Post » Fri May 22, 2015 5:40 pm

Maybe test this by putting a textfield in every layout and set it to textfield>set text>HELP so you can see if it actually changes the variable to 1 or not?
B
54
S
7
G
8
Posts: 150
Reputation: 5,817

Post » Fri May 22, 2015 9:19 pm

globalvariables are global that means are usable in all event sheets, however if you don't include the right code for it they wont update, :) its a matter how you link the events inside your event sheets don't you think so? the same way goes for global objects


for example i can have 1 scene with 10 event sheets and 5 scenes with 1 event sheet, the only thing i have to do is right click and include event sheet, or clone the event sheet for N times for each scene which is tedious and messy, that's why people tends to use as a general system the function object.
B
78
S
23
G
69
Posts: 1,353
Reputation: 44,005


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 12 guests