Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: KodiakBehr on Sat 08/10/2011 18:00:44

Title: Grid Inventory
Post by: KodiakBehr on Sat 08/10/2011 18:00:44
I'm using the Grid Inventory Module as a starting point for a new game.

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=28177.0

I wasn't bright enough to get it working from the module itself, so I tried adapting the demo instead in order to understand how it works through ablation.

In the demo, there are two inventory grids.  I only need the one, so I started by trimming all references to gInventory2 and DeathInv, while preserving the if-statement logic.  When I do that, line 386 on Module0 crashes the game.


InventoryItem* GridInventory::GetAtScreenXY(int x, int y) {
 GUI *pg = this.pInvWin.OwningGUI;
 int X = this.pInvWin.X + pg.X;
 int Y = this.pInvWin.X + pg.Y;
 
 String id;
 
 if (pg.Visible && this.pInvWin.Visible && this.pInvWin.Enabled && this.pInvWin.Clickable) {
if (x >= X && x < X + this.pInvWin.Width && y >= Y && y < Y + this.pInvWin.Height) {
 
 int pos = (x - X) / this.pInvWin.ItemWidth + ((y - Y) / this.pInvWin.ItemHeight) * this.pInvWin.ItemsPerRow;
 
 id = this.itemId.Substring(pos * 3, 3);
   
 if (id.AsInt)
return inventory[id.AsInt];
}
}

return null;
}


Can't for the life of me figure out what that section does.  I'm probably in over my head.

Does anybody have experience with this module, or any other grid-inventory module, that can offer guidance towards its clean implementation?
Title: Re: Grid Inventory
Post by: KodiakBehr on Sun 09/10/2011 14:56:31
Disregard.  Frankly, grid-inventory adds too much complexity to my game without adding a lot of value. 
I'm going to take some advice from the critics of my last game and keep the interface clean and simple.