MrMonotone
2015-02-10 21:06:32
How to check if an axe is in our inventory.
How to check if its equipped. Is basically the same.
Now we can easily check if either are true.
One could potentially pass an array of string (Item names) and check if any of them are inside the inventory if you are looking for multiple items. I will let you figure that out though.
function GearInInventory : Boolean;
var
Inventory : TReflectInvItemArray; {Our inventory}
I : Integer;
begin
Inventory.GetAll; {Gets the items in our inventory}
for I:= 0 to High(Inventory) do {for every item in our inventory}
if (Pos('axe',Inventory[I].Name) > 0) then {Check if substring on right contains axe}
begin
MyLogger.Status(Inventory[I].Name + ' in inventory'); {Print out the axe}
Result:= true;
end;
end;
How to check if its equipped. Is basically the same.
function GearEquipped : Boolean;
var
Equipment : TReflectWornEquipmentArray;
I : Integer;
begin
Equipment.GetAll;
for I:= 0 to High(Equipment) do
if (Pos('axe',Equipment[I].Name) > 0) then
begin
MyLogger.Status(Equipment[I].Name + ' equipped.');
Result:= true;
break;
end;
end;
Now we can easily check if either are true.
function HasGear : Boolean;
begin
Result:= GearInInventory OR GearEquipped;
end;
One could potentially pass an array of string (Item names) and check if any of them are inside the inventory if you are looking for multiple items. I will let you figure that out though.