[MOD] Tool Ranks and Modifiers [lib_trm][git]

Post Reply
ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

[MOD] Tool Ranks and Modifiers [lib_trm][git]

by ShadMOrdre » Post

What is Tool Ranks and Modifiers?

This mod simply combines the two wonderful mods, toolranks (by lisacvuk) and c-t-m (by davidthecreator).

I have tested this on MT v5.0.1. Due to the on_mods_loaded call, it will not work on previous versions. However, do not worry. If a version of this mod for MT previous versions is in high enough demand, I can repost previous versions which may have worked. Whatever version of MT you use must support the register_on_crafted API function for the craft modifiers to work, and must support the on_mods_loaded API function, for the overrides to take effect. Due to this function call, and the inability to check MT versions, this may crash previous versions of MT.

In order to avoid both dependency nightmares, and to avoid requiring mods to specifically modify tool registration code or add dependencies, this mod was born.

This mod has no dependencies, nor requires any recoding or dependency by mods using this functionality. This mod uses the on_mods_loaded function to override all registered tools to add the above functionality. If there are any specific mods for which I should disable the override, please let me know.

If you experience any issues, please let me know. Also, if you like this mod, please, drop a line.


DOWNLOAD and SOURCE: lib_trm

Image
Image
Image
Attachments
screenshot_20190906_155920.jpg
screenshot_20190906_155920.jpg (244.39 KiB) Viewed 1154 times
screenshot_20190906_155913.jpg
screenshot_20190906_155913.jpg (246.03 KiB) Viewed 1154 times
screenshot_20190906_155858.jpg
screenshot_20190906_155858.jpg (230.1 KiB) Viewed 1154 times

User avatar
runs
Member
Posts: 3225
Joined: Sat Oct 27, 2018 08:32

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by runs » Post

Translation support. Toolranks used descriptions to identify items, so no internationalization possible.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ShadMOrdre » Post

I've updated this mod to use 1 of 3 available translation modes.

Enabled, by default, is an optional dependency on intllib mod. This is to maintain backwards compatibility.

If intllib mod is not installed or enabled, then lib_trm will fall back to an included intllib.lua module. As a native English speaker, I would need assistance if translations are needed.

To enable the MT v5.0+ built in translation module, go to the settings menu for lib_trm, and enable support there. Please note, that while I've used the intllib modules in previous mods, I am not yet familiar with the new builtin translation functionality, and this might be buggy.

Please let me know if this helps. It's also possible to apply the translation function around the description texts, but translations are already a tricky thing, so this might also need work.

Please report any issues, suggestions, or complaints. Thanks in advance.

Shad

ThorfinnS
Member
Posts: 311
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ThorfinnS » Post

I got a report from players (and confirmed it) that if you "repair" a pickaxe by creating a new pickaxe, then "merge" the worn out pick and the new pick, the property "disappears" after mining one node. I think it's only the description, though. In testing, I got a demonic stone shovel, and when digging stone, it was making the sound one gets from a pick going at stone, even though the description dropped back to regular old stone shovel. I made another stone shovel, and this one didn't do the same sound, and had no modifier. It also reported back 0 nodes dug, though the very next node dug said 120 or whatever nodes. Makes sense, I guess, since it looks like it's creating a new tool, rather than just updating the use count on an existing tool.

Repair seems to retain the properties, but not the description.

Might be one of the several dozen mods I have loaded, though. I have toolranks disabled, and don't have c-t-m- downloaded at all. Might also be the check to see if toolranks exists, rather than is enabled, I suppose.

[EDIT]
Oh, and the stone hoe I tried out made no sound at all before it broke. With Toolranks, it gives at least two warning sounds that it's going to break.
[/EDIT]

ThorfinnS
Member
Posts: 311
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ThorfinnS » Post

