Okay, I tried the above triggers with a little help from my brother, who is a really good leak detector and has been playing Warcraft for 25 years. Okay let us describe the draw backs of all the above triggers :
Drawbacks of Ned's first trigger code :
1. This trigger is too complicated for this, and maybe a little hard for beginners.
Drawbacks of my trigger:
1. I do not know what I was thinking. I made it really complicated with the nested loops. It can be done easily.
Drawbacks of Ned's Second trigger :
1. Well, I never knew about this leak, but I found out that if you order a gate to be closed if it is already closed, then it causes an overlapping memory leak.
2. Another leak, if you revive a lever, it causes a leak, because remember a lever doesn't have a death. It's switch is just shown to go to the other side. Though, it may not appear in game, but it causes a memory leak.
Concluding trigger :
The real leakless trigger would look something like the hybrid of some of Ned's and my triggers. But it also contains some more triggers. But, be assured it's leakfree and works, cause I have tried it.
1. Initialization Trigger
In your initialization trigger, add these actions woth your preexisting ones:
-
Actions
-

Set LeverPoint1 = Random point in Your_First_Lever_Region
-

Destructible - Create a Lever in LeverPoint1
-

Set Lever1Val = (Last created destructible)
-

Custom Script - call RemoveLocation (udg_LeverPoint1)
-

Set LeverPoint2 = Random point in Your_Second_Lever_Region
-

Destructible - Create a Lever in LeverPoint2
-

Set Lever2Val = (Last created destructible)
-

Custom Script - call RemoveLocation (udg_LeverPoint2)
-

Set LeverPoint3 = Random point in Your_Third_Lever_Region
-

Destructible - Create a Lever in LeverPoint3
-

Set Lever3Val = (Last created destructible)
-

Custom Script - call RemoveLocation (udg_LeverPoint3)
Explanation : We assume the destructibles to variables to make the variables change its value later.
Variables LeverPoint1, LeverPoint2 and LeverPoint3 are all region type variables while Lever1Val, Lever2Val and Lever3Val are of type Destructible.
2. Your trigger for Lever 1
-
Lever 1
-

Events
-


Destructible - Lever1Val dies
-

Conditions
-

Actions
-


Destructible - Open Gate 1
-


Set Gate1Open = 1
-


If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
-



If - Conditions
-




(Gate2Open) is equal to 1
-



Then - Actions
-




Destructible - Close Gate 2
-




Set Gate2Open = 0
-



Else - Actions
-


If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
-



If - Conditions
-




(Gate3Open) is equal to 1
-



Then - Actions
-




Destructible - Close Gate 3
-




Set Gate3Open = 0
-



Else - Actions
-


Destructible - Remove Lever 001 from the game
-


Set Lever1Death = Random point in Your_First_Lever_Region
-


Destructible - Create a Lever in Lever1Death
-


Set Lever1Val = (Last created Destructible)
-


Custom Script - call RemoveLocation (udg_Lever1Death)
Explanation:
First part is clear, I hope. After closing and opening the gates, we remove the lever from the game fully, and create another lever in that region, and assign Lever1Val to the last created destructible (The variable explained in Init Trigger, remember? ) So this will happen in kind of a loop, each time Lever1Val is destroyed.
Similarly the other two triggers:
3. The trigger for second lever
-
Lever 2
-

Events
-


Destructible - Lever2Val dies
-

Conditions
-

Actions
-


Destructible - Open Gate 2
-


Set Gate2Open = 1
-


If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
-



If - Conditions
-




(Gate1Open) is equal to 1
-



Then - Actions
-




Destructible - Close Gate 1
-




Set Gate1Open = 0
-



Else - Actions
-


If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
-



If - Conditions
-




(Gate3Open) is equal to 1
-



Then - Actions
-




Destructible - Close Gate 3
-




Set Gate3Open = 0
-



Else - Actions
-


Destructible - Remove Lever 002 from the game
-


Set Lever2Death = Random point in Your_Second_Lever_Region
-


Destructible - Create a Lever in Lever2Death
-


Set Lever2Val = (Last created Destructible)
-


Custom Script - call RemoveLocation (udg_Lever2Death)
4. Trigger for third lever :
-
Lever 3
-

Events
-


Destructible - Lever3Val dies
-

Conditions
-

Actions
-


Destructible - Open Gate 3
-


Set Gate3Open = 1
-


If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
-



If - Conditions
-




(Gate2Open) is equal to 1
-



Then - Actions
-




Destructible - Close Gate 2
-




Set Gate2Open = 0
-



Else - Actions
-


If (If - conditions are true) Then do (Then - Actions) else do (Else - Actions)
-



If - Conditions
-




(Gate1Open) is equal to 1
-



Then - Actions
-




Destructible - Close Gate 1
-




Set Gate1Open = 0
-



Else - Actions
-


Destructible - Remove Lever 003 from the game
-


Set Lever3Death = Random point in Your_Third_Lever_Region
-


Destructible - Create a Lever in Lever3Death
-


Set Lever3Val = (Last created Destructible)
-


Custom Script - call RemoveLocation (udg_Lever3Death)
Hope I helped ! Also credit to Ned and my brother!