# Potential Mod - workshop inventory display

**URL:** <https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654>\
**Category:** Modding\
**Created:** [July 7, 2018, 6:45pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654 "2018-07-07T18:45:11Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![illdred](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/illdred/32/51973_2.png) [@illdred](https://discourse.stonehearth.net/u/illdred)\
**Post date:** [July 7, 2018, 6:45pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/1 "2018-07-07T18:45:11Z")

</div>

Hi everyone,

I have a mod. It makes it so that when you open a workshop and select an item to craft, the mod displays how many of that item you have already.

Is there any interest for this mod being available either on steamworkshop and/or here on the forum?

:merry:

---

<div class="post-metadata">

**Author:** ![coasterspaul](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/coasterspaul/32/47876_2.png) [@coasterspaul](https://discourse.stonehearth.net/u/coasterspaul)\
**Post date:** [July 7, 2018, 7:00pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/2 "2018-07-07T19:00:34Z")

</div>

That… sounds amazing.

I’d have to see a screenshot, but this seems like the sort of feature I could easily see fitting in the main game during this last push.

---

<div class="post-metadata">

**Author:** ![illdred](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/illdred/32/51973_2.png) [@illdred](https://discourse.stonehearth.net/u/illdred)\
**Post date:** [July 7, 2018, 7:06pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/3 "2018-07-07T19:06:28Z")

</div>

Here are a couple screenshots (they’re older screenshots, but the idea is there)

 ![stonehearth%20workshop%20inventory%20display%20mod%20work%20in%20progress%20%232](https://us1.discourse-cdn.com/flex022/uploads/stonehearth/original/3X/c/2/c26c5656677e9156b25e0b1bf9a4997a1d1b6ddd.PNG)

 ![stonehearth%20workshop%20inventory%20display%20mod%20work%20in%20progress](https://us1.discourse-cdn.com/flex022/uploads/stonehearth/original/3X/9/2/9232f3be4818aebcd534ec7a2230d99b0ad924ea.jpg)

(note the "Inventory" tab to the right of the "Recipes" and "Orders" tabs)

---

<div class="post-metadata">

**Author:** ![No\_Name](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/no_name/32/62699_2.png) [@No\_Name](https://discourse.stonehearth.net/u/No_Name)\
**Post date:** [July 7, 2018, 7:15pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/4 "2018-07-07T19:15:30Z")

</div>

hey, that looks nice 😃  
to be honest i was thinking if it would be something needed or not or usefull at all but now i see it i like it 😁

---

<div class="post-metadata">

**Author:** ![max99x](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/max99x/32/40094_2.png) [@max99x](https://discourse.stonehearth.net/u/max99x)\
**Post date:** [July 7, 2018, 7:56pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/5 "2018-07-07T19:56:06Z")

</div>

I would use this myself all the time. Heads up, though: I’m modifying the workshop menu as part of an optimization pass, so if you’re relying on its current inventory tracker, that won’t be there anymore in the next release.

---

<div class="post-metadata">

**Author:** ![illdred](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/illdred/32/51973_2.png) [@illdred](https://discourse.stonehearth.net/u/illdred)\
**Post date:** [July 7, 2018, 8:09pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/6 "2018-07-07T20:09:49Z")

</div>

I do use an inventory tracker, the same one that the “Town Overview”'s “Inventory” tab uses.

```javascript
radiant.call_obj('stonehearth.inventory', 'get_item_tracker_command', 'stonehearth:basic_inventory_tracker')
    .done(function (response) {
        self.workshopInventoryDisplayData.basicInventoryTrace = new StonehearthDataTrace(response.tracker, self.workshopInventoryDisplayData.itemTraces)
            .progress(function (response) {
//....

```

@max99x, this tracker reports talisman items, like cook’s spoon, as non-iconic form when they are sitting in the stockpile.

I use this check to see if it is “iconic” form of the item, then if it is NOT an iconic, then count it as “deployed”/“placed”:

```javascript
var isIconic = false;
if (item.canonical_uri && item.canonical_uri. __self != item.uri.__ self) {
    isIconic = true;

```

is there a better way to determine if a talisman is in stock, rather than equipped/used/placed?

Let me know if you need any further information.

:merry:

---

<div class="post-metadata">

**Author:** ![paulthegreat](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/paulthegreat/32/62395_2.png) [@paulthegreat](https://discourse.stonehearth.net/u/paulthegreat)\
**Post date:** [July 7, 2018, 8:13pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/7 "2018-07-07T20:13:55Z")

</div>

Is that specific to the talismans? Are `item.canonical_uri` and `item.uri` simply strings that don’t have a `.__self` property so that ends up being a null comparison?

---

<div class="post-metadata">

**Author:** ![illdred](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/illdred/32/51973_2.png) [@illdred](https://discourse.stonehearth.net/u/illdred)\
**Post date:** [July 7, 2018, 8:47pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/8 "2018-07-07T20:47:15Z")

</div>

yes, it seems to just be the talismans. I’ll check to see if those two properties are plain strings. Thanks for the suggestion.

Edit: Yes, for talismans, the `item.canonical_uri` property doesn’t exist, so talismans are always non-iconic by my checking code.

---

<div class="post-metadata">

**Author:** ![max99x](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/max99x/32/40094_2.png) [@max99x](https://discourse.stonehearth.net/u/max99x)\
**Post date:** [July 8, 2018, 3:07pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/9 "2018-07-08T15:07:45Z")

</div>

> [@illdred](#):
>
> I do use an inventory tracker, the same one that the “Town Overview”'s “Inventory” tab uses.

If you create your own like that it’s fine. The change is only that `StonehearthTeamCrafterView` no longer uses one itself so you can’t share the one it used to have.

> I use this check to see if it is “iconic” form of the item

“Iconic” is not always a synonym for “item”. You probably want `App.catalog.getCatalogData(uri).is_item`.

---

<div class="post-metadata">

**Author:** ![illdred](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/illdred/32/51973_2.png) [@illdred](https://discourse.stonehearth.net/u/illdred)\
**Post date:** [July 10, 2018, 5:49am UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/10 "2018-07-10T05:49:11Z")

</div>

Thanks for your help, @max99x & @paulthegreat.

I’ve put the mod up on the steam workshop and here on the forum:

> [@\[Mod\] Workshop Inventory Display](https://discourse.stonehearth.net/t/mod-workshop-inventory-display/36804):
>
> Hi everyone! This mod shows an additional information panel in the crafter’s workshop to display the number of items you already have (in stock and deployed) for the currently selected crafting recipe. Changes: July 13: Updated to be much much mo…

:merry:

---

<div class="post-metadata">

**Author:** ![Nikolay](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/nikolay/32/60048_2.png) [@Nikolay](https://discourse.stonehearth.net/u/Nikolay)\
**Post date:** [July 10, 2018, 7:22am UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/11 "2018-07-10T07:22:19Z")

</div>

Is it possible to add 3rd counter to show amount of items required to finish buildings?

---

<div class="post-metadata">

**Author:** ![illdred](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/illdred/32/51973_2.png) [@illdred](https://discourse.stonehearth.net/u/illdred)\
**Post date:** [July 10, 2018, 8:49am UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/12 "2018-07-10T08:49:29Z")

</div>

@Nikolay, I like your idea. I’ll investigate, but it sounds tough :merry:

---

<div class="post-metadata">

**Author:** ![illdred](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/illdred/32/51973_2.png) [@illdred](https://discourse.stonehearth.net/u/illdred)\
**Post date:** [July 10, 2018, 8:58am UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/13 "2018-07-10T08:58:26Z")

</div>

@max99x,

`App.catalog.getCatalogData(uri)` did help. Thanks you.

If I have a uri and/or the CatalogData for a talisman like `stonehearth:trapper:talisman`, is there a good way to match it to the item version that the trapper equips?

For example, if I have the trapper talisman, `stonehearth:trapper:talisman`, the result I want is `stonehearth:trapper:knife`.

:merry:

---

<div class="post-metadata">

**Author:** ![max99x](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/max99x/32/40094_2.png) [@max99x](https://discourse.stonehearth.net/u/max99x)\
**Post date:** [July 11, 2018, 3:12pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/14 "2018-07-11T15:12:54Z")

</div>

> [@illdred](#):
>
> If I have a uri and/or the CatalogData for a talisman like `stonehearth:trapper:talisman`, is there a good way to match it to the item version that the trapper equips?
> 
> For example, if I have the trapper talisman, `stonehearth:trapper:talisman`, the result I want is `stonehearth:trapper:knife`.

The two are not really related at the technical level. The latter is just the default weapon of the Trapper class (and that class has no other weapons). If you really want to count them, I’d just count citizens with that job.

---

<div class="post-metadata">

**Author:** ![illdred](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/illdred/32/51973_2.png) [@illdred](https://discourse.stonehearth.net/u/illdred)\
**Post date:** [July 11, 2018, 5:00pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/15 "2018-07-11T17:00:21Z")

</div>

Thank you for the reply, @max99x.

I want to count them so that when the user selects a talisman recipe, then the mod can show how many are equipped.

Do you reckon that looking up all jobs and mapping the `"talisman_uri"` to the `"equipment.mainhand"` would be a dependable solution?

---

<div class="post-metadata">

**Author:** ![paulthegreat](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.stonehearth.net/paulthegreat/32/62395_2.png) [@paulthegreat](https://discourse.stonehearth.net/u/paulthegreat)\
**Post date:** [July 11, 2018, 5:51pm UTC](https://discourse.stonehearth.net/t/potential-mod-workshop-inventory-display/36654/16 "2018-07-11T17:51:21Z")

</div>

Talismans have a unique one-to-one relationship with professions, so I’d just look at the number of each job to determine how many of that talisman is equipped. You don’t need to look at individual hearthling entities and their equipment.
