Disable all groups in an event sheet?

For questions about using Classic.

Post » Thu Oct 07, 2010 4:09 am

Is it possible to disable all groups in an event sheet without referencing them by name?
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Thu Oct 07, 2010 5:42 am

You can put them all under one master group and just disable that one.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Oct 07, 2010 6:46 am

I don't think that will work for my purposes. I'll have something like 10 groups and based on a given condition (e.g. a Get Value) I want to basically disable 9 of the 10 except teh one that corresponds to the value returned. So I was thinking, if I could disable them all I can then just enable the right one. I could do it the roundabout way of having a bunch of disable statements for each possible result of the Get Value condition, but given that I'm not sure exactly how many groups I'll end up having this seems a bit tedious.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Thu Oct 07, 2010 7:50 am

You can use an expression in the name field for your disable group action. Say you name your groups Group1, Group2, Group3, etc. You pick the number by whatever means and store it in a variable. Then you can do [color=#408000:3l13vm30]->System: Disable group "Group"&global('variableName')[/color:3l13vm30]
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Oct 07, 2010 2:59 pm

Right. I was using that to enable the correct group so I could change what happens when different weapon-types are equipped. I was trying to have just a single enable/disable command for simplicity so that when I change the equippedWeapon variable I can just do a: Disable all groups, Enable Group(EquippedWeapon), but it appears that I can't since if I can't do somethign like "Disable all groups" then I either need to employ a holder variable (to hold weapon that was replaced) or call a disable command in all the various parts of the event sheets that cause a weapon to be unequipped.
B
11
S
2
G
3
Posts: 283
Reputation: 1,968

Post » Thu Oct 07, 2010 7:47 pm

I woke up in the middle of the night last night in a cold sweat, realizing that I'd gotten it backwards. I was worried that at the very least I'd confused you, and at most you'd post back saying "uh that don't work!" Either way I knew the cold hand of fate would lead me once again to this thread, and with a foreboding sense of dread I settled back into uneasy dreams.

Um... anyway. Using a loop you can disable all of the numbered groups, like so:

[code:3p0nqpo0]
+Always
->Set global('groupNum') to whatever group you need
->Set global('loopNum') to 1

+For 1 to 9
->System: Disable group "Group"&global('loopNum')
->Add 1 to global('loopNum')

+Always
->System: Enable group "Group"&global('groupNum')
[/code:3p0nqpo0]

The loop cycles through all the groups and shuts them down one at a time, then the following event activates the one group you need. And instead of a loopNum variable you might be able to use the loopIndex expression, but I don't recall off the top of my head if that works with For loops.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Oct 08, 2010 3:01 am

Hahaha sorry to be keeping you up at night! This approach sounds like it'll work, thanks!
B
11
S
2
G
3
Posts: 283
Reputation: 1,968


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests