Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev

This commit is contained in:
Sys Quatre 2020-02-29 18:36:06 +01:00
commit 0d7bf5a5d6
5 changed files with 93 additions and 179 deletions

View File

@ -1,2 +1 @@
default
moreores?

248
init.lua
View File

@ -1,4 +1,5 @@
local mod_storage = minetest.get_mod_storage()
local S = minetest.get_translator("toolranks")
toolranks = {}
@ -12,16 +13,21 @@ toolranks.colors = {
function toolranks.get_tool_type(description)
if not description then
return "tool"
elseif string.find(description, "Pickaxe") then
return "pickaxe"
elseif string.find(description, "Axe") then
return "axe"
elseif string.find(description, "Shovel") then
return "shovel"
elseif string.find(description, "Hoe") then
return "hoe"
else
return "tool"
local d = string.lower(description)
if string.find(d, "pickaxe") then
return "pickaxe"
elseif string.find(d, "axe") then
return "axe"
elseif string.find(d, "shovel") then
return "shovel"
elseif string.find(d, "hoe") then
return "hoe"
elseif string.find(d, "sword") then
return "sword"
else
return "tool"
end
end
end
@ -29,10 +35,14 @@ function toolranks.create_description(name, uses, level)
local description = name
local tooltype = toolranks.get_tool_type(description)
local newdesc = toolranks.colors.green .. description .. "\n" ..
toolranks.colors.gold .. "Level " .. (level or 1) .. " " .. tooltype .. "\n" ..
toolranks.colors.grey .. "Nodes dug: " .. (uses or 0)
local newdesc = S("@1@2\n@3Level @4 @5\n@6@Node dug: @7",
toolranks.colors.green,
description,
toolranks.colors.gold,
(level or 1),
S(tooltype),
toolranks.colors.grey,
(uses or 0))
return newdesc
end
@ -79,15 +89,18 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
most_digs = dugnodes
if(most_digs_user ~= user:get_player_name()) then -- Avoid spam.
most_digs_user = user:get_player_name()
minetest.chat_send_all("Most used tool is now a " .. toolranks.colors.green .. itemdesc
.. toolranks.colors.white .. " owned by " .. user:get_player_name()
.. " with " .. dugnodes .. " uses.")
minetest.chat_send_all(S("Most used tool is now a @1@2@3 owned by @4 with @5 uses.",
toolranks.colors.green,
itemdesc,
toolranks.colors.white,
user:get_player_name(),
dugnodes))
end
mod_storage:set_int("most_digs", dugnodes)
mod_storage:set_string("most_digs_user", user:get_player_name())
end
if(itemstack:get_wear() > 60135) then
minetest.chat_send_player(user:get_player_name(), "Your tool is about to break!")
minetest.chat_send_player(user:get_player_name(), S("Your tool is about to break!"))
minetest.sound_play("default_tool_breaks", {
to_player = user:get_player_name(),
gain = 2.0,
@ -96,9 +109,10 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
local level = toolranks.get_level(dugnodes)
if lastlevel < level then
local levelup_text = "Your " .. toolranks.colors.green ..
itemdesc .. toolranks.colors.white ..
" just leveled up!"
local levelup_text = S("Your @1@2@3 just leveled up!",
toolranks.colors.green,
itemdesc,
toolranks.colors.white)
minetest.sound_play("toolranks_levelup", {
to_player = user:get_player_name(),
gain = 2.0,
@ -123,168 +137,46 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
return itemstack
end
minetest.override_item("default:pick_diamond", {
original_description = "Diamond Pickaxe",
description = toolranks.create_description("Diamond Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:axe_diamond", {
original_description = "Diamond Axe",
description = toolranks.create_description("Diamond Axe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:shovel_diamond", {
original_description = "Diamond Shovel",
description = toolranks.create_description("Diamond Shovel", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:pick_wood", {
original_description = "Wooden Pickaxe",
description = toolranks.create_description("Wooden Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:axe_wood", {
original_description = "Wooden Axe",
description = toolranks.create_description("Wooden Axe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:shovel_wood", {
original_description = "Wooden Shovel",
description = toolranks.create_description("Wooden Shovel", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:pick_steel", {
original_description = "Steel Pickaxe",
description = toolranks.create_description("Steel Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:axe_steel", {
original_description = "Steel Axe",
description = toolranks.create_description("Steel Axe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:shovel_steel", {
original_description = "Steel Shovel",
description = toolranks.create_description("Steel Shovel", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:pick_stone", {
original_description = "Stone Pickaxe",
description = toolranks.create_description("Stone Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:axe_stone", {
original_description = "Stone Axe",
description = toolranks.create_description("Stone Axe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:shovel_stone", {
original_description = "Stone Shovel",
description = toolranks.create_description("Stone Shovel", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:pick_bronze", {
original_description = "Bronze Pickaxe",
description = toolranks.create_description("Bronze Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:axe_bronze", {
original_description = "Bronze Axe",
description = toolranks.create_description("Bronze Axe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:shovel_bronze", {
original_description = "Bronze Shovel",
description = toolranks.create_description("Bronze Shovel", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:pick_mese", {
original_description = "Mese Pickaxe",
description = toolranks.create_description("Mese Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:axe_mese", {
original_description = "Mese Axe",
description = toolranks.create_description("Mese Axe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:shovel_mese", {
original_description = "Mese Shovel",
description = toolranks.create_description("Mese Shovel", 0, 1),
after_use = toolranks.new_afteruse})
if minetest.get_modpath("moreores") then
minetest.override_item("moreores:pick_mithril", {
original_description = "Mithril Pickaxe",
description = toolranks.create_description("Mithril Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("moreores:axe_mithril", {
original_description = "Mithril Axe",
description = toolranks.create_description("Mithril Axe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("moreores:shovel_mithril", {
original_description = "Mithril Shovel",
description = toolranks.create_description("Mithril Shovel", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("moreores:sword_mithril", {
original_description = "Mithril Sword",
description = toolranks.create_description("Mithril Sword", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("moreores:pick_silver", {
original_description = "Silver Pickaxe",
description = toolranks.create_description("Silver Pickaxe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("moreores:axe_silver", {
original_description = "Silver Axe",
description = toolranks.create_description("Silver Axe", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("moreores:shovel_silver", {
original_description = "Silver Shovel",
description = toolranks.create_description("Silver Shovel", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("moreores:sword_silver", {
original_description = "Silver Sword",
description = toolranks.create_description("Silver Sword", 0, 1),
after_use = toolranks.new_afteruse})
-- Helper function
local function add_tool(name)
local desc = ItemStack(name):get_definition().description
minetest.override_item(name, {
original_description = desc,
description = toolranks.create_description(desc, 0, 1),
after_use = toolranks.new_afteruse
})
end
-- add swords for snappy nodes
minetest.override_item("default:sword_wood", {
original_description = "Wooden Sword",
description = toolranks.create_description("Wooden Sword", 0, 1),
after_use = toolranks.new_afteruse})
-- Sword
add_tool("default:sword_wood")
add_tool("default:sword_stone")
add_tool("default:sword_steel")
add_tool("default:sword_bronze")
add_tool("default:sword_mese")
add_tool("default:sword_diamond")
minetest.override_item("default:sword_stone", {
original_description = "Stone Sword",
description = toolranks.create_description("Stone Sword", 0, 1),
after_use = toolranks.new_afteruse})
-- Pickaxe
add_tool("default:pick_wood")
add_tool("default:pick_stone")
add_tool("default:pick_steel")
add_tool("default:pick_bronze")
add_tool("default:pick_mese")
add_tool("default:pick_diamond")
minetest.override_item("default:sword_steel", {
original_description = "Steel Sword",
description = toolranks.create_description("Steel Sword", 0, 1),
after_use = toolranks.new_afteruse})
-- Axe
add_tool("default:axe_wood")
add_tool("default:axe_stone")
add_tool("default:axe_steel")
add_tool("default:axe_bronze")
add_tool("default:axe_mese")
add_tool("default:axe_diamond")
minetest.override_item("default:sword_bronze", {
original_description = "Bronze Sword",
description = toolranks.create_description("Bronze Sword", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:sword_mese", {
original_description = "Mese Sword",
description = toolranks.create_description("Mese Sword", 0, 1),
after_use = toolranks.new_afteruse})
minetest.override_item("default:sword_diamond", {
original_description = "Diamond Sword",
description = toolranks.create_description("Diamond Sword", 0, 1),
after_use = toolranks.new_afteruse})
-- Shovel
add_tool("default:shovel_wood")
add_tool("default:shovel_stone")
add_tool("default:shovel_steel")
add_tool("default:shovel_bronze")
add_tool("default:shovel_mese")
add_tool("default:shovel_diamond")
minetest.log("action", "[toolranks] loaded.")

11
locale/toolranks.en.tr Normal file
View File

@ -0,0 +1,11 @@
# textdomain: toolranks
@1@2@n@3Level @4 @5@n@6Node dug: @7=@1@2@n@3Level @4 @5@n@6Node dug: @7
pickaxe=pickaxe
axe=axe
shovel=shovel
hoe=hoe
sword=sword
tool=tool
Most used tool is now a @1@2@3 owned by @4 with @5 uses.=Most used tool is now a @1@2@3 owned by @4 with @5 uses.
Your tool is about to break!=Your tool is about to break!
Your @1@2@3 just leveled up!=Your @1@2@3 just leveled up!

11
locale/toolranks.fr.tr Normal file
View File

@ -0,0 +1,11 @@
# textdomain: toolranks
@1@2@n@3Level @4 @5@n@6Node dug: @7=@1@2@n@3@5 niveau @4@n@6Blocks minés : @7
pickaxe=pioche
axe=hache
shovel=pelle
hoe=houe
sword=épée
tool=outil
Most used tool is now a @1@2@3 owned by @4 with @5 uses.=Loutil le plus utilisé est désormais @1@2@3 appartenant à @4 avec @5 utilisations.
Your tool is about to break!=Votre outil va se casser !
Your @1@2@3 just leveled up!=Votre @1@2@3 a gagné un niveau !

View File

@ -1 +1,2 @@
name = toolranks
depends = default