New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add wear bar color API #13328
Add wear bar color API #13328
Conversation
Nice. I like it when things get un-hardcoded in Minetest. Could be useful for technic tools which use the wear bar for a charge level. I did not test but I looked at the documentation. I strongly suggest to explicitly explain the purpose of Suggestions for future PRs:
|
I also think that'd be a great feature, since what is critically high wear (which is basically what the red/yellow color of the wear bar is supposed to indicate) can vary greatly based on what gameplay mechanism the item/ item wear bar is used for and what the wear bar is meant to indicate. For example if the wear bar is used to indicate temperature (e.g. for a thermometer item) then having it get red when it gets low doesn't make a lot of sense, so allowing modders to change wear bar color for an item via metadata would open a lot of possibilities for how mods can use the little bar under an item. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase this PR (do not merge branch) to current master
branch. It should only consists of your commits (around 5 or 7 in this PR). You can read more here.
1bef033
to
1acd2a3
Compare
Thanks for the link! Being not super experienced with git (I tend to just have 1 or 2 branches on personal projects), I didn't think of the fact that if I didn't force push, the history on github would clash with my rebased history, and so I accidentally did a merge I shouldn't have. All fixed now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concept and implementation look good. I have also tested it, but I have not checked its performance. There are some code styles fix needed, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few changes needed. Sorry for my mistakes in the last review.
No problem at all, I really appreciate that you're spending time looking at it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good to me. Further improvements can be added later.
@techno-sam rebase needed (we forgot to tell you, sorry!) |
No problem! |
Done @Zughy |
Co-authored-by: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com>
Co-authored-by: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com>
Co-authored-by: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com>
Co-authored-by: Muhammad Rifqi Priyo Susanto <muhammadrifqipriyosusanto@gmail.com>
new, simplified API for wear bar coloring
4d4465d
to
24f39a4
Compare
f3926ad
to
8e292ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored a bit, please review @techno-sam (and @srifqi) to make sure you're still happy with it. Tested, everything works as expected. Thank you very much for the good work!
Another documentation thing: This PR adds "Wear Bar Color" as a separate top-level section in |
@appgurueu thanks for your refactor. I'm afraid I forgot to clean up after myself when I condensed the API. |
Using wear values directly instead of "durability" values would still be more consistent IMO (what do others think?) However, if we decide to use "durability" values for whatever reason, it would be good to add a definition of "durability" as |
Adds an api for modders to change the appearance of the wear bar on their tools.
Currently, the tool damage bar (called "wear bar" by dev wiki) color cannot be customized by modders, and is listed under hardcoded features. This PR fixes that by adding fields in item def as well as item metadata to change the appearance. (See lua_api.txt for api specifics)
Resolves #13325
Summary
The
wear_bar
field in item definitions and item meta allows modders to customize the color of wear bars in a variety of ways.To do
This PR is Ready for Review.
How to test
In the devtest game, grab a few of the pickaxes (5, 10, 50, and 100 use pickaxes are customized) and dig some stone, allowing their wear bars to appear. Note the progression through different colors (as described by the tool description) when the pickaxe takes more damage.
Additionally, there is a pickaxe called "Wear Bar Color Test," that when punched with will use a random color for its wear bar. You can use the
/use_tool
command to damage the tool a bit in order to allow the wear bar to appear.Screenshot demonstrating the different color possibilities: