Senior Member
Join Date: Jul 2010
Posts: 149
|
I have two class special abilities: cEnsEnsp and cEnsSpForm. cEnsEnsp has an array with a checkbox (field: usrIsCheck). cEnsSpForm has a normal activation checkbox (field: abilActive). Everytime a user selects one of these abilities, I want it to deselect the other. In other words, if hero.child[cEnsEnsp].field[usrIsCheck].value = 1 then hero.child[cEnsSpForm].field[abilActive].value = 0, and vice versa.
I'm using the following code for cEnsEnsp: Code:
doneif (field[usrIsCheck].value = 0) hero.child[cEnsSpForm].field[abilActive].value = 0 trustme Code:
doneif (field[abilActive].value = 0) hero.child[cEnsEnsp].field[usrIsCheck].value = 0 trustme Mind you, I don't want selecting one ability to disable the other, merely deselect it. It's possible to use neither of these abilities, but it's not possible to use both of them simultaneously, so I can't just use a single checkbox that toggles the two abilities. But if each one disables the other, then the user has to deselect one before he or she can select the other, and I want to reduce the number of clicks the user has to make. |
#1 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,213
|
In that case, I'd recommend just writing an eval rule that complains if the user turns on both, and write your scripts such that if one is turned on, the other one will not apply its effects - one of them says:
doneif (hero.child[the other one].field[whichever].value <> 0) If you do want to do it this way, ask yourself - at the time in the execution of the script that it tries to alter the user-controlled field, is this a trusted script? Also, be very careful of timing - if the user checks the other one, are your timings set up such that the fact that the other is still on won't disable this new one? That kind of weirdness is one of the reasons we don't usually do this sort of thing. |
#2 |
|
|