- Home /
Inventory script Help Please
my inventory script is not working i got the concept of the script from this link Inventory, simple and easy
but i made it myself so here is my inventory script :
static var statInventory : Inventory;
var EmptySlot : Texture;
var inventoryWindow : Rect;
class InventoryItem
{
var ItemName : String;
var ItemTexture : Texture;
}
function OnAwake() {
inventoryWindow = new Rect (10, 10, 10, 10);
}
function Loot(){
if(GUI.Button (Rect (5,5,10,10), ""));
{
GUI.DrawTexture (Rect, EmptySlot)
}
else
{
GUI.DrawTexture (Rect, ItemTexture)
}
function CloseInventoryWindow(){
if (GUI.Button (Rect (10,10,150,100), "X")) {
inventoryWindow = false;
}
and here is my loot script on objects:
var ItemTexture :Texture;
var ItemName : String;
function Start()
{
var theInventoryItem : InventoryItem;
theInventoryItem.ItemName = ItemName;
theInventoryItem.ItemTexture = ItemTexture;
}
function OnMouseDown()
{
Loot ();
}
function Loot ()
{
if (clicked)
{
clicked = true;
}
Inventory.AddItem(TheInventoryItem);
theInventoryItem = null;
Destroy(this.gameObject);
}
now they will change this is just the basics but for the inventory script i keep getting this error:
Assets/Scripts/PlayerScripts/Inventory.js(19,1): BCE0044: expecting :, found '}'.
its telling me to put a colon but when i do it gives me a bunch of errors please help
Answer by coastwise · Nov 05, 2012 at 06:46 PM
You have an extra semicolon on the first line of the Loot function. Should be something like this:
function Loot() {
if (GUI.Button (Rect (5,5,10,10), "")) {
GUI.DrawTexture (Rect, EmptySlot);
} else { // ...
Answer by FrostHDD · Nov 06, 2012 at 02:36 AM
i added that and changed my script up a bit now here is the inventory script:
static var statInventory : Inventory;
var EmptySlot : Texture;
var inventoryWindow : Rect;
class InventoryItem
{
var ItemName : String;
var ItemTexture : Texture;
}
function OnAwake() {
inventoryWindow = new Rect (10, 10, 10, 10);
}
function Loot() {
if (GUI.Button (Rect (5,5,10,10), "")) {
GUI.DrawTexture (Rect, EmptySlot);
}
else
{
GUI.DrawTexture (Rect, ItemTexture);
}
}
and here is my item loot script:
var ItemTexture : Texture;
var ItemName : String;
function Start()
{
var theInventoryItem : InventoryItem;
theInventoryItem.ItemName = ItemName;
theInventoryItem.ItemTexture = ItemTexture;
}
function OnMouseDown()
{
Loot ();
}
function Loot ()
Inventory.AddItem(TheInventoryItem);
theInventoryItem = null;
Destroy(this.gameObject);
but i keep getting this error:
Assets/Scripts/ItemScripts/ItemLoot.js(16,1): BCE0043: Unexpected token: Inventory.
please help
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I'm trying to add items to an inventory. 1 Answer
how to make a Equipment Script 1 Answer
Why does it give me this error and how can i fix it? 1 Answer