Posted by: Vlasák
« on: January 18, 2005, 05:33:43 AM »If you want to make the condition as:
(Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4)
As it been said it is not possible - AND is implicit in triggers and no single AND(x) as in case of OR(x) doesn't exist. But there is a three block solution that can simulate various Sum of Products boolean formulas ( (...AND...AND...AND...) OR (...AND...AND...AND...) OR (...AND...AND...AND...) OR...)
I've wanted this many months ago - I've tried to simulate AND by !OR() and it didn't work. Just about two months ago I realised, that it can be do in following way...
The principle - make the negation of: (Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4) - that is
(!Trigger1 OR !Trigger2) AND (!Trigger3 Or !Trigger4). This negation can be coded in IE script block.
The action of that block must be the reverse of your original action you've wanted to code - or just NoAction() - "I want to do something when condition (Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4) is true and do nothing when it is not true".
There is the second block which follow after this. This block has it's condition always true and its purpose is to perform the action that I've wanted.
Because of the proccesing of scripts the following two possibilites occurs:
- the first block condition is true (="Oposition of my original requirements are fulfiled"="My original requirements are not fulfiled") - NoAction (or reverse action) is perform and the script restarts to its beginning. So the second "always true" block is not performed. So I "catch" the undesired cases.
- the first block condition is false (="Oposition of my original requirements are no fulfiled"="My original requirements are fulfiled") - script skips to second block and it is performed then...
Well, this solution is rough, however - the rest of the script after the mentioned second block is always cut off from the script procceeding due to second block's always true condition. I can add there Continue() action that ensures the continue of the script proceeding. But by this I'll break a little the standart rules of the script proceeding (when the block is performed, the script restarts).
So, I'll add "AND" local variable - its values meaning:
- 0: my desired action can be performed
- 1: my desired action cannot be performed due to the fact that the opposite conditions are true
I've developed similar method for the simulation of OR in BG1 where this trigger is not present.
(Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4)
As it been said it is not possible - AND is implicit in triggers and no single AND(x) as in case of OR(x) doesn't exist. But there is a three block solution that can simulate various Sum of Products boolean formulas ( (...AND...AND...AND...) OR (...AND...AND...AND...) OR (...AND...AND...AND...) OR...)
I've wanted this many months ago - I've tried to simulate AND by !OR() and it didn't work. Just about two months ago I realised, that it can be do in following way...
The principle - make the negation of: (Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4) - that is
(!Trigger1 OR !Trigger2) AND (!Trigger3 Or !Trigger4). This negation can be coded in IE script block.
The action of that block must be the reverse of your original action you've wanted to code - or just NoAction() - "I want to do something when condition (Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4) is true and do nothing when it is not true".
There is the second block which follow after this. This block has it's condition always true and its purpose is to perform the action that I've wanted.
Because of the proccesing of scripts the following two possibilites occurs:
- the first block condition is true (="Oposition of my original requirements are fulfiled"="My original requirements are not fulfiled") - NoAction (or reverse action) is perform and the script restarts to its beginning. So the second "always true" block is not performed. So I "catch" the undesired cases.
- the first block condition is false (="Oposition of my original requirements are no fulfiled"="My original requirements are fulfiled") - script skips to second block and it is performed then...
Code: [Select]
IF
OR(2)
!Trigger1
!Trigger2
OR(2)
!Trigger3
!Trigger4
THEN
RESPONSE #100
NoAction()
END
IF
True()
THEN
RESPONSE #100
Action()
END
Well, this solution is rough, however - the rest of the script after the mentioned second block is always cut off from the script procceeding due to second block's always true condition. I can add there Continue() action that ensures the continue of the script proceeding. But by this I'll break a little the standart rules of the script proceeding (when the block is performed, the script restarts).
So, I'll add "AND" local variable - its values meaning:
- 0: my desired action can be performed
- 1: my desired action cannot be performed due to the fact that the opposite conditions are true
Code: [Select]
IF
GlobalGT("AND",LOCALS",0) //if AND =>0
THEN
RESPONSE #100
SetGlobal("OR","LOCALS",0) //reset to 0
Continue() //I want to continue in the script
END
IF
OR(2)
!Trigger1
!Trigger2
OR(2)
!Trigger3
!Trigger4
THEN
RESPONSE #100
SetGlobal("AND","LOCALS",1) //My desired action cannot be performed (opposite conditions are true), so AND=1
Continue() //!! I want to continue in script because in my imaginary "(Trigger1 AND Trigger2) OR (Trigger3 AND Trigger4)" block I have now the case when its conditions are not true and the script continues to following block in these cases
END
IF
!GlobalGT("AND","LOCALS",0) //AND is not =>0
THEN
RESPONSE #100
Action //perform desired action
//no Continue() - if this block is performed, the script restarts as it's standart.
END
I've developed similar method for the simulation of OR in BG1 where this trigger is not present.