• 🏆 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] This loops ten times when it shouldn't

Status
Not open for further replies.
Could anyone help me find the problem and solution to it?

It is an item recipe system however our resource database was no help because its 3 or more items required for one recipe and one of the recipes of 3 of the same item-type and since there is basically none of said type of recipe system... yeah in a problem. :goblin_cry: Though there might be a VJASS one, I never decided to check because well I need a GUI solution.

[trigger=]
Events
Map initialization
Conditions
Actions
-------- --------
Set item1[1] = Claws of Attack +3
Set item2[1] = Claws of Attack +3
Set recipe[1] = Claws of Attack +3
Set output[1] = |cff8E388E[1337]|r |cffFF0000Blitzkrieg Blade|r
Set itemamountreq[1] = 3
-------- --------
Set item1[2] = Claws of Attack +3
Set item2[2] = Claws of Attack +3
Set recipe[2] = Mooncrystal
Set output[2] = Crown of Kings +5
Set itemamountreq[2] = 3
-------- --------
Set recipes_ammount = 2

[/trigger]


[trigger=]
Events
Unit - A unit Acquires an item
Conditions
Actions
Trigger - Turn off (This trigger)
For each (Integer A) from 1 to 6, do (Actions)
Loop - Actions
Set itemslot[(Integer A)] = No item
For each (Integer ItemRun) from 1 to recipes_ammount, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item being manipulated)) Equal to recipe[ItemRun]
Then - 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 carried by (Triggering unit) in slot (Integer A)) Not equal to itemslot[(Integer A)]
Or - Any (Conditions) are true
Conditions
((Triggering unit) has an item of type item1[ItemRun]) Equal to True
((Triggering unit) has an item of type item2[ItemRun]) Equal to True
((Triggering unit) has an item of type recipe[ItemRun]) Equal to True
Then - Actions
Set itemslot[(Integer A)] = (Item carried by (Triggering unit) in slot (Integer A))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Integer A) Equal to 3
Then - Actions
Hero - Create output[ItemRun] and give it to (Triggering unit)
Game - Display to (All players) the text: (String((Integer A)))
Game - Display to (All players) the text: (Name of (Item carried by (Triggering unit) of type item1[ItemRun]))
Game - Display to (All players) the text: (Name of (Item carried by (Triggering unit) of type item2[ItemRun]))
Game - Display to (All players) the text: (Name of (Item carried by (Triggering unit) of type recipe[ItemRun]))
Game - Display to (All players) the text: (Name of (Item carried by (Triggering unit) of type output[ItemRun]))
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 carried by (Triggering unit) in slot (Integer A)) Equal to itemslot[(Integer A)]
Then - Actions
Item - Remove itemslot[(Integer A)]
Set itemslot[(Integer A)] = No item
Else - Actions
Else - Actions
Else - Actions
Else - Actions
Trigger - Turn on (This trigger)

[/trigger]
 
Last edited:
Level 23
Joined
Apr 16, 2012
Messages
4,041
As DSG pointed out, you have potentionally infinite recursion in there because you fire this event wheb unit receives item, and at that point you potentionally give him item, causing it to fire again and again and again.
 
I forgot the other item-types, that might explain it. . .

Sorry guys, will edit or reply if I can't solve it.

EDIT: Remade it yet again and can't solve it. Everything has been fixed except yet another issue has risen.

Whenever items get combined in the first 3 slots, it will mess up and only make the first recipe.
 
Last edited:
Status
Not open for further replies.
Top