Game Development Community

unable to find object .. Inventory Problem [Self-Resolved]

by Siobhan · in Torque Game Builder · 11/02/2010 (6:04 pm) · 1 replies

I'm having a strange problem.
I already have a 'shop.gui' set up with a 'ShopGui.cs' file located in ~/gui/ and it works fine.
I pretty much just copied the shop code to create an inventory 'inventory.gui' and 'InventoryGui.cs' in ~/gui/ too.

The client opens inventory.gui with a key bind to 'i'. whereas the server tells the client to open the shop once the client has selected a character.

But when I click on the buttons ('ArmourBtn' and 'WeaponsBtn') I get this error:
<input> (0): Unable to find object: 'InventoryGui' attempting to call function 'armourBtn'

I can't understand why it works fine for the shop but not for the inventory. If anyone could shed some light on this I would be very grateful.

And one other question about the inventory. How does it work? The client asks the server for permission to add or remove an item from the inventory and then the server responds with a 'yes you're allowed' or 'no you're not allowed' and then the client adds/removes the item. Is that it?
Thanks again.

Here's some code snippets:
inventory.gui
new GuiBitmapButtonCtrl(weaponsBtn) {
      canSaveDynamicFields = "0";
      isContainer = "0";
      Profile = "ShopTab";
      HorizSizing = "right";
      VertSizing = "bottom";
      Position = "16 120";
      Extent = "140 30";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      Command = "InventoryGui.WeaponsBtn();";
      hovertime = "1000";
      groupNum = "-1";
      buttonType = "PushButton";
      useMouseEvents = "1";
      bitmap = "common/gui/images/ShopWeapnsTab";
   };
   new GuiBitmapButtonCtrl(armourBtn) {
      canSaveDynamicFields = "0";
      isContainer = "0";
      Profile = "ShopTab";
      HorizSizing = "right";
      VertSizing = "bottom";
      Position = "18 74";
      Extent = "140 30";
      MinExtent = "8 2";
      canSave = "1";
      Visible = "1";
      Command = "InventoryGui.ArmourBtn();";
      hovertime = "1000";
      groupNum = "-1";
      buttonType = "PushButton";
      useMouseEvents = "1";
      bitmap = "common/gui/images/ShopArmourTab";
   };

InventoryGui.cs
function InventoryGui::ArmourBtn(){
	echo("ARMOUR BUTTON");
	$Type = 0; //armour
	
	clearAllInvLists();
	
	%i=0;
	while($aCheck[$ARMOUR,%i]==1){
		%itemName = (%i+1)SPC": "SPC$aInv[$ARMOUR,%i];
		
		//Add Items to Lists
		InvItemsList.addItem(%itemName);
		InvMod.addItem($aInv[$ARMOUR,%i].modification);
		InvSellPrice.addItem($aInv[$ARMOUR,%i].sellValue);
		
		%i++;
	}
}
	
function InventoryGui::WeaponsBtn(){
	$Type = 1; //weapon
	
	clearAllInvLists();
	
	%i=0;
	while($aCheck[$WEAPONS,%i]==1){
		%itemName = (%i+1)SPC": "SPC$aInv[$WEAPONS,%i];
		
		//Add Items to Lists
		InvItemsList.addItem(%itemName);
		InvMod.addItem($aInv[$WEAPONS,%i].modification);
		InvSellPrice.addItem($aInv[$WEAPONS,%i].sellValue);
		
		%i++;
	}
}


#1
11/30/2011 (2:53 am)
might be where you have the init for the inventory set to the wrong folder. mines in art ,gui .but in the client init.cs i load it with

exec("art/gui/inventoryGui.gui"); you might have a typo or something wrong,

my inventory.cs is in game scripts client.

it loads with the rest of the gui's, but im having a prob setting a bind key to open it.allways the little things that take up all the time.

you might have the command for the armor button wrong to. it should be ,,

Canvas.pushDialog(inventoryGui);


that should open the inventory gui when you push the button.