• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

If too many if then else is used in one trigger does that cause it to be disabled?

Status
Not open for further replies.
Level 8
Joined
Nov 21, 2008
Messages
316
The reason i ask if too many if then else's are used in one trigger can is cause a trigger to be disabled is because im getting an error after i decided to combine many of the simple triggers i had in my map. it says script error. all all the triggers work separately.

ex... all triggers which i combined follow this format.
  • Taurania Spawns
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Trained unit)) Equal to Kodo Beast (Tauren)
        • Then - Actions
          • Set KodoBeast = (KodoBeast + 1)
          • Unit - Remove (Trained unit) from the game
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Tauren
            • Then - Actions
              • Set Tauren = (Tauren + 1)
              • Unit - Remove (Trained unit) from the game
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Trained unit)) Equal to Sprit Walker
                • Then - Actions
                  • Set Spritwalker = (Spritwalker + 1)
                  • Unit - Remove (Trained unit) from the game
                • Else - Actions
  • Centrax Spawns
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Trained unit)) Equal to Centaur Khan
        • Then - Actions
          • Set CentaurKahn = (CentaurKahn + 1)
          • Unit - Remove (Trained unit) from the game
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Centaur Archer
            • Then - Actions
              • Set CentaurArcher = (CentaurArcher + 1)
              • Unit - Remove (Trained unit) from the game
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Unit-type of (Trained unit)) Equal to Centaur Sorcerer
                • Then - Actions
                  • Set CentaurSorcerer = (CentaurSorcerer + 1)
                  • Unit - Remove (Trained unit) from the game
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Trained unit)) Equal to Centaur Drudge
                    • Then - Actions
                      • Set CentaurDrudge = (CentaurDrudge + 1)
                      • Unit - Remove (Trained unit) from the game
                    • Else - Actions
there are 36 bases so i did triggers like this for each base. and combined them since they are all pretty similar, so why do they work separate but when i put em all in one they don't work?
 
Level 8
Joined
Nov 21, 2008
Messages
316
The trigger spawns/baseburn are the ones that stopped working after i combined the triggers similar into one. there use to b 36 burns and 36 spawn triggers but now i did them into 1 of each
 

Attachments

  • Brokenalliances2ccccccccc.w3x
    1,009.8 KB · Views: 44
Level 37
Joined
Mar 6, 2006
Messages
9,240
You can get around that by using arrays and loops. Create a unit type array, put your units there. Create an integer array. Then loop through the unit type array and when match is found, increase the corresponding integer.

MaxIndex is the maximum index of the unit type array that's used for a unit type.

For example:
UnitTypes[0] = Footman
UnitTypes[1] = Knight
UnitTypes[2] = Rifleman

MaxIndex would be 2 there.

  • Untitled Trigger 002
    • Events
    • Conditions
    • Actions
      • Set UnitType = (Unit-type of (Trained unit))
      • For each (Integer loopA) from 0 to MaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UnitType Equal to UnitTypes[loopA]
            • Then - Actions
              • Set UnitCount[loopA] = (UnitCount[loopA] + 1)
              • Unit - Remove (Trained unit) from the game
              • Skip remaining actions
            • Else - Actions
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Yes, there are 100% without a doubt a limit to the number of If statements allowed in both JASS and GUI. While I'm unfamiliar with the GUI limit (Probably 36), the JASS limit exists and I've encountered it. I think I encountered it mainly through an elseif limit, but I could be wrong. It doesn't compile with an error, it just fails to run anything past a certain if limit and the thread stops.
 
Status
Not open for further replies.
Top