Show object counter in inventory?

Mr.Night
22 Sept 2018, 06:37I am trying to make it so if my player has 30 grams of silver, it shows "Silver (30)" beside the object in the inventory window.
I've looked everywhere for how to do it but im drawing blanks.
mrangel
22 Sept 2018, 07:34I believe you need to change the object's listalias
attribute to the name you want to display.

Mr.Night
22 Sept 2018, 07:45I managed to invent a way to do it, and im not sure it it's right. but it works perfectly.
I added an attribute to the player called silver set to an integer, then I made a status attribute called Silver.
So Silver=Silver: /G
So in the status pane it shows Silver: 0/G
Then when I pick up silver I have it add one to the player.silver variable.
mrangel
22 Sept 2018, 08:06Yeah, that's the standard way of handling money.
The option I suggested above is how you would do it if you want it to show next to an object in the inventory pane.

Mr.Night
22 Sept 2018, 08:18I thought about doing that, but i think for my game it makes more sense if it is a stat.
My only issue is that, lets say I have the item in the inventory... and the counter is at zero...
I am trying to make it so if the counter is at zero, I no longer see silver in the inventory or use it.

Forgewright
24 Sept 2018, 12:37if (silver <= 0) {
silver.parent = holding_room
}
else {
silver.parent = player
}
mrangel
24 Sept 2018, 13:03If I had an item that I wanted to show multiple of in the inventory, I'd probably give it a number
attribute, (so it could be incense.number
, or silver.number
, or potion.number
, if you've got multiple items to keep track of), and then give it a changednumber
script which automatically updates the displayed name every time the number changes:
if (this.number < 0) {
this.number = 0
}
else {
switch (this.number) {
case (0) {
this.visible = false
}
case (1) {
this.visible = true
this.listalias = GetDisplayAlias(this)
}
default {
this.visible = true
this.listalias = GetDisplayAlias(this) + " (×" + this.number + ")"
}
}
}

Forgewright
24 Sept 2018, 15:02Much better mrangel

Mr.Night
24 Sept 2018, 23:25How I managed to get it working is making an attribute called statusattribute and setting it to chocolate: !/G
It works well because each 1 represents 1 gram, instead of using money.
Only issue im having is still being able to use chocolate when the counter is at zero.