[MOD] Tool ranks [toolranks]

KCoombes
Member
Posts: 427
Joined: Thu Jun 11, 2015 23:19
In-game: Knatt
Location: SW Florida, USA

Re: [MOD] Tool ranks [toolranks]

by KCoombes » Post

Is there a limit to how many levels a tool can gain?

User avatar
lisacvuk
Member
Posts: 274
Joined: Sat Jul 19, 2014 11:52
GitHub: lisacvuk
IRC: lisac
In-game: lisacvuk
Location: Serbia, Užice

Re: [MOD] Tool ranks [toolranks]

by lisacvuk » Post

6, at 1600 nodes
It's lisac, not lisa.
400 character limit? Am I writing a book?
Administrator on Craig's server. Minetest player.
"The enemy pales when they see the face of Dazzle!" ~ Dazzle obviously.
I live in Serbia.
Steam | OpenDOTA
My mods:
Tool ranks
I appreciate donations in TF2 items. :)

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [MOD] Tool ranks [toolranks]

by azekill_DIABLO » Post

cuz otherwise my pick would have somethin' like: lvl 78...
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

ABJ
Member
Posts: 3015
Joined: Sun Jan 18, 2015 13:02
GitHub: ABJ-MV
In-game: ABJ
Location: In Earth orbit, with a perigee of 1048 km and an apogee of 1337 km and an inclination of 69 degrees.

Re: [MOD] Tool ranks [toolranks]

by ABJ » Post

Get sorcerykid here too!

User avatar
TumeniNodes
Member
Posts: 2943
Joined: Fri Feb 26, 2016 19:49
GitHub: TumeniNodes
IRC: tumeninodes
In-game: TumeniNodes
Location: in the dark recesses of the mind
Contact:

Re: [MOD] Tool ranks [toolranks]

by TumeniNodes » Post

Love this. Definitely adds to gameplay : )
A Wonderful World

auouymous
Member
Posts: 195
Joined: Sun Dec 07, 2014 09:39
GitHub: auouymous
IRC: air
In-game: auouymous

Re: [MOD] Tool ranks [toolranks]

by auouymous » Post

lisacvuk wrote:

Code: Select all

wear = digparams.wear / (1 + level / 4)
I simply brute-forced the above code. No idea how it works, but it seems about right in-game.
For levels 1-6 that code multiplies wear by 1.0, 0.67, 0.57, 0.5, 0.44, and 0.4. The following code is more balanced and offers more than just 6 levels and 1600 broken nodes to get a max level tool.

Code: Select all

toolranks = {
  -- these two settings can be tweaked by the server admin
  min_bits = 6, -- 64 nodes to get level 1
-- min_bits = 7, -- 128 nodes to get level 1
  max_level = 15
}
toolranks.min_nodes = math.pow(2, toolranks.min_bits)
toolranks.max_level_nodes = math.pow(2, toolranks.max_level+toolranks.min_bits-1)

function toolranks.get_level(uses)
  if uses < toolranks.min_nodes then return 0 end
  if uses >= toolranks.max_level_nodes then return toolranks.max_level end
  return 1 + math.log(math.floor(uses / toolranks.min_nodes)) / math.log(2)
end

-- the level>1 check is not needed
local wear = digparams.wear * (1 - (level / toolranks.max_level))
With 15 levels you get wear multipliers of 1.0, 0.93, 0.86, 0.8, 0.73, 0.67, 0.6, 0.53, 0.47, 0.4, 0.33, 0.26, 0.2, 0.13, 0.07 and 0.0. So a level 15 tool becomes unbreakable.

With min_bits=6 a level 15 tool must break 1,048,576 nodes (2,097,152 nodes for min_bits=7). Max level can be decreased to 10 and only require 32,768 or 65,536 nodes. Or it could be increased to 20 and require 33,554,432 or 67,108,864 nodes. Quite flexible.

User avatar
lisacvuk
Member
Posts: 274
Joined: Sat Jul 19, 2014 11:52
GitHub: lisacvuk
IRC: lisac
In-game: lisacvuk
Location: Serbia, Užice

Re: [MOD] Tool ranks [toolranks]

by lisacvuk » Post

Okay, that seems to have took some effort. Thanks for your input.

There were some previous attempts at more levels on GitHub, but they aren't very much liked by server admins. 6 levels seems to be the best possible amount.

