u: The Unit
t: The item Type
c: Count of items of type t
i: Loop Variable
function CountItemsOfType takes unit u, integer t returns integer
local integer c = 0
local integer i = 0
loop
exitwhen i > UnitInventorySizeBJ(u)
if GetItemTypeId(UnitItemInSlot(u, i)) == t then
set c = c + 1
endif
endloop
return c
endfunction
Events
Conditions
Actions
set count = 0 // Missed that but fixed now, thanks
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 <Some Unit> in slot (Integer A))) Equal to <Some Item Type>
Then - Actions
Set count = (count + 1)
Else - Actions
---- No need to do anything ----
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
count Less than 2
Then - Actions
Skip remaining actions
Else - Actions
You need to set count to 0 before the loopphyrex1an said:You dont need jass for this, well the jass version is much better if it is realy used as a condition and not a set global then check global vaule as you have to do if you want the rest of your trigger to be in GUI format.
Here is the gui version then, recuires one integer variable. Here called count.
Code:Events Conditions 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 <Some Unit> in slot (Integer A))) Equal to <Some Item Type> Then - Actions Set count = (count + 1) Else - Actions ---- No need to do anything ---- If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions count Less than 2 Then - Actions Skip remaining actions Else - Actions
And you should learn jass anyway, it is a great help. And you can use all cool jass spells and systems outthere without any problems. You create your functions above all triggers, where the name of the map is, the custom script section.