Inventory system in 3D beat 5
by Romek · in Torque 3D Professional · 09/21/2009 (12:35 am) · 5 replies
Hello everyone.
Im trying get to work resource http://www.garagegames.com/community/resources/view/7514 in 3D beta 5.
Ive discover that part which is saying about script array is already implement in engine by default.
Then GuiObjectView I did how is been explain.
Then adding the InventoryGUI.
Ive done all that, but unfourntly dosen't work. This is my current error:
But anyway I should also explain what Im trying achive by this. I want have traking system of my invenotry, in my space game, where u able mount things into the ship, as well as into the human character. Display should be in 3D, and rotate, zoom, and list of things what I have in invenory. The most important is that, that should be able mount and unmount equipment, on my models.
Please point to another resource which have all those things, othervise please help me out with this one.
Im trying get to work resource http://www.garagegames.com/community/resources/view/7514 in 3D beta 5.
Ive discover that part which is saying about script array is already implement in engine by default.
Then GuiObjectView I did how is been explain.
Then adding the InventoryGUI.
Ive done all that, but unfourntly dosen't work. This is my current error:
art/gui/InventoryGUI.gui (85): Unable to find object: '0' attempting to call function 'add'
But anyway I should also explain what Im trying achive by this. I want have traking system of my invenotry, in my space game, where u able mount things into the ship, as well as into the human character. Display should be in 3D, and rotate, zoom, and list of things what I have in invenory. The most important is that, that should be able mount and unmount equipment, on my models.
Please point to another resource which have all those things, othervise please help me out with this one.
#2
09/21/2009 (11:33 pm)
This is a code what Im using right now of my InventoryGUI.gui. Sorry for pasting this so late.//--- OBJECT WRITE BEGIN ---
new GuiControl(InventoryGUI) {
profile = "GuiDefaultProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "0 0";
extent = "640 480";
minExtent = "8 2";
visible = "1";
new GuiWindowCtrl(InventoryWindow) {
profile = "GuiWindowProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "2 -2";
extent = "621 476";
minExtent = "8 2";
visible = "1";
text = "Inventory";
maxLength = "255";
resizeWidth = "1";
resizeHeight = "1";
canMove = "1";
canClose = "1";
canMinimize = "1";
canMaximize = "1";
minSize = "50 50";
CloseCommand = "Canvas.PopDialog(InventoryGUI);";
new GuiObjectView(InventoryItemView) {
profile = "GuiDefaultProfile";
horizSizing = "relative";
vertSizing = "relative";
position = "0 0";
extent = "400 400";
minExtent = "8 2";
visible = "1";
helpTag = "0";
cameraZRot = "0";
forceFOV = "0";
};
new GuiScrollCtrl() {
profile = "GuiScrollProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "410 30";
extent = "200 400";
minExtent = "8 2";
visible = "1";
willFirstRespond = "1";
hScrollBar = "alwaysOn";
vScrollBar = "alwaysOn";
constantThumbHeight = "0";
childMargin = "0 0";
new GuiTextListCtrl(InventoryListView) {
profile = "GuiTextArrayProfile";
horizSizing = "right";
vertSizing = "bottom";
position = "2 2";
extent = "178 2";
minExtent = "8 2";
visible = "1";
enumerate = "0";
resizeCell = "1";
columns = "0";
fitParentWidth = "1";
clipColumnText = "0";
};
};
};
};
//--- OBJECT WRITE END ---
function toggleInventoryGUI(%val){
if(%val)
InventoryGUI.toggle();
}
function InventoryGUI::OnWake(%this){
UpdateInventoryListView();
}
//This function updates the InventoryListView
function UpdateInventoryListView(){
echo("UpdatingInventoryListView, lets start by clearing it");
InventoryListView.clear();
echo("Done now looping through Inventory");
for(%x = 0; %x < $Inventory.count(); %x++){
InventoryListView.addRow(%x,$Inventory.getKey(%x) SPC $Inventory.getValue(%x));
echo("Added Item at "@%x);
}
echo("Complete!, now sorting and cleaning");
InventoryListView.sort(0);
InventoryListView.setSelectedRow(0);
InventoryListView.scrollVisible(0);
}
function InventoryGUI::toggle(%this)
{
if (%this.isAwake()){
Canvas.popDialog(%this);
}else{
Canvas.pushDialog(%this);
}
}
/*function InventoryListView::OnSelect( %this, %id, %text )
{
InventoryItemView.setEmpty();
$SelectedItem = getField(InventoryListView.getRowTextById(%id),0);
$SelectedItem = getWord($SelectedItem,0);
InventoryItemView.setObject($SelectedItem,$InventoryImage.getValue
($InventoryImage.getIndexFromKey($SelectedItem)),"", 0);
}*/
function InventoryListView::OnSelect( %this, %id, %text )
{
$SelectedItem = getField(InventoryListView.getRowTextById(%id),0);
$SelectedItem = getWord($SelectedItem,0);
InventoryItemView.setModel($SelectedItem.shapefile);
}
#3
So on the end the problem, WAS with script array, because that's where function add was called. And by adding this line above is ok now.
So far no major errors, but right now is not updating the from current inventory. Like in the past, I get this resource to work in TGA 1.8.1, and there was displaying everything what I have in inventory, stright away. Im assuming is becasue of this: (that's only red line what I have right in my output)
That's line of code in scripts/server/inventory.cs, when u double click on error:
09/21/2009 (11:34 pm)
I manage to fix the problem by adding to the top, of file scrpit/server/init.cs line:$Inventory = new ArrayObject ();
So on the end the problem, WAS with script array, because that's where function add was called. And by adding this line above is ok now.
So far no major errors, but right now is not updating the from current inventory. Like in the past, I get this resource to work in TGA 1.8.1, and there was displaying everything what I have in inventory, stright away. Im assuming is becasue of this: (that's only red line what I have right in my output)
scripts/server/inventory.cs (134): Unable to find object: '' attempting to call function 'getName'
That's line of code in scripts/server/inventory.cs, when u double click on error:
function ShapeBase::getInventory(%this,%data)
{
// Return the current inventory amount
return %this.inv[%data.getName()];
}
#4
09/21/2009 (11:53 pm)
Ive checked this function ShapeBase::getInventory(%this,%data) in other project and Im simply not passing anything to it. My fault. But right now I have fix it.
#5
09/22/2009 (3:23 am)
Great job at getting this far! Post here if you have further problems with your Inventory implementation.
Associate Konrad Kiss
Bitgap Games