Hey! In case it’s not already clear, I’m quite new to this forum. However whenever I have encountered problems I have usually googled myself to this wonderful site called Kirupa.com But enough of the flattering I suppose. Here’s my dilemma, and any help is appreciated…
Here’s the code, so far…
on (release) {
var i:Number;
var i2:Number;
for (i = 0; _root.itemsINinventory == “FOOD_fish”; i++) {
trace(“you added more fish to your inventory”);
}
for (i2 = 0; _root.itemsINinventory == 0;) {
_root.itemsINinventory* = “FOOD_fish”;
i++
}
}
**The problems are as follows:
I want the loop to check through the Array (itemsINinventory) until it find a value equal to (in this case) FOOD_fish. As soon as it finds FOOD_fish, I want the loop to stop and increase the current subarray value by one (+1)… *[1]
NOW, say that after checking through the Array (itemsINinventory), it never finds the value “FOOD_fish”, if this is the case then I want it to…
check through the Array (itemsINinventory) again until it finds a value == 0 (this means the inventory slot is empty). when it has done so I want the loop to stop, and for it to add the FOOD_fish value to itemsINinventory*
and thirdly… if neither of the above conditions occur I… well let’s just do a trace action for now…
For the love of anyone’s God I can not get this to work… the best so far I have accomplished is to get it to add the FOOD_fish value to all of the subarrays *
Which in itself looks quite funny, but not what I want…
Help?
EDIT!
More or less fixed it myself… however this code does not work like it should still… because you are supposed to be able add other items as well, which does not occur…
*on (release) {
var i:Number;
var e:Number;
noITEMfound = “false”;
trace(_root.itemsINinventory);
for (i = 0; _root.itemsINinventory == “FOOD_fish”; i++) {
noITEMfound = “true”;
trace(“you have two fishies… LOL”);
}
if(noITEMfound == "false") {
for (e = 0; _root.itemsINinventory[e] == 0; e++) {
_root.itemsINinventory[e] = "FOOD_fish";
e--
}
}
}**