• 🏆 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!

[Trigger] Can i write this shorter somehow :D ???

Status
Not open for further replies.
Level 11
Joined
Jul 28, 2007
Messages
920
  • Add Scrolls Orc
    • Events
    • Conditions
    • Actions
      • -------- orc grunt --------
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Hero[(Integer A)] in slot 1)) Equal to Orc Grunt
              • ((Owner of Hero[(Integer A)]) Current lumber) Greater than or equal to focus_orc_grunt
            • Then - Actions
              • Item - Remove (Item carried by Hero[(Integer A)] in slot 1)
              • Wait 0.01 seconds
              • Custom script: call UnitAddItemToSlotById( udg_Hero[GetForLoopIndexA()] , 'I00F' , 0 )
            • Else - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Hero[(Integer A)] in slot 2)) Equal to Orc Grunt
              • ((Owner of Hero[(Integer A)]) Current lumber) Greater than or equal to focus_orc_grunt
            • Then - Actions
              • Item - Remove (Item carried by Hero[(Integer A)] in slot 2)
              • Wait 0.01 seconds
              • Custom script: call UnitAddItemToSlotById( udg_Hero[GetForLoopIndexA()] , 'I00F' , 1 )
            • Else - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Hero[(Integer A)] in slot 3)) Equal to Orc Grunt
              • ((Owner of Hero[(Integer A)]) Current lumber) Greater than or equal to focus_orc_grunt
            • Then - Actions
              • Item - Remove (Item carried by Hero[(Integer A)] in slot 3)
              • Wait 0.01 seconds
              • Custom script: call UnitAddItemToSlotById( udg_Hero[GetForLoopIndexA()] , 'I00F' , 2 )
            • Else - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Hero[(Integer A)] in slot 4)) Equal to Orc Grunt
              • ((Owner of Hero[(Integer A)]) Current lumber) Greater than or equal to focus_orc_grunt
            • Then - Actions
              • Item - Remove (Item carried by Hero[(Integer A)] in slot 4)
              • Wait 0.01 seconds
              • Custom script: call UnitAddItemToSlotById( udg_Hero[GetForLoopIndexA()] , 'I00F' , 3 )
            • Else - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Hero[(Integer A)] in slot 5)) Equal to Orc Grunt
              • ((Owner of Hero[(Integer A)]) Current lumber) Greater than or equal to focus_orc_grunt
            • Then - Actions
              • Item - Remove (Item carried by Hero[(Integer A)] in slot 5)
              • Wait 0.01 seconds
              • Custom script: call UnitAddItemToSlotById( udg_Hero[GetForLoopIndexA()] , 'I00F' , 4 )
            • Else - Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Hero[(Integer A)] in slot 6)) Equal to Orc Grunt
              • ((Owner of Hero[(Integer A)]) Current lumber) Greater than or equal to focus_orc_grunt
            • Then - Actions
              • Item - Remove (Item carried by Hero[(Integer A)] in slot 6)
              • Wait 0.01 seconds
              • Custom script: call UnitAddItemToSlotById( udg_Hero[GetForLoopIndexA()] , 'I00F' , 5 )
            • Else - Actions
 
Last edited by a moderator:
Level 40
Joined
Dec 14, 2005
Messages
10,532
Edited for trigger tags.

And you can nest an Integer B loop to shorten that by 6x:

  • Add Scrolls Orc
    • Events
    • Conditions
    • Actions
      • -------- orc grunt --------
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 6, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item carried by Hero[(Integer A)] in slot (Integer B))) Equal to Orc Grunt
                  • ((Owner of Hero[(Integer A)]) Current lumber) Greater than or equal to focus_orc_grunt
                • Then - Actions
                  • Item - Remove (Item carried by Hero[(Integer A)] in slot (Integer B))
                  • Wait 0.01 seconds
                  • Custom script: call UnitAddItemToSlotById( udg_Hero[GetForLoopIndexA()] , 'I00F' , bj_forLoopBIndex - 1 )
                • Else - Actions
 
Status
Not open for further replies.
Top