- Home /
This post has been wikified, any user with enough reputation can edit it.
make inventory script get variables from item's script
my goal is to make it so when i click items gui button it put the items info into the inventory as it should
i perfer not to add the items info to the inventory script ill perfer if it got the info it needs threw the items script this is my inventory script it is working please do not CHANGE or recommend changing it unless the changes keep the inventory script still working
var inventoryActive : boolean = false;
var weaponlistActive : boolean = false;
var armorlistActive : boolean = false;
var clothinglistActive : boolean = false;
var jewerlylistActive : boolean = false;
var inbw = 0;
var inbh = 75;
var weaponhight = 100;
var armorhight = 125;
var clothinghight = 150;
var jewerlyhight = 175;
var bw = 0;
var size = 100;
var size1 = 25;
var lwh = 125;
var lch = 150;
var ljh = 175;
var lah = 100;
var law1 = 100;
var law2 = 175;
var law3 = 250;
var lasize = 75;
var lasize1 = 25;
var item = "";
function OnGUI()
{
if (GUI.Button(Rect(inbw, inbh, size, size1), "Inventory"))
{
inventoryActive = !inventoryActive;
}
if(inventoryActive){
if (GUI.Button(Rect(bw, weaponhight, size, size1), "Weapons"))
{
weaponlistActive = !weaponlistActive;
}
if(weaponlistActive)
{
GUI.Box (Rect (law1, lah, lasize, lasize1), item);
GUI.Box (Rect (law2, lah, lasize, lasize1), item);
GUI.Box (Rect (law3, lah, lasize, lasize1), item);
}
if (GUI.Button(Rect(bw, armorhight, size, size1), "Armor"))
{
armorlistActive = !armorlistActive;
}
if(armorlistActive)
{
GUI.Box (Rect (law1, lwh, lasize, lasize1), item);
GUI.Box (Rect (law2, lwh, lasize, lasize1), item);
GUI.Box (Rect (law3, lwh, lasize, lasize1), item);
}
if (GUI.Button(Rect(bw, clothinghight, size, size1), "Clothing"))
{
clothinglistActive = !clothinglistActive;
}
if(clothinglistActive)
{
GUI.Box (Rect (law1, lch, lasize, lasize1), item);
GUI.Box (Rect (law2, lch, lasize, lasize1), item);
GUI.Box (Rect (law3, lch, lasize, lasize1), item);
}
if (GUI.Button(Rect(bw, jewerlyhight, size, size1), "Jewerly"))
{
jewerlylistActive = !jewerlylistActive;
}
if(jewerlylistActive)
{
GUI.Box (Rect (law1, ljh, lasize, lasize1), item);
GUI.Box (Rect (law2, ljh, lasize, lasize1), item);
GUI.Box (Rect (law3, ljh, lasize, lasize1), item);
}
}
}
this is my items script please concentrate all changes here
var details : boolean = false;
var detaillistActive : boolean = false;
var tunnelwidth = 500;
var tunnelheight = 200;
var tunnel1 = 100;
var tunnel2 = 30;
var law = 500;
var lah = 230;
var size = 100;
var size1 = 25;
var item = "Cube";
var pickw = 500;
var pickh = 255;
var picksize = 100;
var picksize1 = 25;
function OnGUI ()
{
if (details)
{
if (GUI.Button(Rect(tunnelwidth, tunnelheight, tunnel1, tunnel2), "Cube"))
{
detaillistActive = !detaillistActive;
}
if(detaillistActive)
{
GUI.Box(Rect(law, lah, size, size1), item);
GUI.Button(Rect(pickw, pickh, picksize, picksize1), "Pick-up");
}
}
}
function OnTriggerEnter(other : Collider)
{
if(other.tag == "Player")
{
details = true;
}
}
function OnTriggerExit(other: Collider)
{
if(other.tag == "Player")
{
details = false;
}
}
Comment
I don't see a method or function like AddItemToInventory() - do you have one?
no i dont know how to go about that which is why im asking and there is a button on the item that when i click it it bring up the pick-up option/desiption