- Home /
need to shorten my code but unsure of how
 #pragma strict
 var slots = 1;
 var    slot1empty : boolean = false;
 var slot2empty : boolean = false;
 var slot3empty : boolean = false;
 var slot4empty : boolean = false;
 var slot5empty : boolean = false;
 var slot6empty : boolean = false;
 var slot7empty : boolean = false;
 var slot8empty : boolean = false;
 var slot9empty : boolean = false;
 var slot10empty : boolean = false;
 var slot11empty    : boolean = false;
 var slot12empty    : boolean = false;
 var slot13empty    : boolean = false;
 var slot14empty    : boolean = false;
 var slot15empty : boolean = false;
 var slot16empty    : boolean = false;
 var slot17empty    : boolean = false;
 var slot18empty    : boolean = false;
 var slot19empty    : boolean = false;
 var slot20empty : boolean = false;
 var slot21empty : boolean = false;
 var slot22empty : boolean = false;
 var slot23empty : boolean = false;
 var slot24empty : boolean = false;
 var slot25empty : boolean = false;
 var slot26empty : boolean = false;
 var slot27empty : boolean = false;
 var slot28empty : boolean = false;
 
 var item1d : boolean = false;
 var item2d : boolean = false;
 
 var item1 = "";
 var item2 = "";
 var item3 = "";
 var item4 = "";
 var item5 = "";
 var item6 = "";
 var item7 = "";
 var item8 = "";
 var item9 = "";
 var item10 = "";
 var item11 = "";
 var item12 = "";
 var item13 = "";
 var item14 = "";
 var item15 = "";
 var item16 = "";
 var item17 = "";
 var item18 = "";
 var item19 = "";
 var item20 = "";
 var item21 = "";
 var item22 = "";
 var item23 = "";
 var item24 = "";
 var item25 = "";
 var item26 = "";
 var item27 = "";
 var item28 = "";
 
 var s1 = "Slot";
 var s2 = "Slot";
 var s3 = "Slot";
 var s4 = "Slot";
 var s5 = "Slot";
 var s6 = "Slot";
 var s7 = "Slot";
 var s8 = "Slot";
 var s9 = "Slot";
 var s10 = "Slot";
 var s11 = "Slot";
 var s12 = "Slot";
 var s13 = "Slot";
 var s14 = "Slot";
 var s15 = "Slot";
 var s16 = "Slot";
 var s17 = "Slot";
 var s18 = "Slot";
 var s19 = "Slot";
 var s20 = "Slot";
 var s21 = "Slot";
 var s22 = "Slot";
 var s23 = "Slot";
 var s24 = "Slot";
 var s25 = "Slot";
 var s26 = "Slot";
 var s27 = "Slot";
 var s28 = "Slot";
 
 var pick = "Pick Up";
 
 var slot1;
 var slot2;
 var slot3;
 var slot4;
 var slot5;
 var slot6;
 var slot7;
 var slot8;
 var slot9;
 var slot10;
 var slot11;
 var slot12;
 var slot13;
 var slot14;
 var slot15;
 var slot16;
 var slot17;
 var slot18;
 var slot19;
 var slot20;
 var slot21;
 var slot22;
 var slot23;
 var slot24;
 var slot25;
 var slot26;
 var slot27;
 var slot28;
 
 var slot1opt : boolean = false;
 var slot2opt : boolean = false;
 var slot3opt : boolean = false;
 var slot4opt : boolean = false;
 var slot5opt : boolean = false;
 var slot6opt : boolean = false;
 var slot7opt : boolean = false;
 var slot8opt : boolean = false;
 var slot9opt : boolean = false;
 var slot10opt : boolean = false;
 var slot11opt : boolean = false;
 var slot12opt : boolean = false;
 var slot13opt : boolean = false;
 var slot14opt : boolean = false;
 var slot15opt : boolean = false;
 var slot16opt : boolean = false;
 var slot17opt : boolean = false;
 var slot18opt : boolean = false;
 var slot19opt : boolean = false;
 var slot20opt : boolean = false;
 var slot21opt : boolean = false;
 var slot22opt : boolean = false;
 var slot23opt : boolean = false;
 var slot24opt : boolean = false;
 var slot25opt : boolean = false;
 var slot26opt : boolean = false;
 var slot27opt : boolean = false;
 var slot28opt : boolean = false;
 
 var hatch : GameObject;
 var pickax : GameObject;
 var hatchc : GameObject;
 var pickaxc : GameObject;
 var item;
 
 var PickedUp1 : boolean = false;
 var PickedUp2 : boolean = false;
 var Droped1 : boolean = false;
 var Droped2 : boolean = false;
 
 var hat = "Hatched";
 var pic = "Pickax";
 
 
 function OnGUI() 
 {
     GUI.Box(Rect(0, 0, 200, 370),"Inventory");
     
     if(!slot1empty)
         {
             GUI.Box(Rect(0, 20, 50, 50), s1);
             s1 = "Slot";
         }
     
     if(!slot2empty)
         {
             GUI.Box(Rect(50, 20, 50, 50), s2);
             s2 = "Slot";
         }
     if(!slot3empty)
         {
             GUI.Box(Rect(100, 20, 50, 50), s3);
             s3 = "Slot";
         }
     if(!slot4empty)
         {
             GUI.Box(Rect(150, 20, 50, 50), s4);
             s4 = "Slot";
         }
     if(!slot5empty)
         {
             GUI.Box(Rect(0, 70, 50, 50), s5);
             s5 = "Slot";
         }
     if(!slot6empty)
         {
             GUI.Box(Rect(50, 70, 50, 50), s6);
             s6 = "Slot";
         }
     if(!slot7empty)
         {
             GUI.Box(Rect(100, 70, 50, 50), s7);
             s7 = "Slot";
         }
     if(!slot8empty)
         {
             GUI.Box(Rect(150, 70, 50, 50), s8);
             s8 = "Slot";
         }
     if(!slot9empty)
         {
             GUI.Box(Rect(0, 120, 50, 50), s9);
             s9 = "Slot";
         }
     if(!slot10empty)
         {
             GUI.Box(Rect(50, 120, 50, 50), s10);
             s10 = "Slot";
         }
     if(!slot11empty)
         {
             GUI.Box(Rect(100, 120, 50, 50), s11);
             s11 = "Slot";
         }
     if(!slot12empty)
         {
             GUI.Box(Rect(150, 120, 50, 50), s12);
             s12 = "Slot";
         }
     if(!slot13empty)
         {
             GUI.Box(Rect(0, 170, 50, 50), s13);
             s13 = "Slot";
         }
     if(!slot14empty)
         {
             GUI.Box(Rect(50, 170, 50, 50), s14);
             s14 = "Slot";
         }
     if(!slot15empty)
         {
             GUI.Box(Rect(100, 170, 50, 50), s15);
             s15 = "Slot";
         }
     if(!slot16empty)
         {
             GUI.Box(Rect(150, 170, 50, 50), s16);
             s16 = "Slot";
         }
     if(!slot17empty)
         {
             GUI.Box(Rect(0, 220, 50, 50), s17);
             s17 = "Slot";
         }
     if(!slot18empty)
         {
             GUI.Box(Rect(50, 220, 50, 50), s18);
             s18 = "Slot";
         }
     if(!slot19empty)
         {
             GUI.Box(Rect(100, 220, 50, 50), s19);
             s19 = "Slot";
         }
     if(!slot20empty)
         {
             GUI.Box(Rect(150, 220, 50, 50), s20);
             s20 = "Slot";
         }
     if(!slot21empty)
         {
             GUI.Box(Rect(0, 270, 50, 50), s21);
             s21 = "Slot";
         }
     if(!slot22empty)
         {
             GUI.Box(Rect(50, 270, 50, 50), s22);
             s22 = "Slot";
         }
     if(!slot23empty)
         {
             GUI.Box(Rect(100, 270, 50, 50), s23);
             s23 = "Slot";
         }
     if(!slot24empty)
         {
             GUI.Box(Rect(150, 270, 50, 50), s24);
             s24 = "Slot";
         }
     if(!slot25empty)
         {
             GUI.Box(Rect(0, 320, 50, 50), s25);
             s25 = "Slot";
         }
     if(!slot26empty)
         {
             GUI.Box(Rect(50, 320, 50, 50), s26);
             s26 = "Slot";
         }
     if(!slot27empty)
         {
             GUI.Box(Rect(100, 320, 50, 50), s27);
             s27 = "Slot";
         }
     if(!slot28empty)
         {
             GUI.Box(Rect(150, 320, 50, 50), s28);
             s28 = "Slot";
         }
     
     
     if(slot1empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(0, 20, 50, 50), s1))
             {
                 slot1opt = !slot1opt;
                 if(slot1opt)
                 {
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }
             
     if (slot2empty)
         {
             Destroy(GameObject.Find(Item.name + "(Clone)"));
             if(GUI.Button(Rect(50, 20, 50, 50), s2))
                 {
                     slot2opt = !slot2opt;
                     if(slot2opt)
                     {
                     slot1opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
         }
     if(slot3empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(100, 20, 50, 50), s3))
             {
                 slot3opt = !slot3opt;
                 if(slot3opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }
     if(slot4empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(150, 20, 50, 50), s4))
             {
                 slot4opt = !slot4opt;
                 if(slot4opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot5empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(0, 70, 50, 50), s5))
             {
                 slot5opt = !slot5opt;
                 if(slot5opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }
     if(slot6empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(50, 70, 50, 50), s6))
             {
                 slot6opt = !slot6opt;
                 if(slot6opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }
     if(slot7empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(100, 70, 50, 50), s7))
             {
                 slot7opt = !slot7opt;
                 if(slot7opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot8empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(150, 70, 50, 50), s8))
             {
                 slot8opt = !slot8opt;
                 if(slot8opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }        
     if(slot9empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(0, 120, 50, 50), s9))
             {
                 slot9opt = !slot9opt;
                 if(slot9opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }
     if(slot10empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(50, 120, 50, 50), s10))
             {
                 slot10opt = !slot10opt;
                 if(slot10opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }
     if(slot11empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(100, 120, 50, 50), s11))
             {
                 slot11opt = !slot11opt;
                 if(slot11opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }        
     if(slot12empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(150, 120, 50, 50), s12))
             {
                 slot12opt = !slot12opt;
                 if(slot12opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }            
     if(slot13empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(0, 170, 50, 50), s13))
             {
                 slot13opt = !slot13opt;
                 if(slot13opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }
     if(slot14empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(50, 170, 50, 50), s14))
             {
                 slot14opt = !slot14opt;
                 if(slot14opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot15empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(100, 170, 50, 50), s15))
             {
                 slot15opt = !slot15opt;
                 if(slot15opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }        
     if(slot16empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(150, 170, 50, 50), s16))
             {
                 slot16opt = !slot16opt;
                 if(slot16opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }            
     if(slot17empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(0, 220, 50, 50), s17))
             {
                 slot17opt = !slot17opt;
                 if(slot17opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }                
     if(slot18empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(50, 220, 50, 50), s18))
             {
                 slot18opt = !slot18opt;
                 if(slot18opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }                    
     if(slot19empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(100, 220, 50, 50), s19))
             {
                 slot19opt = !slot19opt;
                 if(slot19opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }
     if(slot20empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(150, 220, 50, 50), s20))
             {
                 slot20opt = !slot20opt;
                 if(slot20opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot21empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(0, 270, 50, 50), s21))
             {
                 slot21opt = !slot21opt;
                 if(slot21opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot22empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(50, 270, 50, 50), s22))
             {
                 slot22opt = !slot22opt;
                 if(slot22opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot23empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(100, 270, 50, 50), s23))
             {
                 slot23opt = !slot23opt;
                 if(slot23opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot24empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(150, 270, 50, 50), s24))
             {
                 slot24opt = !slot24opt;
                 if(slot24opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot25empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(0, 320, 50, 50), s25))
             {
                 slot25opt = !slot25opt;
                 if(slot2opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot26opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot26empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(50, 320, 50, 50), s26))
             {
                 slot26opt = !slot26opt;
                 if(slot26opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot27opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot27empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(100, 320, 50, 50), s27))
             {
                 slot27opt = !slot27opt;
                 if(slot27opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot28opt = false;
                 }
             }
     }    
     if(slot28empty)
     {
         Destroy(GameObject.Find(Item.name + "(Clone)"));
         if (GUI.Button(Rect(150, 320, 50, 50), s28))
             {
                 slot28opt = !slot28opt;
                 if(slot28opt)
                 {
                     slot1opt = false;
                     slot2opt = false;
                     slot3opt = false;
                     slot4opt = false;
                     slot5opt = false;
                     slot6opt = false;
                     slot7opt = false;
                     slot8opt = false;
                     slot9opt = false;
                     slot10opt = false;
                     slot11opt = false;
                     slot12opt = false;
                     slot13opt = false;
                     slot14opt = false;
                     slot15opt = false;
                     slot16opt = false;
                     slot17opt = false;
                     slot18opt = false;
                     slot19opt = false;
                     slot20opt = false;
                     slot21opt = false;
                     slot22opt = false;
                     slot23opt = false;
                     slot24opt = false;
                     slot25opt = false;
                     slot26opt = false;
                     slot27opt = false;
                 }
             }
     }    
     
     
     if(item1d)
     {
         if (GUI.Button(Rect(200, 100, 100, 25), pick))
         {
             Item = hatchc;
             if(slots == 1)
             {
                 s1 = "1";
                 slot1empty = true;
                 item1 = hat;
                 PickedUp1 = true;
             }
             
             if(slots == 2)
             {
                 s2 = "1";
                 slot2empty = true;
                 item2 = hat;
             }
             if(slots == 3)
             {
                 s3 = "1";
                 slot3empty = true;
                 item3 = hat;
             }
             if(slots == 4)
             {
                 s4 = "1";
                 slot4empty = true;
                 item4 = hat;
             }
             if(slots == 5)
             {
                 s5 = "1";
                 slot5empty = true;
                 item5 = hat;
             }
             if(slots == 6)
             {
                 s6 = "1";
                 slot6empty = true;
                 item6 = hat;
             }
             if(slots == 7)
             {
                 s7 = "1";
                 slot7empty = true;
                 item7 = hat;
             }
             if(slots == 8)
             {
                 s8 = "1";
                 slot8empty = true;
                 item8 = hat;
             }
             if(slots == 9)
             {
                 s9 = "1";
                 slot9empty = true;
                 item9 = hat;
             }
             if(slots == 10)
             {
                 s10 = "1";
                 slot10empty = true;
                 item10 = hat;
             }
             if(slots == 11)
             {
                 s11 = "1";
                 slot11empty = true;
                 item11 = hat;
             }
             if(slots == 12)
             {
                 s12 = "1";
                 slot12empty = true;
                 item12 = hat;
             }
             if(slots == 13)
             {
                 s13 = "1";
                 slot13empty = true;
                 item13 = hat;
             }
             if(slots == 14)
             {
                 s14 = "1";
                 slot14empty = true;
                 item14 = hat;
             }
             if(slots == 15)
             {
                 s15 = "1";
                 slot15empty = true;
                 item15 = hat;
             }
             if(slots == 16)
             {
                 s16 = "1";
                 slot16empty = true;
                 item16 = hat;
             }
             if(slots == 17)
             {
                 s17 = "1";
                 slot17empty = true;
                 item17 = hat;
             }
             if(slots == 18)
             {
                 s18 = "1";
                 slot18empty = true;
                 item18 = hat;
             }
             if(slots == 19)
             {
                 s19 = "1";
                 slot19empty = true;
                 item19 = hat;
             }
             if(slots == 20)
             {
                 s20 = "1";
                 slot20empty = true;
                 item20 = hat;
             }
             if(slots == 21)
             {
                 s21 = "1";
                 slot21empty = true;
                 item21 = hat;
             }
             if(slots == 22)
             {
                 s22 = "1";
                 slot22empty = true;
                 item22 = hat;
             }
             if(slots == 23)
             {
                 s23 = "1";
                 slot23empty = true;
                 item23 = hat;
             }
             if(slots == 24)
             {
                 s24 = "1";
                 slot24empty = true;
                 item24 = hat;
             }
             if(slots == 25)
             {
                 s25 = "1";
                 slot25empty = true;
                 item25 = hat;
             }
             if(slots == 26)
             {
                 s26 = "1";
                 slot26empty = true;
                 item26 = hat;
             }
             if(slots == 27)
             {
                 s27 = "1";
                 slot27empty = true;
                 item27 = hat;
             }
             if(slots == 28)
             {
                 s28 = "1";
                 slot28empty = true;
                 item28 = hat;
             }
             item1d = false;
         }
     }
     
     
     if(item2d)
     {
         if (GUI.Button(Rect(200, 100, 100, 25), pick))
         {
             Item = pickaxc;
             if(slots == 1)
             {
                 s1 = "2";
                 slot1empty = true;
                 item1 = pic;
                 PickedUp2 = true;
             }
             if(slots == 2)
             {
                 Item = pickaxc;
                 s2 = "2";
                 slot2empty = true;
                 item2 = pic;
             }
             if(slots == 3)
             {
                 
                 s3 = "2";
                 slot3empty = true;
                 item3 = pic;
             }
             if(slots == 4)
             {
                 
                 s4 = "2";
                 slot4empty = true;
                 item4 = pic;
             }
             if(slots == 5)
             {
                 
                 s5 = "2";
                 slot5empty = true;
                 item5 = pic;
             }
             if(slots == 6)
             {
                 
                 s6 = "2";
                 slot6empty = true;
                 item6 = pic;
             }
             if(slots == 7)
             {
                 
                 s7 = "2";
                 slot7empty = true;
                 item7 = pic;
             }
             if(slots == 8)
             {
                 
                 s8 = "2";
                 slot8empty = true;
                 item8 = pic;
             }
             if(slots == 9)
             {
                 
                 s9 = "2";
                 slot9empty = true;
                 item9 = pic;
             }
             if(slots == 10)
             {
                 
                 s10 = "2";
                 slot10empty = true;
                 item10 = pic;
             }
             if(slots == 11)
             {
                 
                 s11 = "2";
                 slot11empty = true;
                 item11 = pic;
             }
             if(slots == 12)
             {
                 
                 s12 = "2";
                 slot12empty = true;
                 item12 = pic;
             }
             if(slots == 13)
             {
                 
                 s13 = "2";
                 slot13empty = true;
                 item13 = pic;
             }
             if(slots == 14)
             {
                 
                 s14 = "2";
                 slot14empty = true;
                 item14 = "pick";
             }
             if(slots == 15)
             {
                 
                 s15 = "2";
                 slot15empty = true;
                 item15 = pic;
             }
             if(slots == 16)
             {
                 
                 s16 = "2";
                 slot16empty = true;
                 item16 = pic;
             }
             if(slots == 17)
             {
                 
                 s17 = "2";
                 slot17empty = true;
                 item17 = pic;
             }
             if(slots == 18)
             {
                 
                 s18 = "2";
                 slot18empty = true;
                 item18 = pic;
             }
             if(slots == 19)
             {
                 
                 s19 = "2";
                 slot19empty = true;
                 item19 = pic;
             }
             if(slots == 20)
             {
                 
                 s20 = "2";
                 slot20empty = true;
                 item20 = pic;
             }
             if(slots == 21)
             {
                 
                 s21 = "2";
                 slot21empty = true;
                 item21 = pic;
             }
             if(slots == 22)
             {
                 
                 s22 = "2";
                 slot22empty = true;
                 item22 = pic;
             }
             if(slots == 23)
             {
                 
                 s23 = "2";
                 slot23empty = true;
                 item23 = pic;
             }
             if(slots == 24)
             {
                 
                 s24 = "2";
                 slot24empty = true;
                 item24 = pic;
             }
             if(slots == 25)
             {
                 
                 s25 = "2";
                 slot25empty = true;
                 item25 = pic;
             }
             if(slots == 26)
             {
                 
                 s26 = "2";
                 slot26empty = true;
                 item26 = pic;
             }
             if(slots == 27)
             {
                 
                 s27 = "2";
                 slot27empty = true;
                 item27 = pic;
             }
             if(slots == 28)
             {
                 
                 s28 = "2";
                 slot28empty = true;
                 item28 = pic;
             }
             item2d = false;
         }
         
     }
     
     if(slot1opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item1);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot1empty = false;
             slot1opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot2opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item2);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot2empty = false;
             slot2opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot3opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item3);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot3empty = false;
             slot3opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot4opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item4);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot4empty = false;
             slot4opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot5opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item5);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot5empty = false;
             slot5opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot6opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item6);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot6empty = false;
             slot6opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot7opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item7);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot7empty = false;
             slot7opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot8opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item8);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot8empty = false;
             slot8opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot9opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item9);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot9empty = false;
             slot9opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot10opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item10);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot10empty = false;
             slot10opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot11opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item11);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot11empty = false;
             slot11opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot12opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item12);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot12empty = false;
             slot12opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot13opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item13);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot13empty = false;
             slot13opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot14opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item14);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot14empty = false;
             slot14opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot15opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item15);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot15empty = false;
             slot15opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot16opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item16);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot16empty = false;
             slot16opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot17opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item17);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot17empty = false;
             slot17opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot18opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item18);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot18empty = false;
             slot18opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot19opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item2);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot19empty = false;
             slot19opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot20opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item20);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot20empty = false;
             slot20opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot21opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item21);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot21empty = false;
             slot21opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot22opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item22);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot22empty = false;
             slot22opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot23opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item23);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot23empty = false;
             slot23opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot24opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item24);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot24empty = false;
             slot24opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot25opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item25);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot25empty = false;
             slot25opt = false;
             Instantiate(Item, player.position, Quaternion.identity);    
         }
     }
     if(slot26opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item26);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot26empty = false;
             slot26opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot27opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item2);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot27empty = false;
             slot27opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     if(slot28opt)
     {
         GUI.Box(Rect(200, 100, 100, 50), item28);
         if(GUI.Button(Rect(200, 125, 100, 25), "Drop"))
         {
             slot28empty = false;
             slot28opt = false;
             Instantiate(Item, player.position, Quaternion.identity);
         }
     }
     
 }
 
 
 function Update()
 {
 
     if(!slot28empty)
     {
         slots = 28;
     }
     if(!slot27empty)
     {
         slots = 27;
     }
     if(!slot26empty)
     {
         slots = 26;
     }
     if(!slot25empty)
     {
         slots = 25;
     }
     if(!slot24empty)
     {
         slots = 24;
     }
     if(!slot23empty)
     {
         slots = 23;
     }
     if(!slot22empty)
     {
         slots = 22;
     }
     if(!slot21empty)
     {
         slots = 21;
     }
     if(!slot20empty)
     {
         slots = 20;
     }
     if(!slot19empty)
     {
         slots = 19;
     }
     if(!slot18empty)
     {
         slots = 18;
     }
     if(!slot17empty)
     {
         slots = 17;
     }
     if(!slot16empty)
     {
         slots = 16;
     }
     if(!slot15empty)
     {
         slots = 15;
     }
     if(!slot14empty)
     {
         slots = 14;
     }
     if(!slot13empty)
     {
         slots = 13;
     }
     if(!slot12empty)
     {
         slots = 12;
     }
     if(!slot11empty)
     {
         slots = 11;
     }
     if(!slot10empty)
     {
         slots = 10;
     }
     if(!slot9empty)
     {
         slots = 9;
     }
 
     if(!slot8empty)
     {
         slots = 8;
     }
     if(!slot7empty)
     {
         slots = 7;
     }
     if(!slot6empty)
     {
         slots = 6;
     }
     if(!slot5empty)
     {
         slots = 5;
     }
     if(!slot4empty)
     {
         slots = 4;
     }
     if(!slot3empty)
     {
         slots = 3;
     }
     if(!slot2empty)
     {
         slots = 2;
     }
     if(!slot1empty)
     {
         slots = 1;
     }
 
 
 
     if(slots == 1)
     {
         pick = "Pick Up";
     }
     if(slots == 2)
     {
         pick = "Pick Up";
     }
     if(slots == 3)
     {
         pick = "Pick Up";
     }
     if(slots == 4)
     {
         pick = "Pick Up";
     }
     if(slots == 5)
     {
         pick = "Pick Up";
     }
     if(slots == 6)
     {
         pick = "Pick Up";
     }
     if(slots == 7)
     {
         pick = "Pick Up";
     }
     if(slots == 8)
     {
         pick = "Pick Up";
     }
     if(slots == 9)
     {
         pick = "Pick Up";
     }
     if(slots == 10)
     {
         pick = "Pick Up";
     }
     if(slots == 11)
     {
         pick = "Pick Up";
     }
     if(slots == 12)
     {
         pick = "Pick Up";
     }
     if(slots == 13)
     {
         pick = "Pick Up";
     }
     if(slots == 14)
     {
         pick = "Pick Up";
     }
     if(slots == 15)
     {
         pick = "Pick Up";
     }
     if(slots == 16)
     {
         pick = "Pick Up";
     }
     if(slots == 17)
     {
         pick = "Pick Up";
     }
     if(slots == 18)
     {
         pick = "Pick Up";
     }
     if(slots == 19)
     {
         pick = "Pick Up";
     }
     if(slots == 20)
     {
         pick = "Pick Up";
     }
     if(slots == 21)
     {
         pick = "Pick Up";
     }
     if(slots == 22)
     {
         pick = "Pick Up";
     }
     if(slots == 23)
     {
         pick = "Pick Up";
     }
     if(slots == 24)
     {
         pick = "Pick Up";
     }
     if(slots == 25)
     {
         pick = "Pick Up";
     }
     if(slots == 26)
     {
         pick = "Pick Up";
     }
     if(slots == 27)
     {
         pick = "Pick Up";
     }
     if(slots == 28)
     {
         pick = "full inv";
     }
 if(!slot1empty)
 {
     Item = hatch;
 }
 
     
 }
 
 function OnTriggerEnter(other : Collider)
 {
 if(other.tag == "item1")
     {
         item1d = true;                 
     }
     
 if(other.tag == "item2")
     {
         item2d = true;
     }
 }
  
        
 function OnTriggerExit(other : Collider)
 {
     if(other.tag == "item1")
     {
         item1d = false;
     }
     
     if(other.tag == "item2")
     {
         item2d = false;
     }
 }
 
 var Item : GameObject;
 var player : Transform;    
