Forum rules - please read before posting.

Display item amounts

My InventoryBox menu element is set to display item amounts "only if multiple". This works well because most of my items have a slot capacity of 1, and I don't want a number over them. Coins have a slot capacity of 99 though, and I'd like the number to be displayed even when there is only one coin in the slot (I drew the sprite so that the number appears to be engraved on the coin). I'm not sure how to write a script to do this - I might be able to modify AC's code for this purpose, but I know this is not best practice and that this would make the AC update process cumbersome. Any insight on how I could achieve this?

Relatedly, it would be really nice to be able to pick the colour of the display count text for the inventory cursor (currently you can do this for the inventory menu only).

Comments

  • I'd like the number to be displayed even when there is only one coin in the slot

    At the moment, it'd involve editing the MenuInventoryBox script's GetCount function, but I'll give some thought about how this might be made optional.

    Relatedly, it would be really nice to be able to pick the colour of the display count text for the inventory cursor

    Noted, thanks.

  • For anyone who might be interested:

    • Chris implemented the above request by adding the option to display item amounts "Only If Stackable" (on the container menu element).
    • I also asked him if a similar option could be added to the inventory cursor. He added the ability to do this by subclassing RuntimeInventory ourselves. To do this, remove the RuntimeInventory component from the PersistentEngine prefab and add this one instead:

      using UnityEngine;
      using System.Collections.Generic;
      using AC;
      
      public class CustomRuntimeInventory : RuntimeInventory
      {
          protected override string GetInventoryCountText()
          {
              if (InvInstance.IsValid(selectedInstance))
              {
                  int displayCount = selectedInstance.TransferCount;
                  if (selectedInstance.InvItem.canCarryMultiple && selectedInstance.InvItem.maxCount > 1)
                  {
                      return displayCount.ToString();
                  }
              }
              return string.Empty;
          }
      }
      
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.