| 06-14-2006, 03:19 AM | #2 |
Using For Loop Integer A with Waits is dangerous because Integer A is a global value meaning it can be overridden in other triggers. Change that to For Each (Variable) being a local variable and all should be well. |
| 06-14-2006, 06:36 AM | #3 |
Eventually you can use the trick with local globals, and put a Trigger: Custom Script: local integer bj_forLoopAIndexYou can only use this bug on one variable per trigger, though. And it will cause problems if you use stuff like Pick Every Units In <Something> or Pick Every Player In <Something> in your trigger. |
| 06-14-2006, 09:05 AM | #4 |
ok i took the time and read vexorians post on local variables to understand them a little better found here. So, all I have to do is put this line of custom text at the start of the trigger, and refer to that integer instead of using integer A? Trigger: AutoUpgradeSuperSpeed![]() Conditions![]() Actions![]() ![]() Custom script: local integer udg_localinteger![]() ![]() For each (Integer localinteger) from 1 to 6, do (Actions)![]() ![]() ![]() Loop - Actions![]() ![]() ![]() ![]() If (All Conditions are True) then do (Then Actions) else do (Else Actions)![]() ![]() ![]() ![]() ![]() If - Conditions![]() ![]() ![]() ![]() ![]() ![]() (Unit-type of ShrineTracker[localinteger]) Equal to SuperSpeed Shrine Lvl 1![]() ![]() ![]() ![]() ![]() ![]() Income[localinteger] Greater than or equal to 2000![]() ![]() ![]() ![]() ![]() Then - Actions![]() ![]() ![]() ![]() ![]() ![]() Wait 0.50 seconds![]() ![]() ![]() ![]() ![]() ![]() Unit - Replace ShrineTracker[localinteger] with a SuperSpeed Shrine Lvl 2 using The new unit's default life and mana![]() ![]() ![]() ![]() ![]() ![]() Selection - Select (Last replaced unit) for (Player(localinteger))![]() ![]() ![]() ![]() ![]() ![]() Set ShrineTracker[localinteger] = (Last replaced unit)![]() ![]() ![]() ![]() ![]() ![]() Game - Display to (Player(localinteger)), at offset (0.00, 0.00) the text: |c0000cdf9Your inco...![]() ![]() ![]() ![]() ![]() Else - Actionscorrect me if this is wrong. Edit: Ok, in this case it is wrong. After reading a little more thoroughly about this subject and testing this failed trigger, I learned that locals cannot be used in the if/then/else actions. this creates a problem in the case i need the conditions to be checked every 8 seconds and match the player inside of the loop, but in this case, how can it be avoided? Should I just use a different global for each trigger that uses if/then/else instead? The above trigger crashed my game when it fired, but didn't when i removed the custom text. And one last thing. The reason I use the wait command at all is because for some reason without that small delay the shrine sometimes did not get replaced. Using the wait fixed that but caused this problem. |
| 05-09-2007, 10:29 PM | #5 |
hmm, i say you global idea. WAIT command in loop with "integer A" or "integer B" will make a bug if TWO or more loops runs at one time. Example: loop1 starts and when a=3 starts loop2. loop2 sets a=1 while loop1 is waiting. understand? A is global variable for all loops. if you want to run loops with wait action at one time, use local variables. you can use custom scrips for this idea. Custom script: local integer a Custom script: set a = 1 Custom script: loop Custom script: exitwhen a > 20 Unit - Move air instantly to ((Position of land) offset by (((Distance between (Position of air) and (Position of land)) x 0.90) - 1.00) towards (Angle from (Position of land) to (Position of air)) degrees), facing ((Facing of land) + (((Facing of air) - (Facing of land)) x 0.80)) degrees Wait 0.05 seconds Custom script: set a = a + 1 Custom script: endloop |
