Show object counter in inventory?

I 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.


I believe you need to change the object's listalias attribute to the name you want to display.


I 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.


Yeah, 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.


I 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.


if (silver <= 0)  {
  silver.parent = holding_room
}
else {
  silver.parent = player
}

If 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 + ")"
    }
  }
}

Much better mrangel


How 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.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums