Alright, I'm stumped to why one of the functions is not working. I have three functions dealing with items(part of an item stacking script) They all have the same three arguements and I know for a fact the third one(AddItem) works as it triggers as a result of the first function(checkexistingitems) always returns false even if there is the same item.
I'm using the same three inputs for the arguments on all of them. So why is the first function failing?
Thanks
JASS:
function CheckExistingItems takes unit u, integer i, integer r returns boolean
if (r == 0) then
if (GetInventoryIndexOfItemTypeBJ(u, udg_Human_item<i>) > 0) then
return true
endif
endif
if (r == 1) then
if (GetInventoryIndexOfItemTypeBJ(u, udg_Orc_item<i>) > 0) then
return true
endif
endif
if (r == 2) then
if (GetInventoryIndexOfItemTypeBJ(u, udg_Nightelf_item<i>) > 0) then
return true
endif
endif
if (r == 3) then
if (GetInventoryIndexOfItemTypeBJ(u, udg_Human_item<i>) > 0) then
return true
endif
endif
return false
endfunction
function AddItemCharge takes unit u, integer i, integer r returns boolean
if (r == 0) then
call SetItemCharges( GetItemOfTypeFromUnitBJ(u, udg_Human_item<i>), GetItemCharges(GetItemOfTypeFromUnitBJ(u, udg_Human_item<i>)) + 1)
else
if (r == 1) then
call SetItemCharges( GetItemOfTypeFromUnitBJ(u, udg_Orc_item<i>), GetItemCharges(GetItemOfTypeFromUnitBJ(u, udg_Orc_item<i>)) + 1)
else
if (r == 2) then
call SetItemCharges( GetItemOfTypeFromUnitBJ(u, udg_Nightelf_item<i>), GetItemCharges(GetItemOfTypeFromUnitBJ(u, udg_Nightelf_item<i>)) + 1)
else
if (r == 3) then
call SetItemCharges( GetItemOfTypeFromUnitBJ(u, udg_Undead_item<i>), GetItemCharges(GetItemOfTypeFromUnitBJ(u, udg_Undead_item<i>)) + 1)
endif
endif
endif
endif
return false
endfunction
function AddItem takes unit u, integer i, integer r returns boolean
if (r == 0) then
call UnitAddItemByIdSwapped( udg_Human_item<i>, u )
else
if (r == 1) then
call UnitAddItemByIdSwapped( udg_Orc_item<i>, u )
else
if (r == 2) then
call UnitAddItemByIdSwapped( udg_Nightelf_item<i>, u )
else
if (r == 3) then
call UnitAddItemByIdSwapped( udg_Undead_item<i>, u )
endif
endif
endif
endif
return false
endfunction</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
I'm using the same three inputs for the arguments on all of them. So why is the first function failing?
Thanks