Changing inventory items order

Started by Dusk, Fri 30/04/2004 12:33:53

Previous topic - Next topic

Dusk

Hello everybody - I hope this question is not too dumb for this forum, because I'm quite new to AGS and maybe there's a simple solution.

I can't find a not-really-dirty way to re-order inventory items. I'm making a personalized inventory window (hope to show you soon) that needs a "filler" item in its "n" first position. So i display mulptiple items multiple times, and that's ok... I "lose" a filler adding new items, and it works... but if I had to lose item and wanna insert a filler in the first inventory position? If I AddInventory(FILLER) it goes to the last position, I need it in the first.
How to specify the position? I've read many docs and found that the inventory is in practice an array where the key is the item number and the value is the amount of that item the player has.
So I tried character[GetPlayerCharacter()].inv[FILLERNUMBER]++ , but the problem remains, the new filler goes in the last position.
So the question is: where does AGS store the inventory items order? I hope it's not an hardcoded thing, maybe a not documented one, or maybe I simply didn't  search enough well.
Any links/suggestion/functions/reference to old post appreciated, help me or I will "backup" the real inventory items somewhere, place a right number of fillers in the inventory and then "restore" the saved "real" items. It should work, but it's REALLY DIRTY... :)

Sorry for poor English, writing from Italy - first written post - great community, great software (thanks CJ)
Bye :)


SSH

Welcome to the forums, Dusk. I hope you'll enjoy AGS.

I think taht inventory items are displayed in the order in which they are numbered, so if FILLER is to be listed first, you'll have to make it your first inventory item. I could be wrong on this, though.

What exactly are you tryint to do with this filler, anyway. Is it just right-justfying the inventory GUI?

You could maybe manually do an invetory GUI by using buttons instead of an inventory area, but this woiuld take a lot of scripting. It would offer more flexibiltiy on exactly how items are displayed, though.
12

strazer

#2
Quote from: Pumaman on Mon 05/04/2004 20:47:10The inventory window currently keeps track of the order that items are added to it, until such a time as the player character is changed, at which point the items switch back to the default order.

I suppose the default is the order in which the items are numbered as SSH says.

This sounds interesting, I look forward to your solutions.

Dusk

Thanks SSH, thanks Strazer (I have read the thread).

I think I'm going to make a personalized inventory window with buttons as suggested by SSH, cause I'd like to have maximum flexibility... items aren't simply right aligned, the inventory window is composed by more lines of 8 items each. It auto-scrolls down if needed, but due to the inventory window properties they went up in the first line, while I wanted them in the the 3rd line (the visibile one). So I made my AddInventoryEx/LoseInventoryEx that keep an indipendent item count and filler adjust, to change the GUI behavior/scrolling when needed.

I can't explain exactly in English.. by the way I think it's cool :D
The filler is item number 1, so if I make a double swapcharacter-and-back with an invisible-follower character I think that I can solve the problem... but items will be sorted only by their number after that. In general, it would be great to have them placed in the order one pick-ups them, as occurs temporarily before a swap-character.
The best thing would be to have a structure to completely manipulate the inventory position of an item... now the inventory is a
short inv[MAX_INV]
it would be perfect IMHO to have
typedef struct { short count; short position; } invitem
and so
invitem inv[MAX_INV]
so that we can do
character[GetPlayerCharacter()].inv[3].count++; //gets the item
character[GetPlayerCharacter()].inv[3].position = 1; //places the item in a specific inventory position

But I am sure that CJ has to do many more important add/changes that this..  so I'll find a way : )
Bye  ;)

Pumaman

Rather than switching to a dummy character and back, the easiest way to re-sort the inventory is simply to call the  UpdateInventory  command.

The other workaround you could do is to store your inventory in a seperate array, then when you want to add an item to the inventory have your own custom function which clears the player's inventory and adds items back in the correct order.

Dusk

Quote from: Pumaman on Fri 30/04/2004 16:59:20
Rather than switching to a dummy character and back, the easiest way to re-sort the inventory is simply to call the  UpdateInventory  command.
Great! I think that for now it's perfect. Really thankyou :)

Quote from: Pumaman on Fri 30/04/2004 16:59:20
The other workaround you could do is to store your inventory in a seperate array, then when you want to add an item to the inventory have your own custom function which clears the player's inventory and adds items back in the correct order.
Ok... this sounds perfect, and I'll do this way at the end... shame on me, I thought for a moment that there wasn't a way to declare arrays in AGS... but reading the forums I'm seeing a lot of undocumented-really-cool-and-useful-stuff : )

Thanks again,  bye  8)

SMF spam blocked by CleanTalk