Stacking Inventory

Started by Akumayo, Sun 11/09/2005 17:22:23

Previous topic - Next topic

Akumayo

I know there is an option on the main game screen editor for "Display multiple items multiple times."  I normally tick this, but my inventories always flood.  I don't really value the idea of a scrolling inventory, so my question is this:
How do you stack inventory items, displaying how many you have on each icon, without creating inventory items that actually have the number as part of their sprite?

I considered using globalints to track how much you have, but the problem remains, how do you display to the player how much they have?
"Power is not a means - it is an end."

Ishmael

Mark up a co-ordinate spot of every item slot, and place a labe somewhere on each slot, where you want the number to be displayed, and in the repeadetly_execute check which item is at which co-ordinates, and change the label by each slot to the number of items on each slot. I think you can get the number of items with cCHARID.inv[item] (was character[CHARID].inv[] in the old scripting), once you know which number to supply as item.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Akumayo

hrm....I'm still not good at setting label text, how would you do it?
"Power is not a means - it is an end."

Ishmael

Label.SetText. Look it up in the manual for exact instructions on how to use it ;)
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Akumayo

Okay, nevermind, I found a SetLabelText script in one of my old games, it should work, another question though, how exactly do I determine which inv slot to put the labels on, I mean, what if Label 1 is set to Slot 1, meat, and the player gets a rib first instead of meat?
"Power is not a means - it is an end."

Ishmael

The InventoryItem.GetAtScreenXY(mouse.x, mouse.y); will tell you what item is where, just mark down one point from each slot, and go through every slot to get, for example, an array of inv item numbers, which you can then use as reference in, for example, a while loop that sets the labels based on the inv item numbers.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Akumayo

Hrm...that sounds rather difficult, I'll just break down and use scrolling buttons, thanks for your help though!
"Power is not a means - it is an end."

Ishmael

You give up too easily :P

Here're some bits of code I thought up:

start of global script:
int itemcount[8];

repeadetly_execute (or someplace else, like where the inventory is brought up, if it's not visible all the time):
InventoryItem *itemcount[1] = InventoryItem.GetAtScreenXY(20, 20);
InventoryItem *itemcount[2] = InventoryItem.GetAtScreenXY(40, 20);
InventoryItem *itemcount[3] = InventoryItem.GetAtScreenXY(60, 20);
InventoryItem *itemcount[4] = InventoryItem.GetAtScreenXY(80, 20);
InventoryItem *itemcount[5] = InventoryItem.GetAtScreenXY(20, 40);
InventoryItem *itemcount[6] = InventoryItem.GetAtScreenXY(40, 40);
InventoryItem *itemcount[7] = InventoryItem.GetAtScreenXY(60, 40);
InventoryItem *itemcount[8] = InventoryItem.GetAtScreenXY(80, 40);
Inv1.SetText("%d", itemcount[1]);
Inv2.SetText("%d", itemcount[2]);
Inv3.SetText("%d", itemcount[3]);
Inv4.SetText("%d", itemcount[4]);
Inv5.SetText("%d", itemcount[5]);
Inv6.SetText("%d", itemcount[6]);
Inv7.SetText("%d", itemcount[7]);
Inv8.SetText("%d", itemcount[8]);

Very simple stuff, and I don't guarantee it works, as I haven't tested it, and I'm not yet that familiar with the new scripting, but anyway...
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

SMF spam blocked by CleanTalk