Help with Toggling On/Off

Currently my game has 3 "abilities" that the player can activate.
Out of the 3 abilities, only 2 can be active at any single time.
I've searched around and found the code to do something along the lines of
(Self.Toggle + 1)%2 which will switch it between 0/1 or off/on.
The problem I am having is allowing only 2 of the 3 abilities to be active at any one time.
If I limit the abilities to only being able to toggle when say ActiveAbilities < 2, this prevents me from turning off the abilities.
I can't seem to figure out a way to have each ability to toggle on/off as long as less than 2 are already active, HOWEVER, still allowing it to toggle off if it is 1 of 2 already active.
Any ideas?
Out of the 3 abilities, only 2 can be active at any single time.
I've searched around and found the code to do something along the lines of
(Self.Toggle + 1)%2 which will switch it between 0/1 or off/on.
The problem I am having is allowing only 2 of the 3 abilities to be active at any one time.
If I limit the abilities to only being able to toggle when say ActiveAbilities < 2, this prevents me from turning off the abilities.
I can't seem to figure out a way to have each ability to toggle on/off as long as less than 2 are already active, HOWEVER, still allowing it to toggle off if it is 1 of 2 already active.
Any ideas?
Comments
then have another attribute called active abilities and have it set to 0.
then have a rule for each of the abilitiyes, when its attribute is 1 change active abilities to active abilities+1, then another rule when attribute is 0 changeattribute to -1
then finally in each rule that toggles each ability to 1, have that in a rule thats if active abilitiles is <2
so each time u turn a ability on it addds one to the active abiltiy attributes and when u turn it off it subtrats one. so if u had 2 on that attribute would be set to 2. and since you can only turn on on when the attributes less then 2, it will only let u have 2 ata atime like you want. and it will still let you turn them off
there might be a cleaner way to do it, im in class right and now dont really have time at the moment. that should work for u though
If I read your suggestion right, then it will toggle using that formula as long as ActiveAbilities is < 2, meaning 1 or 0.
But the problem I am running into is say if Ability 1 and Ability 2 are active, then ActiviteAbilities = 2. Since ActiveAbilities is 2, it won't allow anything to toggle, not even the already active ones to let them turn off.
Stuck on this for about 12 hours now and my head hurts.
this works better than any on/off solution I have ever used
would this work?
create three attributes, one for each button.
on button one have a rule that says
`
if ANY
button2 is false
button3 is fales
change attribute button1 to true
`
on button two
`
if ANY
button1 is false
button3 is fales
change attribute button2 to true
`
and on button three:
`
if ANY
button1 is false
button2 is fales
change attribute button3 to true
`
that SHOULD allow all buttons to turn on, but requires at least on of the other two to be off already. if they are both true, you won't be able to toggle them.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Hotspot button
Rule
-when touched inside
-change attribute to game.switchOn to (game.switchOn+1)%2
Scene image (light off image)
No rules
Scene image (light on image)
Rule
Interpolate.self.color.alpha = 0
If game.switchOn = 1
Interpolate.self.color.alpha =1
How do I get the light on image to interpolate back to zero when touch again?