Trying to create a custom class array

I’m kinda new to Unity and Javascript and working on a simple roguelike game. I’m trying to create an array of a custom “Weapon” class but getting error messages. The code goes like this:

class Weapon {
	var name : String;
	var minDamage : int;
	var maxDamage : int;
	var textureOffset : Vector2;
};

var weaponList : Weapon[];

function Start () {
	initWeaponList();
}

function initWeaponList () {

	weaponList[0].name = "Branch";
	weaponList[0].minDamage = 1;
	weaponList[0].maxDamage = 1;
	weaponList[0].textureOffset = Vector2(0,0);
	
	weaponList[1].name = "Short Sword";
	weaponList[1].minDamage = 1;
	weaponList[1].maxDamage = 2;
	weaponList[1].textureOffset = Vector2(0.125,0);
}

What’s wrong with this code? I’ve checked around on this board and in the Unity script references, and tried a couple other ways to do this, but nothing seems to work. Help would be appreciated!

You need to initialise the array. As it stands, you have the name of an array, with no array attached.

function initWeaponList () {
    weaponList=new Weapon[2];
    weaponList[0]=new Weapon();
    weaponList[0].name = "Branch";
    weaponList[0].minDamage = 1;
    weaponList[0].maxDamage = 1;
    weaponList[0].textureOffset = Vector2(0,0);
     
    weaponList[1]=new Weapon();
    weaponList[1].name = "Short Sword";
    weaponList[1].minDamage = 1;
    weaponList[1].maxDamage = 2;
    weaponList[1].textureOffset = Vector2(0.125,0);</PRE>
}