Finally got an inventory working, one small bug that I can't figure out though, help?
sheymyster
Member Posts: 7
So I've been wracking my brain trying to figure out how to make an inventory that works off of a dynamic table. Basically each time I click an item it adds that items custom integer property (Item ID) to a table and then adds a row to the beginning of that table, (this way the table is always ready for the next item to be added). I then set up a pause menu which currently only contains 8 inventory slots for testing purposes. Each slot is the same and the only difference is which table column it is dependent on. So, each slot has an integer property called "Containing Item ID" and that property is constrained to a specific cell in the table, in this test case column 2 and the row is based on which item slot, so item slot 1 is constrained to row 2 column 2, item slot 2 is constrained to row 3 column 2, and so on...... (It's one row ahead because a table cannot exist with 0 rows so there is always a blank row at the beginning of the table so the first item slot starts at row 2 where the item information starts.
By clicking the inventory/pause game button, the table is saved so the changes to the table are preserved and the inventory inside displays the items you've collected.
Every item you add pushes the other items down the table which means down the inventory so the most recent items you've collected show at the beginning of the inventory. This is how I wanted, but I'm sure someone could tinker a bit and have it display differently (such as after the last item) by using the table row count property creatively. I then gave each inventory slot an attribute behavior where if the Containing Item ID = # the image for the inventory slot actor changes to that of the item which corresponds to that ID. Since the item ID transfers from the obtaining of the item to the table and then to the slot, the image showing in the inventory will always be that of the item you collected.
Finally I wanted to mess around with removing items from the inventory. Since the entire inventory display is based on the table, removing the row containing the item ID should make the slots update removing the image of the item you discarded (because the Containing Item ID is constrained by the table cell value) but this isn't the case. When I click on an item it does delete the row but the image stays until I leave the inventory. This was workable because I thought about just displaying a "sold" or "discarded" image over top of it and then when you checked the inventory again it would be gone as desired, BUT when I remove an item that isn't the last item in the inventory the slot updates with the next item over but that item still displays it's image still as well........which isn't going to work and I have no idea how to fix it.
Basically it looks like this. [O]...[X]...[Y] When I delete item X, the inventory looks like this [O]...[Y]...[Y] until I exit the inventory and return to it. When I return it looks proper like this [O]...[Y]...[ ]
Is there a way I can post my game salad file, I'd be happy to share my progress with the inventory and everyone is welcome to use it for their apps and improve on it. Any help would be much appreciated and let me know how to post my file so you guys can see it first hand instead of trying to decipher the wall of text I just wrote.
By clicking the inventory/pause game button, the table is saved so the changes to the table are preserved and the inventory inside displays the items you've collected.
Every item you add pushes the other items down the table which means down the inventory so the most recent items you've collected show at the beginning of the inventory. This is how I wanted, but I'm sure someone could tinker a bit and have it display differently (such as after the last item) by using the table row count property creatively. I then gave each inventory slot an attribute behavior where if the Containing Item ID = # the image for the inventory slot actor changes to that of the item which corresponds to that ID. Since the item ID transfers from the obtaining of the item to the table and then to the slot, the image showing in the inventory will always be that of the item you collected.
Finally I wanted to mess around with removing items from the inventory. Since the entire inventory display is based on the table, removing the row containing the item ID should make the slots update removing the image of the item you discarded (because the Containing Item ID is constrained by the table cell value) but this isn't the case. When I click on an item it does delete the row but the image stays until I leave the inventory. This was workable because I thought about just displaying a "sold" or "discarded" image over top of it and then when you checked the inventory again it would be gone as desired, BUT when I remove an item that isn't the last item in the inventory the slot updates with the next item over but that item still displays it's image still as well........which isn't going to work and I have no idea how to fix it.
Basically it looks like this. [O]...[X]...[Y] When I delete item X, the inventory looks like this [O]...[Y]...[Y] until I exit the inventory and return to it. When I return it looks proper like this [O]...[Y]...[ ]
Is there a way I can post my game salad file, I'd be happy to share my progress with the inventory and everyone is welcome to use it for their apps and improve on it. Any help would be much appreciated and let me know how to post my file so you guys can see it first hand instead of trying to decipher the wall of text I just wrote.
Comments
✮ FREE templates at GSinvention ✮
✮ Available for hire! support@gsinvention.com ✮
OK, I think I did it right, this is my current file, I'm going to grab some food and work on it more this afternoon/night.
@artfish I'm not exactly sure what you're suggesting but I think you're saying having the items always in the inventory and just showing them when I have them? That won't really work because each slot has to be able to have any item because my game consists of lots of obtainable items.
thanks
✮ FREE templates at GSinvention ✮
✮ Available for hire! support@gsinvention.com ✮
https://www.dropbox.com/s/cdtygg692lsirv3/Inventory Project.rar