forked from mtcontrib/minetest-toolranks
Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev
This commit is contained in:
commit
0d7bf5a5d6
@ -1,2 +1 @@
|
|||||||
default
|
default
|
||||||
moreores?
|
|
||||||
|
248
init.lua
248
init.lua
@ -1,4 +1,5 @@
|
|||||||
local mod_storage = minetest.get_mod_storage()
|
local mod_storage = minetest.get_mod_storage()
|
||||||
|
local S = minetest.get_translator("toolranks")
|
||||||
|
|
||||||
toolranks = {}
|
toolranks = {}
|
||||||
|
|
||||||
@ -12,16 +13,21 @@ toolranks.colors = {
|
|||||||
function toolranks.get_tool_type(description)
|
function toolranks.get_tool_type(description)
|
||||||
if not description then
|
if not description then
|
||||||
return "tool"
|
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
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -29,10 +35,14 @@ function toolranks.create_description(name, uses, level)
|
|||||||
local description = name
|
local description = name
|
||||||
local tooltype = toolranks.get_tool_type(description)
|
local tooltype = toolranks.get_tool_type(description)
|
||||||
|
|
||||||
local newdesc = toolranks.colors.green .. description .. "\n" ..
|
local newdesc = S("@1@2\n@3Level @4 @5\n@6@Node dug: @7",
|
||||||
toolranks.colors.gold .. "Level " .. (level or 1) .. " " .. tooltype .. "\n" ..
|
toolranks.colors.green,
|
||||||
toolranks.colors.grey .. "Nodes dug: " .. (uses or 0)
|
description,
|
||||||
|
toolranks.colors.gold,
|
||||||
|
(level or 1),
|
||||||
|
S(tooltype),
|
||||||
|
toolranks.colors.grey,
|
||||||
|
(uses or 0))
|
||||||
return newdesc
|
return newdesc
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -79,15 +89,18 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
|
|||||||
most_digs = dugnodes
|
most_digs = dugnodes
|
||||||
if(most_digs_user ~= user:get_player_name()) then -- Avoid spam.
|
if(most_digs_user ~= user:get_player_name()) then -- Avoid spam.
|
||||||
most_digs_user = user:get_player_name()
|
most_digs_user = user:get_player_name()
|
||||||
minetest.chat_send_all("Most used tool is now a " .. toolranks.colors.green .. itemdesc
|
minetest.chat_send_all(S("Most used tool is now a @1@2@3 owned by @4 with @5 uses.",
|
||||||
.. toolranks.colors.white .. " owned by " .. user:get_player_name()
|
toolranks.colors.green,
|
||||||
.. " with " .. dugnodes .. " uses.")
|
itemdesc,
|
||||||
|
toolranks.colors.white,
|
||||||
|
user:get_player_name(),
|
||||||
|
dugnodes))
|
||||||
end
|
end
|
||||||
mod_storage:set_int("most_digs", dugnodes)
|
mod_storage:set_int("most_digs", dugnodes)
|
||||||
mod_storage:set_string("most_digs_user", user:get_player_name())
|
mod_storage:set_string("most_digs_user", user:get_player_name())
|
||||||
end
|
end
|
||||||
if(itemstack:get_wear() > 60135) then
|
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", {
|
minetest.sound_play("default_tool_breaks", {
|
||||||
to_player = user:get_player_name(),
|
to_player = user:get_player_name(),
|
||||||
gain = 2.0,
|
gain = 2.0,
|
||||||
@ -96,9 +109,10 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
|
|||||||
local level = toolranks.get_level(dugnodes)
|
local level = toolranks.get_level(dugnodes)
|
||||||
|
|
||||||
if lastlevel < level then
|
if lastlevel < level then
|
||||||
local levelup_text = "Your " .. toolranks.colors.green ..
|
local levelup_text = S("Your @1@2@3 just leveled up!",
|
||||||
itemdesc .. toolranks.colors.white ..
|
toolranks.colors.green,
|
||||||
" just leveled up!"
|
itemdesc,
|
||||||
|
toolranks.colors.white)
|
||||||
minetest.sound_play("toolranks_levelup", {
|
minetest.sound_play("toolranks_levelup", {
|
||||||
to_player = user:get_player_name(),
|
to_player = user:get_player_name(),
|
||||||
gain = 2.0,
|
gain = 2.0,
|
||||||
@ -123,168 +137,46 @@ function toolranks.new_afteruse(itemstack, user, node, digparams)
|
|||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.override_item("default:pick_diamond", {
|
-- Helper function
|
||||||
original_description = "Diamond Pickaxe",
|
local function add_tool(name)
|
||||||
description = toolranks.create_description("Diamond Pickaxe", 0, 1),
|
local desc = ItemStack(name):get_definition().description
|
||||||
after_use = toolranks.new_afteruse})
|
minetest.override_item(name, {
|
||||||
|
original_description = desc,
|
||||||
minetest.override_item("default:axe_diamond", {
|
description = toolranks.create_description(desc, 0, 1),
|
||||||
original_description = "Diamond Axe",
|
after_use = toolranks.new_afteruse
|
||||||
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})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- add swords for snappy nodes
|
-- Sword
|
||||||
minetest.override_item("default:sword_wood", {
|
add_tool("default:sword_wood")
|
||||||
original_description = "Wooden Sword",
|
add_tool("default:sword_stone")
|
||||||
description = toolranks.create_description("Wooden Sword", 0, 1),
|
add_tool("default:sword_steel")
|
||||||
after_use = toolranks.new_afteruse})
|
add_tool("default:sword_bronze")
|
||||||
|
add_tool("default:sword_mese")
|
||||||
|
add_tool("default:sword_diamond")
|
||||||
|
|
||||||
minetest.override_item("default:sword_stone", {
|
-- Pickaxe
|
||||||
original_description = "Stone Sword",
|
add_tool("default:pick_wood")
|
||||||
description = toolranks.create_description("Stone Sword", 0, 1),
|
add_tool("default:pick_stone")
|
||||||
after_use = toolranks.new_afteruse})
|
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", {
|
-- Axe
|
||||||
original_description = "Steel Sword",
|
add_tool("default:axe_wood")
|
||||||
description = toolranks.create_description("Steel Sword", 0, 1),
|
add_tool("default:axe_stone")
|
||||||
after_use = toolranks.new_afteruse})
|
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", {
|
-- Shovel
|
||||||
original_description = "Bronze Sword",
|
add_tool("default:shovel_wood")
|
||||||
description = toolranks.create_description("Bronze Sword", 0, 1),
|
add_tool("default:shovel_stone")
|
||||||
after_use = toolranks.new_afteruse})
|
add_tool("default:shovel_steel")
|
||||||
|
add_tool("default:shovel_bronze")
|
||||||
minetest.override_item("default:sword_mese", {
|
add_tool("default:shovel_mese")
|
||||||
original_description = "Mese Sword",
|
add_tool("default:shovel_diamond")
|
||||||
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})
|
|
||||||
|
|
||||||
minetest.log("action", "[toolranks] loaded.")
|
minetest.log("action", "[toolranks] loaded.")
|
||||||
|
11
locale/toolranks.en.tr
Normal file
11
locale/toolranks.en.tr
Normal 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
11
locale/toolranks.fr.tr
Normal 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.=L’outil 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 !
|
Loading…
x
Reference in New Issue
Block a user