Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Joseph DiPerla on Tue 17/06/2008 21:37:31

Title: Dont hate me--- Suggestion-- Inventory variables.
Post by: Joseph DiPerla on Tue 17/06/2008 21:37:31
I know this can be done already by creating several characters and using their inventories to be displayed in a certain inventory window. But it gets too sloppy, particularly if you have four characters who use 3 different inventories. Plus it could get confusing when scripting it.

My suggestion would be to be able to add Inventory type numbers to an inventory object. For instance, so I have a key. Under the type for it I would put a 1 in it. For a magic potion, I would put a 2 in there. For a gun, I would put a 3  etc.. So basically I have defined for myself that 1 is a normal item, 2 is a magic item and 3 is a weapon.

So if I want an inventory window to display weapons, I would then put in its properties for inventory type to display a 3.

And perhaps some scripting options to change inventory type to display for an Inventory window and to change the type of an inventory as well?

Would this be possible? Would offer some cleaner organization for our games.
Title: Re: Dont hate me--- Suggestion-- Inventory variables.
Post by: GarageGothic on Tue 17/06/2008 21:42:23
You could make a custom "type" property for the inventory item and then filter items with the appropriate value when filling up your inventory window.

Edit: A long time ago I wrote some code for sorting the inventory here (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=31886.msg410576#msg410576). The only difference you want to make is to avoid  the bubble sort part (assuming you want to keep them in the order they were picked up). And then add a conditional check that only writes them back to the inventory window if the type property is the right value.
You'll want to keep the contents of the array so that you can restore the full inventory when the user closes the window or changes the filter mode. Also be aware that you will have to add your own function for new inventory items being added/removed (for instance during inventory combination puzzles) while the filtered inventory is being displayed, as the new items are not part of your stored list. If you read the full inventory back to the inventory window last-to-first, you could just let your own AddItem function add the new items at the end of the array, and your RemoveItem set those items that were removed to an invalid value (e.g. -1)  and don't add those back.
Title: Re: Dont hate me--- Suggestion-- Inventory variables.
Post by: Joseph DiPerla on Tue 17/06/2008 21:48:55
Good idea. I guess I can use the Property function. Only problem would be on how to filter it in the inventory window. There's no option to filter items with a certain property and I found no help or scripting option on this in the manual. How would you go about this?
Title: Re: Dont hate me--- Suggestion-- Inventory variables.
Post by: GarageGothic on Tue 17/06/2008 22:00:03
Check my edit that I wrote while you posted.
Title: Re: Dont hate me--- Suggestion-- Inventory variables.
Post by: Joseph DiPerla on Thu 19/06/2008 16:28:38
I guess I can try to use that. But if Chris could implement the feature, it would be a lot less confusing and a lot cleaner to use as well. The less coding I do, the less the errors :) I suck at coding in C++/C#/Java syntax.
Title: Re: Dont hate me--- Suggestion-- Inventory variables.
Post by: Pumaman on Thu 19/06/2008 21:57:34
Is this something that other people would find useful?
Title: Re: Dont hate me--- Suggestion-- Inventory variables.
Post by: GarageGothic on Thu 19/06/2008 22:20:27
I think it's a bit silly to spend time implementing something into the engine that could be done as a module in about half an hour. But by all means, if it's trivial to implement a filter-by-property function for inventory windows, I'm sure a lot of people - especially those making RPGs - would find it useful.