Im trying to make an inventory. Everything works perfectly except for one thing, when scrolling between items i noticed all “strings” listed are seperated like this: (m,e,yo,u,h,er,hi,m). I dont want commas at all… can anyone see why this random comma appears to be seperating my strings? i use Unityscript / Javascript.
var itembagCursor : int = 0;
var itembagCursorMax : int = 0;
var selectedItem;
var selecteditemname;
function Start(){
Master.itembag.AddRange(Array("potion","shard","antidote")); //add item to inventory
itembagCursorMax = itembagCursorMax + 2;
Master.inventory.AddRange(Array("key","key","ammo","ammo")); //add multiple items
Master.inventory.Sort(); //sort inventory
Master.inventory.Remove("ammo"); //remove first instance of item
}
function Update(){
selectedItem = Array(Master.itembag[itembagCursor]).ToString();
if(Input.GetKeyDown(KeyCode.LeftArrow)){
itembagCursor = itembagCursor - 1;
}
if(Input.GetKeyDown(KeyCode.RightArrow)){
itembagCursor = itembagCursor + 1;
}
if(itembagCursor > itembagCursorMax){
itembagCursor = 0;
}
if(itembagCursor < 0){
itembagCursor = itembagCursorMax;
}
}
function OnGUI(){
GUI.Label(Rect(0,0,400,50), "Inventory: " + Array(Master.inventory)); //display inventory by converting it to an array
GUI.Label(Rect(Screen.width/2 - 200,Screen.height - 50,400,50),selectedItem);
}