Only thing I might change is the number of nodes needed for levels. It doesn't take long for level 6 right now.
It's lisac, not lisa.
400 character limit? Am I writing a book?
Administrator on Craig's server. Minetest player.
"The enemy pales when they see the face of Dazzle!" ~ Dazzle obviously.
I live in Serbia.
Steam | OpenDOTA
My mods:
Tool ranks
I appreciate donations in TF2 items. :)

auouymous
Member
Posts: 195
Joined: Sun Dec 07, 2014 09:39
GitHub: auouymous
IRC: air
In-game: auouymous

Re: [MOD] Tool ranks [toolranks]

by auouymous » Post

I haven't looked at the rest of the toolranks code but would it be possible to show something like "next level at N nodes" in the tooltip? It would let the player know if another level exists and how many nodes are needed to reach it.
lisacvuk wrote:There were some previous attempts at more levels on GitHub, but they aren't very much liked by server admins. 6 levels seems to be the best possible amount.
The new code below has an additional unbreakable_level setting that can be same as or higher than max_level. It controls the actual scale of the wear multiplier while max_level < unbreakable_level disables unbreakable tools.

With bits=7, max=5 and unbreakable=15 you get 6 levels with similar node counts but more balanced wear multipliers. Bumping max_level to 9 adds 4 more levels with level 9 requiring 32768 nodes and giving the same 0.4 wear multiplier your current level 6 gives. Bumping min_bits to 8 would double all the node counts. It allows admins to easily tweak node count and wear multiplier scales, and add more levels. It even has a debug mode to see the values for each level.

Code: Select all

lvl     nodes      wear multiplier
0       0          1
1       128        0.93
2       256        0.87
3       512        0.8
4       1024       0.73
5       2048       0.67  (current level 2 gives this wear)

6       4096       0.6
7       8192       0.53
8       16384      0.47
9       32768      0.4  (current level 6 gives this wear)

Code: Select all

toolranks = {
  -- these three settings can be tweaked by the server admin
--  min_bits = 6, -- 64 nodes to get level 1
  min_bits = 7, -- 128 nodes to get level 1
--  min_bits = 8, -- 256 nodes to get level 1
  max_level = 6,
  unbreakable_level = 15,
  debug = false -- set to true to view node counts and wear multipliers for each level
}
if toolranks.max_level > toolranks.unbreakable_level then
  minetest.log("error", "[toolranks] max_level("..toolranks.max_level..") must be less than or equal to unbreakable_level("..toolranks.unbreakable_level..")")
  toolranks.max_level = toolranks.unbreakable_level
end
toolranks.min_nodes = math.pow(2, toolranks.min_bits)
toolranks.max_level_nodes = math.pow(2, toolranks.max_level+toolranks.min_bits-1)

function toolranks.get_level(uses)
  if uses < toolranks.min_nodes then return 0 end
  if uses >= toolranks.max_level_nodes then return toolranks.max_level end
  return 1 + math.log(math.floor(uses / toolranks.min_nodes)) / math.log(2)
end

-- the level>1 check is not needed
local wear = digparams.wear * (1 - (level / toolranks.unbreakable_level))

-- or maybe get rid of debug setting and always display this info, without the error message
if toolranks.debug then
  print("[toolranks] DEBUG", toolranks.get_level(0), 0, 1)
  for i=1,toolranks.max_level,1 do
    local nodes = math.pow(2, i-1+toolranks.min_bits)
    -- current wear multiplier
--    local wear = 1 / (1 + (i+1) / 4)
    -- new wear multiplier
    local wear = 1 - (i / toolranks.unbreakable_level)
    print("[toolranks] DEBUG", toolranks.get_level(nodes), nodes, wear)
  end
  minetest.log("error", "[toolranks] DEBUG enabled")
end

User avatar
lisacvuk
Member
Posts: 274
Joined: Sat Jul 19, 2014 11:52
GitHub: lisacvuk
IRC: lisac
In-game: lisacvuk
Location: Serbia, Užice

Re: [MOD] Tool ranks [toolranks]

by lisacvuk » Post

First of all, thank you for your interest in my mod, and for the effort of improving it. I know more levels sounds good to multiple players, but I'd like to keep this mod simple. The code looks good and is probably a lot cleaner then mine. I also don't think forum is a good way for developer communication, so I'd appreciate it if you could make a pull request next time.
It's lisac, not lisa.
400 character limit? Am I writing a book?
Administrator on Craig's server. Minetest player.
"The enemy pales when they see the face of Dazzle!" ~ Dazzle obviously.
I live in Serbia.
Steam | OpenDOTA
My mods:
Tool ranks
I appreciate donations in TF2 items. :)

