better math and usage check change

master
TenPlus1 2019-05-22 20:57:09 +01:00
parent 42260bf4f4
commit 38f9c14342
3 changed files with 36 additions and 12 deletions

View File

@ -1,6 +1,9 @@
# minetest-toolranks
Minetest tool ranks mod
## Original mod by lisacvuk
https://github.com/lisacvuk/minetest-toolranks
Tool gains levels for digging nodes. Higher level tools take longer to
wear out.

View File

@ -19,18 +19,18 @@ end
function toolranks.get_level(uses)
if uses < 200 then
return 1
elseif uses < 400 then
return 2
elseif uses < 1000 then
return 3
elseif uses < 2000 then
return 4
elseif uses < 3200 then
return 5
else
if uses >= 3200 then
return 6
elseif uses >= 2000 then
return 5
elseif uses >= 1000 then
return 4
elseif uses >= 400 then
return 3
elseif uses >= 200 then
return 2
else
return 1
end
end
@ -94,7 +94,7 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
-- Set wear level
if level > 1 then
wear = digparams.wear / (1 + level / 4)
wear = digparams.wear * 4 / (4 + level)
end
itemstack:add_wear(wear)

21
license.txt Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2018
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.