So, i have a list of items like so
var itemList = new Item[40];
class Item {
var itemName : String;
var PrereqItem1 : String;
var PrereqItem2 : String;
var sellPrice : int;
var weight : float;
var quantityInInventory : int;
}
And in a seperate file i have a function which, on fired, i would like to return the value of an item based off the two items the player has selected. So far the function looks like this:
function SearchList(){
for (var i : int = 0; i < Inv.itemList.length; i++) {
if (item1 == Inv.itemList.PrereqItem1 && item2 == Inv.itemList.PrereqItem2){
Result = Inv.itemList.itemName;
}
}
}
So, as an example, the player might select a fish (item 1) and a pizza (item 2), and click the button. The code will then search the list for an item that has both the prerequisites of pizza and fish, then return the name of “fish pizza”.
My issue is that i cannot work out how to word the if statement so it…well…works. I suspect the answer is simple, but i’m currently staring at the wood and wondering where the trees are.
Any help you guys can give will be much appreciated.