User avatar
ToyElf
Member
Posts: 13
Joined: Fri Apr 21, 2017 19:23
In-game: ToyElf Toy_Elf
Location: Carboard Box
Contact:

Re: [MOD] Tool ranks [toolranks]

by ToyElf » Post

I run into this error whenever i try to play with this mod. I changed the name of the folder to toolranks, and i DID launch the game, but whenever I broke any node it instantly crashed the game. Any ideas? :(
Attachments
000326.png
000326.png (58.51 KiB) Viewed 1105 times

User avatar
kingoscargames
Member
Posts: 216
Joined: Fri Jul 28, 2017 12:06
GitHub: kingoscargames
In-game: kingoscargames
Location: Netherlands

Re: [MOD] Tool ranks [toolranks]

by kingoscargames » Post

You are using a outdated minetest version so try updating that.

User avatar
Napiophelios
Member
Posts: 1035
Joined: Mon Jul 07, 2014 01:14
GitHub: Napiophelios
IRC: Nappi
In-game: Nappi

Re: [MOD] Tool ranks [toolranks]

by Napiophelios » Post

ToyElf wrote:I run into this error whenever i try to play with this mod. I changed the name of the folder to toolranks, and i DID launch the game, but whenever I broke any node it instantly crashed the game. Any ideas? :(
make a blank file called--> mod.conf
open it with a text editor and write this:

Code: Select all

name = toolranks
place your new mod.conf file
inside the mod folder (next to the init.lua file)
and see if it helps

edit: never mind.
why do you have that screen shot if you know that's not the problem?
kingoscargames wrote:You are using a outdated minetest version so try updating that.
yeah...what he said :)

User avatar
lisacvuk
Member
Posts: 274
Joined: Sat Jul 19, 2014 11:52
GitHub: lisacvuk
IRC: lisac
In-game: lisacvuk
Location: Serbia, Užice

Re: [MOD] Tool ranks [toolranks]

by lisacvuk » Post

ToyElf wrote:I run into this error whenever i try to play with this mod. I changed the name of the folder to toolranks, and i DID launch the game, but whenever I broke any node it instantly crashed the game. Any ideas? :(
Rename the mod dir to 'toolranks'
It's lisac, not lisa.
400 character limit? Am I writing a book?
Administrator on Craig's server. Minetest player.
"The enemy pales when they see the face of Dazzle!" ~ Dazzle obviously.
I live in Serbia.
Steam | OpenDOTA
My mods:
Tool ranks
I appreciate donations in TF2 items. :)

User avatar
kingoscargames
Member
Posts: 216
Joined: Fri Jul 28, 2017 12:06
GitHub: kingoscargames
In-game: kingoscargames
Location: Netherlands

Re: [MOD] Tool ranks [toolranks]

by kingoscargames » Post

lisacvuk wrote: Rename the mod dir to 'toolranks'
ToyElf wrote:I changed the name of the folder to toolranks,

User avatar
the_raven_262
Member
Posts: 343
Joined: Mon Sep 22, 2014 09:30
GitHub: theraven262
IRC: [Discord unfortunately] corvus262

Re: [MOD] Tool ranks [toolranks]

by the_raven_262 » Post

ToyElf wrote:I run into this error whenever i try to play with this mod. I changed the name of the folder to toolranks, and i DID launch the game, but whenever I broke any node it instantly crashed the game. Any ideas? :(
You've got outdated minetest, as others already said. It is wise to update at least when a new release is out.

User avatar
lisacvuk
Member
Posts: 274
Joined: Sat Jul 19, 2014 11:52
GitHub: lisacvuk
IRC: lisac
In-game: lisacvuk
Location: Serbia, Užice

Re: [MOD] Tool ranks [toolranks]

by lisacvuk » Post

kingoscargames wrote:
lisacvuk wrote: Rename the mod dir to 'toolranks'
ToyElf wrote:I changed the name of the folder to toolranks,
Kill me
It's lisac, not lisa.
400 character limit? Am I writing a book?
Administrator on Craig's server. Minetest player.
"The enemy pales when they see the face of Dazzle!" ~ Dazzle obviously.
I live in Serbia.
Steam | OpenDOTA
My mods:
Tool ranks
I appreciate donations in TF2 items. :)

User avatar
the_raven_262
Member
Posts: 343
Joined: Mon Sep 22, 2014 09:30
GitHub: theraven262
IRC: [Discord unfortunately] corvus262

Re: [MOD] Tool ranks [toolranks]

by the_raven_262 » Post

lisacvuk wrote:Kill me
Sure thing.

User avatar
ToyElf
Member
Posts: 13
Joined: Fri Apr 21, 2017 19:23
In-game: ToyElf Toy_Elf
Location: Carboard Box
Contact:

Re: [MOD] Tool ranks [toolranks]

by ToyElf » Post

Yup, updating fixed it, thanks! I didn't even realise i was using an outdated version >_> Cheers guys!

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [MOD] Tool ranks [toolranks]

by azekill_DIABLO » Post

the_raven_262 wrote:
lisacvuk wrote:Kill me
Sure thing.
will help too! a little bucket of lava?
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
lisacvuk
Member
Posts: 274
Joined: Sat Jul 19, 2014 11:52
GitHub: lisacvuk
IRC: lisac
In-game: lisacvuk
Location: Serbia, Užice

Re: [MOD] Tool ranks [toolranks]

by lisacvuk » Post

azekill_DIABLO wrote:
the_raven_262 wrote:
lisacvuk wrote:Kill me
Sure thing.
will help too! a little bucket of lava?
Image
It's lisac, not lisa.
400 character limit? Am I writing a book?
Administrator on Craig's server. Minetest player.
"The enemy pales when they see the face of Dazzle!" ~ Dazzle obviously.
I live in Serbia.
Steam | OpenDOTA
My mods:
Tool ranks
I appreciate donations in TF2 items. :)

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [MOD] Tool ranks [toolranks]

