Page 1 of 1

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

Posted: Fri Sep 06, 2019 22:54
by ShadMOrdre
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

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

Posted: Sat Sep 07, 2019 23:38
by runs
Translation support. Toolranks used descriptions to identify items, so no internationalization possible.

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

Posted: Sun Sep 08, 2019 07:09
by ShadMOrdre
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

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

Posted: Tue Sep 10, 2019 04:15
by ThorfinnS
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]

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

Posted: Wed Sep 11, 2019 18:02
by ThorfinnS
Here's what I'm talking about.
has-props.png
Pick has properties
(18.9 KiB) Not downloaded yet
one-use.png
...after digging one stone block,
(17.64 KiB) Not downloaded yet
first.png
...there's no longer properties in the hover.
(13.77 KiB) Not downloaded yet

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

Posted: Mon Sep 16, 2019 23:01
by ShadMOrdre
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

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

Posted: Tue Sep 24, 2019 05:13
by ShadMOrdre
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

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

Posted: Thu Oct 03, 2019 20:02
by Lone_Wolf
When repairing tools via the crafting grid just copy over the attributes from the highest ranking tool?

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

Posted: Fri Oct 04, 2019 03:55
by ThorfinnS
Never mind. I thought for sure I had disabled toolranks to give this a whirl, but not so much...

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

Posted: Fri Oct 04, 2019 08:00
by Skamiz Kazzarch
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.

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

Posted: Fri Oct 04, 2019 16:50
by ThorfinnS
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.

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

Posted: Fri Oct 04, 2019 18:36
by ShadMOrdre
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

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

Posted: Fri Jan 03, 2020 14:11
by Imk
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>

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

Posted: Mon Jan 06, 2020 04:50
by ShadMOrdre
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

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

Posted: Mon Jan 06, 2020 09:56
by DS-minetest
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.

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

Posted: Mon Jan 06, 2020 17:23
by Imk
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'

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

Posted: Mon Jan 20, 2020 11:29
by Evolution_Pixels
Pull Request with bug fixes for RE Battery crafting in Technic mod was sent.

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

Posted: Wed Jan 22, 2020 08:29
by ShadMOrdre
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

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

Posted: Fri Jan 24, 2020 08:17
by Evolution_Pixels
Pull Request with bug fixes for other craft objects.
PS. Everything that couldn't work in other mods is working now.

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

Posted: Fri Jan 31, 2020 22:45
by ShadMOrdre
Evolution_Pixels,

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

Shad

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

Posted: Sat Feb 01, 2020 20:23
by Evolution_Pixels
ShadMOrdre wrote:Evolution_Pixels,

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

Shad
If found anything bug or error I send PR.

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

Posted: Sun May 24, 2020 13:16
by ThorfinnS
Maybe another reqd nil check? Like the battery in, um, [techage], was it? This from [sickles].
+ Spoiler