Here's what I'm talking about.
Pick has properties
Pick has properties
has-props.png (18.9 KiB) Viewed 1154 times
...after digging one stone block,
...after digging one stone block,
one-use.png (17.64 KiB) Viewed 1154 times
...there's no longer properties in the hover.
...there's no longer properties in the hover.
first.png (13.77 KiB) Viewed 1154 times

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ShadMOrdre » Post

ThorfinnS,

Yes, I've encountered this issue. Thank you for reporting.

I've got this fixed, just not in a way that I am comfortable with, ie, there are still "issues" regarding the tooltips and the way they are managed. With a little more integration between the two mods, the issues will go away. Note, due to the way that the description field is handled, there will continue to be issues with other mods that directly write the description, without accommodating the existing description. Those mods will need to be updated to correctly write the descriptions, without overwriting what any other mod may be adding to a tools description.

I also want to attempt creating armor modifiers, but I'll wait until after I post this update.

Again, thanks for your reporting.

Shad

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ShadMOrdre » Post

I am happy to announce this update.

Tools now maintain the description field across level ups. Tools and armor both benefit from the tool ranks code. At this time, only tools use the modifiers. Included in this update, is a function that overrides defined tools and armor, to now use the tool ranks and modifiers code. For mods that have already hard-coded support for toolranks mod, they will be ignored by this mod, but can still use the toolranks namespace from this mod. For any mod that defines either tools or armor, and that does not provide support for toolranks, those tools and armors will be overridden to use this mod.

Tool repair is correctly handled via the anvil mod, or the anvil found in the cottages mod. Both anvils correctly repair the wear value of the existing itemstack, thus, the tool is repaired, not replaced, and retains it's modifers and levels. As a game play mechanic, this should be preferred to tool repair recipes for the craft grid.

Tool repair via the crafting grid will never work, because, technically, the worn/damaged tools are not repaired, but are instead used to craft a new tool from the worn/damaged existing tools. The new tool takes on default values, since it is a new itemstack from the craft grid. This is not something that can be corrected easily, from within a mod. IMO, I'm not entirely sure that tool repair recipes for the craft grid are the right way to "fix" damaged tools, from a game play mechanics perspective. Either way, I will not address or try to accommodate tool repair via the crafting grid due this issue.

Armor modifiers are still on my TO DO list.

Please let me know if the resolves the existing issues, sans the craft grid repair issue.

DOWNLOAD: lib_trm


Shad

User avatar
Lone_Wolf
Member
Posts: 2576
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by Lone_Wolf » Post

When repairing tools via the crafting grid just copy over the attributes from the highest ranking tool?
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

ThorfinnS
Member
Posts: 311
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ThorfinnS » Post

Never mind. I thought for sure I had disabled toolranks to give this a whirl, but not so much...

User avatar
Skamiz Kazzarch
Member
Posts: 613
Joined: Fri Mar 09, 2018 20:34
GitHub: Skamiz
In-game: Skamiz
Location: la lojbaugag.

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by Skamiz Kazzarch » Post

Letest version of trm, latest version of minetest, fresh world with only this mod enabled 2019-10-04 09:56:16: ACTION[Server]: singleplayer joins game. List of players: singleplayer

Code: Select all

2019-10-04 09:56:19: ACTION[Server]: singleplayer digs default:snow at (298,6,156)
2019-10-04 09:56:19: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback node_on_dig(): ...ames\minetest\bin\..\mods\lib_trm/lib_trm_tool_ranks.lua:81: attempt to concatenate local 'itemdesc' (a nil value)
2019-10-04 09:56:19: ERROR[Main]: stack traceback:
2019-10-04 09:56:19: ERROR[Main]: 	...ames\minetest\bin\..\mods\lib_trm/lib_trm_tool_ranks.lua:81: in function 'after_use'
2019-10-04 09:56:19: ERROR[Main]: 	C:\Games\minetest\bin\..\builtin\game\item.lua:569: in function <C:\Games\minetest\bin\..\builtin\game\item.lua:537>
2019-10-04 09:56:19: ACTION[Server]: singleplayer leaves game. List of players: 
2019-10-04 09:56:19: ACTION[Main]: Server: Shutting down
Edit:
Un-comenting line 53 in init.lua seems to have fixed it.