the code is made up of 28 inventory slots and 2 items i wanna try and lower the amount of code as much as i can such as lowering repeating 28 things with different number to short as possible
This is not really a Unity question, but more of a general program$$anonymous$$g question. You need to educate yourself on arrays and other collections. Figuring out which one(s) to use can be complicated. Here is some material to get you started:
http://wiki.unity3d.com/index.php?title=Which_$$anonymous$$ind_Of_Array_Or_Collection_Should_I_Use?
This is a very amateur effort for sure. And that's ok! :)
In addition to robertbu's suggestions, also look into operators (relational testing especially) and the benefits of object oriented program$$anonymous$$g. Each one of your inventory slots could be an object instance which allows you to store all relevant information describing a slot. If you had that then you'd only need an array of your custom objects. Doing comparisons and queries would use a lot less code then.
Finally, robertbu is also correct when stating that this is not a Unity question. Its time to become very good friends with Google, or even check out Codeacademy. $$anonymous$$eep in $$anonymous$$d, while that link points to the javascript section on their site Unity uses a custom implementation of javascript called UnityScript. $$anonymous$$uch of the general stuff carries over, however, so it's a good resource.
Since you are still new to program$$anonymous$$g, I would recommend c# and start over. Im pretty sure that after a few days of learning you can write this code quickly and more efficient in a few lines of code. Or even better get an idea of a object-oriented way of program$$anonymous$$g that.
you need to learn for loop and if else. create class like: class Slot{ isEmpty = true; slotNum = 1; // & so on...... // .... // ..
}
then create a for loop like:
var slots = List(); // should be populate before looping..
for(slot in slots){ if (slot.isEmpty){ // do stuff } else { // do other stuff }
if (slot.slotNum == 1){ slot.pick = "Pick up"; // } else { slot.pick = "Bla bla" }
// or call some function.. slot.myFunc(); }
// just showing you the logic. // better to learn for your self.
Answer by iwaldrop · Jan 09, 2014 at 05:13 AM
This does not replace your code, but provides an example of how using a custom object, an array, a loop, and a ternary conditional allows you to do in a few lines of code what you did in hundreds. The longest part of it is using Unity GUI (eager for the new version).
To explain, this code displays the inventory slots horizontally across the top of the screen. When you press on a slot it will randomly select one of the 'demoItems' that are setup and assign it to the slot. Within the loop, it will either display the title of the item on the button, or the default empty slot title.
Again, I encourage you to really learn this stuff, hence why I took the time to write an example. Nobody is going to rewrite your entire script, because it is just too time consuming to figure out what you're doing and do it for you. Because that is true, and because this is an excellent learning opportunity for you, I suggest you accept this as answered and create some new questions as you hit stumbling blocks implementing a new solution.
 using UnityEngine;
 using System.Collections;
 
 public class ShortenedCode : MonoBehaviour
 {
     const string EMPTY_SLOT_TITLE = "slot";
     public int slotCount;
     public InventoryItem[] demoItems = new InventoryItem[3]
     {
         new InventoryItem { title = "hoe" },
         new InventoryItem { title = "axe" },
         new InventoryItem { title = "gun" },
     };
 
     private InventoryItem[] items;
 
     void Awake()
     {
         items = new InventoryItem[slotCount];
     }
 
     void OnGUI()
     {
         GUILayout.Space(5);
         GUILayout.BeginHorizontal(GUILayout.Width(Screen.width));
         {
             float padding = 2;
             GUILayout.FlexibleSpace();
             for (int i = 0; i < slotCount; i++)
             {
                 InventoryItem item = items[i];
                 Rect nextRect = GUILayoutUtility.GetRect(InventoryItem.SQUARE_SIZE, InventoryItem.SQUARE_SIZE);
                 if (GUI.Button(nextRect, item == null ? EMPTY_SLOT_TITLE : item.title))
                     CycleItem(i);
                 GUILayout.Space(padding);
             }
             GUILayout.FlexibleSpace();
         }
         GUILayout.EndHorizontal();
     }
 
     void CycleItem(int index)
     {
         items[index] = demoItems[Mathf.FloorToInt(Random.value * demoItems.Length)];
     }
 }
 
 [System.Serializable]
 public class InventoryItem
 {
     public const float SQUARE_SIZE = 32;
 
     public string title;
 }
 
ty this was all i was looking for this helps out lot it take a few days for me 2 take it apart and learn what each thing is but it helps but is this javascript or c# if its c# can u post a javascript form simply bc i dont understand c#
Answer by Spinnernicholas · Jan 09, 2014 at 12:08 AM
Use arrays or lists. Then it is easy to loop through those lists to initialize their values and do other stuff like display them in OnGUI().
Answer by Dok101 · Jan 09, 2014 at 10:06 PM
For what your doing I would suggest using arrays for the many variables. Theyre good for your code because you can call on them in the GUI function and many others. There is also many other ways to cut your code. For example from line 75 - 80 your code is
 if(slots == 26)
     {
        pick = "Pick Up";
Instead of doing that for 105 lines just write
 if (slots < 28)
 {
 pick = "Pick Up";
Also use loops as previously suggested
Your answer
 
 
             Follow this Question
Related Questions
Remove Items and Item Tooltips 0 Answers
How to display textures that are in an array? 1 Answer
Does anyone know of good tutorials for learning arrays and classes? 1 Answer
Script Not Working 0 Answers
make scroll chat with scroll bar 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                