Skip to content

Custom HUD Best Practices

Hannele Ruiz edited this page Jan 2, 2021 · 1 revision

Interested in creating a custom HUD for the Inventory? Here are some things that should help you.

Is Ready

Avoid calling any PlayerCompanion functions and accessors before the Companion.IsReady property is set to true. This will make sure that all of the external DLLs of other mods are loaded and that we are able to restore the items from the inventory files.

The Companion.Ready event will be triggered once PlayerCompanion is ready to work. You can use this event if you want to avoid constantly checking the Companion.IsReady property.

Items Added and Removed

PlayerCompanion has events for detecting when an Item is Added or Removed. This two events will be triggered from any player inventory, meaning that you can use them to add and remove visible items from your on screen HUD at any time. They are Companion.Inventory.ItemAdded and Companion.Inventory.ItemRemoved.

Count Changed

It is not recommended to use the CountChanged event of Stackable Item's when implementing custom HUDs, unless you need to format a string with the current item count.

A good example is the stock Inventory Menu, where the count is formated in a string like {name} ({count}).

Clone this wiki locally