ThorfinnS
Member
Posts: 311
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ThorfinnS » Post

Thanks, Skamiz Kazzarch. That's the same message I was getting, and lisacvuk's toolranks WAS disabled. (I was looking at the wrong game setup.)

Might be something to do with all the warnings lib_trm is throwing on load. Undefined globals, IIRC. An undefined global would likely explain the attempting to concatenate a nil value error.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ShadMOrdre » Post

Thanks for reporting this.

I had ran into this, late one night, fixed it, but didn't push the fix.

I have corrected this on Github, and noticed, in the process, that there may still be issues with how descriptions and the toolranks original_description are handled. While all seems to work, at the moment, there may still be issues around this. I will make some minor changes to the code, which should not affect the current functionality, but will help to eliminate error messages popping up from an inconsistent method of determining the description and original_description itemstack definitions.

Again, this should not affect current functionality. This will only be to help eliminate potential future error messages, especially from mods that use the description field, but are not "tool" mods, like the vendors. This won't fix the other issues related to those mods, as those mods have to be updated to read/write the descriptions of itemstacks in a way that won't overwrite the existing itemstack description.

As always, thank you for reporting and all the other feedback.

Shad

User avatar
Imk
Member
Posts: 490
Joined: Mon Nov 05, 2018 19:15
In-game: Imk
Location: Crimea, Russia
Contact:

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by Imk » Post

Kraft according to this recipe battery (Mod technic)
viewtopic.php?p=364595#p364595

updated new Mod Tool ranks, Technic
one battery turned out okay.
doing more another mistake

Code: Select all

2020-01-03 17:58:47: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod '' in callback item_OnCraft(): ...est/bin/../mods/lib_trm/lib_trm_toolcap_modifier.lua:81: attempt to perform arithmetic on local 'atk' (a nil value)
2020-01-03 17:58:47: ERROR[Main]: stack traceback:
2020-01-03 17:58:47: ERROR[Main]:       ...est/bin/../mods/lib_trm/lib_trm_toolcap_modifier.lua:81: in function 'func'
2020-01-03 17:58:47: ERROR[Main]:       /home/imk/minetest/bin/../builtin/game/register.lua:304: in function </home/imk/minetest/bin/../builtin/game/register.lua:302>

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ShadMOrdre » Post

Imk,

Thanks for reporting this issue.

The issue is that the battery tool registered by technic does not contain a fleshy group. As such, I could choose to ignore those tools, but thus, also denying those tools to have the abilities provided by this mod. The better solution, IMO, would be to provide a default value for the fleshy group. As to what the default should be, I'm open to suggestions, and could even try to implement a settable option or multiple possible defaults.

I'd rather not hard code for specific mods, to avoid dependencies. There are better ways to check for the existence of an item, node or tool, that do not involve hard coded dependencies.

I must admit, I've been busy with life, and other projects, so before I go to far in any direction, I'd like to see if there are other mods for which this or a similar issue might appear, so as to implement the best solution.

In the meantime, if you are willing, a stub mod could be made that simply adds the fleshy group to the technic tools that are affected by using lib_trm. This could probably be made quickly, from my perspective, as a stop gap band aid, until a better solution is implemented.

Any thoughts or suggestions are welcome.

Shad

User avatar
Desour
Member
Posts: 1469
Joined: Thu Jun 19, 2014 19:49
GitHub: Desour
IRC: Desour
In-game: DS
Location: I'm scared that if this is too exact, I will be unable to use my keyboard.

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by Desour » Post