by azekill_DIABLO » Post

Cool! Barman? 2 buckets of lava for me and my friend!

Image
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
lisacvuk
Member
Posts: 274
Joined: Sat Jul 19, 2014 11:52
GitHub: lisacvuk
IRC: lisac
In-game: lisacvuk
Location: Serbia, Užice

Re: [MOD] Tool ranks [toolranks]

by lisacvuk » Post

azekill_DIABLO wrote:Cool! Barman? 2 buckets of lava for me and my friend!

Image
I am honored to warrant a custom MS paint artwork, good sir.
It's lisac, not lisa.
400 character limit? Am I writing a book?
Administrator on Craig's server. Minetest player.
"The enemy pales when they see the face of Dazzle!" ~ Dazzle obviously.
I live in Serbia.
Steam | OpenDOTA
My mods:
Tool ranks
I appreciate donations in TF2 items. :)

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [MOD] Tool ranks [toolranks]

by azekill_DIABLO » Post

that not mein work, found it on image sections xD i'm better at drawing (hmm wait no, it would be worst.)
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

einarromero
New member
Posts: 5
Joined: Wed Sep 20, 2017 02:04

Re: [MOD] Tool ranks [toolranks]

by einarromero » Post

I had an issue, game said:

Code: Select all

/home/einar/.minetest/mods/toolranks/init.lua:30: attempt to concatenate local 'uses' (a nil value)
stack traceback:
/home/einar/.minetest/mods/toolranks/init.lua:30: in function 'create_description'
Someone can help me?

User avatar
lisacvuk
Member
Posts: 274
Joined: Sat Jul 19, 2014 11:52
GitHub: lisacvuk
IRC: lisac
In-game: lisacvuk
Location: Serbia, Užice

Re: [MOD] Tool ranks [toolranks]

by lisacvuk » Post

einarromero wrote:I had an issue, game said:

Code: Select all

/home/einar/.minetest/mods/toolranks/init.lua:30: attempt to concatenate local 'uses' (a nil value)
stack traceback:
/home/einar/.minetest/mods/toolranks/init.lua:30: in function 'create_description'
Someone can help me?
I don't see how could that happen. There is a check to prevent it.
1. What mods have you got enabled?
2. What is your MT version?
It's lisac, not lisa.
400 character limit? Am I writing a book?
Administrator on Craig's server. Minetest player.
"The enemy pales when they see the face of Dazzle!" ~ Dazzle obviously.
I live in Serbia.
Steam | OpenDOTA
My mods:
Tool ranks
I appreciate donations in TF2 items. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests