Clopen

How to Refresh Inventory Item Percentage

Recommended Posts

Clopen    11

I have some code that updates the durability of an armor (repairs it) in a timed task.
It works, but the durability percentage only updates if I unequip it or equip it again.
How do I get the item slot to refresh its state?

... Well, actually, I did get this to work by piggybacking on the "fueled" component's event:

inst:PushEvent("percentusedchange", { percent = inst.components.armor:GetPercent() })

But that looks like an underhanded trick that only works since the ItemTile widget calls the same SetPercent function for both and doesn't look very closely at the inventory item that pushed the event.
I'd be happier if I could just call a "refresh inventory bar" function or something of the same ilk.

Thanks in advance. =)

Share this post


Link to post
Share on other sites
Ultroman    340

Using Armor:SetCondition or any of the functions of the armor which make use of that function, should automatically update the inventory tile, since it itself pushes the event "percentusedchange". How are you changing the durability of the armor, if not by using any of these functions?

Share this post


Link to post
Share on other sites
Clopen    11

Ugh, I don't know what's wrong with me lately. >_<
I went over all the code in armor.lua searching for a function to modify the armor durability and somehow I missed that one.
I only saw TakeDamage.

Thanks. =\

Share this post


Link to post
Share on other sites
Ultroman    340

You're welcome :) We all miss obvious things sometimes. You fixed it by asking your peers. That's part of growing, m8 ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now