ShadMOrdre wrote:(In technic: viewtopic.php?f=11&t=2538&view=unread#p364858)
DS-minetest, are you aware of any other tools, and / or mods, that might include tools without the fleshy group? I know you've been around awhile, so might have exposure to more mods than I. Thanks in advance, and you can reply in the other thread, if you prefer.
Well, technic also has the water and lava can and energy crystals. And mtg's hoes and screwdriver might be missing the fleshy group, too. Apart from that I can't really remember any mods that include craftable tools with wear.

Imo such "tools" that are no real tools (are not used for digging or fighting) should rather be ignored than default-valued. Changing damage- and dig-groups is probably just weird and changing the max tool-wear might even - in the worst case - cause server crashes.
he/him; Codeberg; GitHub; ContentDB; public personal TODO list; "DS" is preferred (but often too short)

User avatar
Imk
Member
Posts: 490
Joined: Mon Nov 05, 2018 19:15
In-game: Imk
Location: Crimea, Russia
Contact:

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by Imk » Post

this addendum might come in handy

ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod '' in callback item_OnCraft(): ...est/bin/../mods/lib_trm/lib_trm_toolcap_modifier.lua:266: attempt to perform arithmetic on local 'atk' (a nil value)
ERROR[Main]: stack traceback:
ERROR[Main]: ####
ERROR[Main]: /home/imk/minetest/bin/../builtin/game/register.lua:304: in function </home/imk/minetest/bin/../builtin/game/register.lua:302>



where ####

...est/bin/../mods/lib_trm/lib_trm_toolcap_modifier.lua:266: in function 'func'

...est/bin/../mods/lib_trm/lib_trm_toolcap_modifier.lua:156: in function 'func'

...est/bin/../mods/lib_trm/lib_trm_toolcap_modifier.lua:244: in function 'func'

...est/bin/../mods/lib_trm/lib_trm_toolcap_modifier.lua:94: in function 'func'

Evolution_Pixels
New member
Posts: 7
Joined: Tue Jan 14, 2020 08:14
Location: Russian Federation

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by Evolution_Pixels » Post

Pull Request with bug fixes for RE Battery crafting in Technic mod was sent.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ShadMOrdre » Post

Evolution_Pixels,

Thank you for the pull req. It has been merged.

Please let me know if this solves the issue for non-Technic tools, or if you encounter any further issues.



Shad

Evolution_Pixels
New member
Posts: 7
Joined: Tue Jan 14, 2020 08:14
Location: Russian Federation

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by Evolution_Pixels » Post

Pull Request with bug fixes for other craft objects.
PS. Everything that couldn't work in other mods is working now.

ShadMOrdre
Member
Posts: 1118
Joined: Mon Dec 29, 2014 08:07
Location: USA

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ShadMOrdre » Post

Evolution_Pixels,

Again, thanks for the pull req. It has been merged.

Shad

Evolution_Pixels
New member
Posts: 7
Joined: Tue Jan 14, 2020 08:14
Location: Russian Federation

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by Evolution_Pixels » Post

ShadMOrdre wrote:Evolution_Pixels,

Again, thanks for the pull req. It has been merged.

Shad
If found anything bug or error I send PR.

ThorfinnS
Member
Posts: 311
Joined: Mon Feb 25, 2019 22:05
GitHub: ThorfinnS

Re: [MOD] Tool Ranks and Modifiers [lib_trm][git]

by ThorfinnS » Post

Maybe another reqd nil check? Like the battery in, um, [techage], was it? This from [sickles].
Spoiler
2020-05-24 08:10:44: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod '' in callback item_OnCraft(): ...\latest\bin\..\mods\lib_trm/lib_trm_toolcap_modifier.lua:13: attempt to index field 'groupcaps' (a nil value)
2020-05-24 08:10:44: ERROR[Main]: stack traceback:
2020-05-24 08:10:44: ERROR[Main]: ...\latest\bin\..\mods\lib_trm/lib_trm_toolcap_modifier.lua:13: in function 'func'
2020-05-24 08:10:44: ERROR[Main]: C:\games\mt\latest\bin\..\builtin\game\register.lua:304: in function <C:\games\mt\latest\bin\..\builtin\game\register.lua:302>

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests