Warcraft III resources & community, 2003–2006 · archived

Count Items Of Type

not rated
Submitted by BertTheJasserFunctions0 downloads
This counts all Items in an "rect" of a give type.

Source

constant function WhichItemType takes nothing returns integer
  return 'XXXX'
endfunction

function CountItem takes nothing returns nothing
  set bj_forLoopAIndex=bj_forLoopAIndex+1
endfunction

function IsItemType takes nothing returns boolean
  return GetItemTypeId(GetFilterItem())==WhichItemType()
endfunction

function CountFolianteInRect takes rect r returns integer
 local integer n
  set bj_forLoopAIndex=0
  call EnumItemsInRect(r,Condition(function IsItemType),function CountItem)
  set n=bj_forLoopAIndex
return n
endfunction

Comments

5
I hate the handle Vars, I wanted to make it usable for everybody.

Probably i submit a advanced Version of the Handle Vars, probably.
Ok quite stupid my first comment, but it seems dumb, you could attach it to the rect using handles..
Didn't know that darky is inaktiv.

I used bj_forLoopAIndex, because i need it in 2 functions . Local vars are only in 1 function usable.

I'm already member of TheJassVault.
I guess we have to live with the duble thing...

But DON'T expect Darky to do that... He's quote inactive if you have noticed that...

(Just to say what I've said a thousand times before): WE NEED A JASS SECTION MOD... THAT'S ONE OF THE REASON I POST MY SCRIPTS AT THE JASS VAULT

OK func, but using bj_forLoopAIndex seems dumb in Jass, just use a local int.
Sorry for Double Submitting, the first time I submitted I forgott the name and now I can't delet the other one. Maybe Darky will do that.