Iterating through inventory question
Posted: Thu Jan 24, 2013 4:14 am
I was playing around with this script. It also me to check and see if a champion in the adventures group is wearing Boots of Valor, and if not open a secret door:
Can this be easily modified to iterate through a set of items, instead of specifying a set of identical functions?
I tried some basic iteration and I think my logic is flawed....
Can I call an itteration function from this one and then call back to this function, so the "local currItem" is always different?
Or am I approaching this the wrong way?
Code: Select all
function itemCheckbootsvalor()
local thisPlayer = 1
local itemSlot = 1
local currItem
for thisPlayer=1,4,1 do
for itemSlot=1,31,1 do
if party:getChampion(thisPlayer):getItem(itemSlot) ~= nil then
currItem = party:getChampion(thisPlayer):getItem(itemSlot).name
if currItem == “boots_valor” then
return true
else
secret_door:open()
end
end
itemSlot = itemSlot + 1
end
thisPlayer = thisPlayer + 1
end
end
Can this be easily modified to iterate through a set of items, instead of specifying a set of identical functions?
I tried some basic iteration and I think my logic is flawed....
Can I call an itteration function from this one and then call back to this function, so the "local currItem" is always different?
Or am I approaching this the wrong way?