Trigger Causes Crash

Level 7
Joined
Nov 18, 2012
Messages
272
[Solved] Trigger Causes Crash

  • Backpacks and Pouches
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Backpack
          • (Item-type of (Item being manipulated)) Equal to Pouch
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Pouch
          • (Level of Inventory (Simple) for (Hero manipulating item)) Equal to 1
        • Then - Actions
          • For each (Integer Inventory) from 1 to 2, do (Actions)
            • Loop - Actions
              • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
              • Hero - Drop Item[Inventory] from (Hero manipulating item)
          • Unit - Remove Inventory (Simple) from (Hero manipulating item)
          • Unit - Add Inventory (BackPack 1) to (Hero manipulating item)
          • For each (Integer Inventory) from 1 to 2, do (Actions)
            • Loop - Actions
              • Hero - Give Item[Inventory] to (Hero manipulating item)
              • Set Item[Inventory] = No item
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Backpack
              • (Level of Inventory (Simple) for (Hero manipulating item)) Equal to 1
            • Then - Actions
              • For each (Integer Inventory) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
                  • Hero - Drop Item[Inventory] from (Hero manipulating item)
              • Unit - Remove Inventory (Simple) from (Hero manipulating item)
              • Unit - Add Inventory (BackPack 2) to (Hero manipulating item)
              • For each (Integer Inventory) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Hero - Give Item[Inventory] to (Hero manipulating item)
                  • Set Item[Inventory] = No item
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-type of (Item being manipulated)) Equal to Backpack
                  • (Level of Inventory (BackPack 1) for (Hero manipulating item)) Equal to 1
                • Then - Actions
                  • For each (Integer Inventory) from 1 to 4, do (Actions)
                    • Loop - Actions
                      • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
                      • Hero - Drop Item[Inventory] from (Hero manipulating item)
                  • Unit - Remove Inventory (BackPack 1) from (Hero manipulating item)
                  • Unit - Add Inventory (BackPack 2) to (Hero manipulating item)
                  • For each (Integer Inventory) from 1 to 4, do (Actions)
                    • Loop - Actions
                      • Hero - Give Item[Inventory] to (Hero manipulating item)
                      • Set Item[Inventory] = No item
                • Else - Actions
                  • Do nothing
Trigger is pretty self explanatory (I hope)

What's wrong with it?
 
Last edited:
Level 7
Joined
Nov 18, 2012
Messages
272
Will this do?
  • Backpacks and Pouches
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Backpack
          • (Item-type of (Item being manipulated)) Equal to Pouch
    • Actions
      • Trigger - Turn off (This trigger)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to Pouch
          • (Level of Inventory (Simple) for (Hero manipulating item)) Equal to 1
        • Then - Actions
          • For each (Integer Inventory) from 1 to 2, do (Actions)
            • Loop - Actions
              • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
              • Hero - Drop Item[Inventory] from (Hero manipulating item)
          • Unit - Remove Inventory (Simple) from (Hero manipulating item)
          • Unit - Add Inventory (BackPack 1) to (Hero manipulating item)
          • For each (Integer Inventory) from 1 to 2, do (Actions)
            • Loop - Actions
              • Hero - Give Item[Inventory] to (Hero manipulating item)
              • Set Item[Inventory] = No item
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item being manipulated)) Equal to Backpack
              • (Level of Inventory (Simple) for (Hero manipulating item)) Equal to 1
            • Then - Actions
              • For each (Integer Inventory) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Set Item[Inventory] = (Item carried by (Hero manipulating item) in slot Inventory)
                  • Hero - Drop Item[Inventory] from (Hero manipulating item)
              • Unit - Remove Inventory (Simple) from (Hero manipulating item)
              • Unit - Add Inventory (BackPack 2) to (Hero manipulating item)
              • For each (Integer Inventory) from 1 to 4, do (Actions)
                • Loop - Actions
                  • Hero - Give Item[Inventory] to (Hero manipulating item)
                  • Set Item[Inventory] = No item
            • Else - Actions
              • Do nothing
      • Trigger - Turn on (This trigger)
 
Level 5
Joined
Nov 30, 2012
Messages
200
It's probably because you're using the Event - A Unit Acquires an Item, which will fire every time a unit gets an item (of course), but the problem arises when the unit is given an item that will fire the trigger again, leading to an endless loop. Try implementing Faestus' changes, i.e. turning off the trigger then turning it on again.
 
Top