Trying to do Inventory, Tons of Errors

private var slot1 = 0;
private var slot2 = 0;
private var slot3 = 0;
private var slot4 = 0;
private var slot5 = 0;
private var slot6 = 0;
private var slot7 = 0;
private var slot8 = 0;
private var slot9 = 0;
private var slot10 = 0;
private var keepChecking : boolean = true;

function OnCollisionEnter (collision : Collision) {

//Iron Sword
if(collision.gameObject.tag == "Iron Sword Entity"  slot1 = 0){

slot1 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot1 != 0){

slot2 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot2 != 0){

slot3 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot3 != 0){

slot4 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot4 != 0){

slot5 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot5 != 0){

slot6 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot6 != 0){

slot7 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot7 != 0){

slot8 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot8 != 0){

slot9 = 1;
keepChecking = false;
}

if(collision.gameObject.tag == "Iron Sword Entity"  slot9 != 0){

slot10 = 1;
keepChecking = false;
}
}

This returns a ton of errors. Ideas?

Line 16.

… I could have let the error tell me that. Maybe try explaining whats wrong?

First of all, look into using arrays (built-in, not the fancy UnityScript Array class)

Second, you are assigning slot1 to 0 rather than comparing

= is assignment
== is comparison

I was about to show you what it would look like with arrays, until I realized I have no idea what that code is supposed to do…

Thirdly, use your eyes.
And fourthly and most importantly… Don’t be a dick.

Anyway, I figured it out.

renman, you’ve replied to a lot of my posts. 0 of those have helped me in any way. You think I can’t read the error and tell there’s something wrong with line 16?

Palm.
Look, i thought maybe you would see it. Were you the one lecturing about how i could not code yet you cant spot that error???

And if that is the only error, then why would you not just post line 16 if you could not see it for yourself?

Dummy.

After much deliberation, I have decided that checking the contents of slot1 twice was a typo, and that you wish for it to break after one is found. Here is what the above looks like with arrays:

private var slots : int[];

function OnCollisionEnter (collision : Collision) {
    if (collision.gameObject.tag == "Iron Sword Entity") {
        for (var i : int=0; i<slots.Length; i++) {
            if (slots[i] != 0) {
                slots[i] = 1;
                break;
            }
        }
    }
}

OhLogical you should do a lot of tutorials before you start your own stuff.
Try this :

http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial
believe me you will never use something like this again:

private var slot1 = 0;

private var slot2 = 0;

private var slot3 = 0;

private var slot4 = 0;

private var slot5 = 0;

private var slot6 = 0;

private var slot7 = 0;

private var slot8 = 0;

private var slot9 = 0;

private var slot10 = 0;

Ok. I’ll just quit coding now because I forgot to put one = sign. Thanks for the advice.

I did it that way for a reason. I’m not new at this.

Please, don’t get me wrong. I am a noob myself. Can you image how often I mix up = and == ?
That happens to the best of us, I think :slight_smile:
I still do tutorials, this isn’t just for idiots. Tutorials are for people who wanna learn stuff. And believe me you in particular have to do a lot tutorials. But me too.

Everybody overlooks little mistakes… Markus speaks the truth. I would advise on using an InventoryItem class to show item values like durability, damage, and stuff like that, then make an array of GUI Buttons to display the items to equip/unequip.