V1.3 Tool and Armor refined

Tools and Armor will repair anywhere in the player's inventory except
the crafting grid.

  Renewable Plant Fiber is now the only level needed to being producing
resources.

  Added support for one of my other mods Item Replicators (You can now
use it to replicate the Renewable Plant Fiber)

  Further refinement of the MCL tools so they don't depend on
_mcl_autogroups just for the times it takes for the tool to mine things.
(Typically found to be 8)
master
david 2021-09-08 18:36:50 -04:00
parent ee2c4cb0b3
commit 2cd9e703c2
9 changed files with 91 additions and 44 deletions

View File

@ -9,20 +9,20 @@ renew_armor.da_armor = minetest.get_modpath("3d_armor") or nil
-- The direct durability for the armors
renew_armor.uses = 365
renew_armor.heal = 2
renew_armor.heal = 3 -- 2
-- The amount repaired per global step
renew_armor.factor = 36
renew_armor.factor = 42 -- 36
-- Do we log that we did something? (Specifically used for debug
renew_armor.log = true
renew_armor.log = false
-- Only support repairing armor when the player is wearing it
local function check_player(player, timer)
if renew_armor.mtg and renew_armor.da_armor then
local _, armor_inv = armor.get_valid_player(armor, player, "[renew_armor]")
-- Checking for armors in 3d_armor slots
local _, armor_inv = armor.get_valid_player(armor, player, "[renew_armor]")
if not armor_inv then return end
for i, stack in pairs(armor_inv:get_list("armor")) do
if not stack:is_empty() then
local name = stack:get_name()
@ -36,7 +36,24 @@ local function check_player(player, timer)
end
end
end
-- Checking for armors in the main inventory
local inv = minetest.get_inventory({type="player", name=player:get_player_name()})
for i, stack in pairs(inv:get_list("main")) do
if not stack:is_empty() then
local name = stack:get_name()
if name:sub(1,11) == "renew_armor" then
if stack:get_wear() ~= 0 then
stack:add_wear( -renew_armor.factor )
inv:set_stack("main", i, stack)
if renew_armor.log == true then
minetest.log("action", "[renew_armor] inv ["..i.."] "..stack:get_wear())
end
end
end
end
end
elseif renew_armor.mcl then
-- Checking for armors in the MCL armor slots
local inv = minetest.get_inventory({type="player", name=player:get_player_name()})
for i, stack in pairs(inv:get_list("armor")) do
if not stack:is_empty() then
@ -52,6 +69,22 @@ local function check_player(player, timer)
end
end
end
-- Checking for armors in the main inventory
local inv = minetest.get_inventory({type="player", name=player:get_player_name()})
for i, stack in pairs(inv:get_list("main")) do
if not stack:is_empty() then
local name = stack:get_name()
if name:sub(1,11) == "renew_armor" then
if stack:get_wear() ~= 0 then
stack:add_wear( -renew_armor.factor )
inv:set_stack("main", i, stack)
if renew_armor.log == true then
minetest.log("action", "[renew_armor] mcl, inv ["..i.."] "..stack:get_wear())
end
end
end
end
end
end
end
@ -62,7 +95,7 @@ elseif renew_armor.mcl then
minetest.log("action", "[renew_armor] Detected MCL")
dofile(renew_armor.modpath.."/mcl_support.lua")
else
error("Expected MTG with 3d_armor or MineClone2")
error("Expected MTG with 3d_armor or MineClone")
end
local timer = 0

View File

@ -1,6 +1,10 @@
local mcl_armor = armor
local mat = "renew_plant:plant_tri"
local mcl_armor = rawget(_G, "mcl_armor") or nil
if mcl_armor == nil then
error("[renew_armor] Failed to obtain MCL armor")
end
local mat = "renew_plant:plant"
local points = {
head = 3,
torso = 8,
@ -13,7 +17,7 @@ renewal.usage = renew_armor.S("")
minetest.register_tool("renew_armor:helmet", {
description = renew_armor.S("Renewable Helmet"),
_doc_items_longdesc = renew_armor.S("A self-repairing peice of armor"),
_doc_items_usagehelp = armor.usage,
_doc_items_usagehelp = mcl_armor.usage,
inventory_image = "renew_armor_inv_helmet.png",
groups = {armor_head = 1, combat_armor_head = 1, armor = 1, combat_armor = 1, mcl_armor_points = points.head, mcl_armor_toughness = 2, mcl_armor_uses=renew_armor.uses, enchantablility = 20},
sounds = {

View File

@ -31,7 +31,7 @@ armor:register_armor(":renew_armor:boots", {
damage_groups = {cracky=2, snappy=1, choppy=1, level=3}
})
local mat = "renew_plant:plant_tri"
local mat = "renew_plant:plant"
minetest.register_craft({
output = "renew_armor:helmet",

View File

@ -34,3 +34,8 @@ minetest.register_craft({
p1
}
})
local i_repl = rawget(_G, "item_replicator") or nil
if i_repl ~= nil then
i_repl.add(p1, 1, 34)
end

View File

@ -1,2 +1,3 @@
name = renew_plant
description = Provides the material used in renew_tools and renew_armor
description = Provides the material used in renew_tools and renew_armor
optional_depends = item_replicator

View File

@ -10,10 +10,10 @@ renew_tools.mcl = minetest.get_modpath("mcl_core") or nil
renew_tools.uses = 365
-- The amount repaired per global step
renew_tools.factor = 36
renew_tools.factor = 42 -- 36
-- Do we log when we repair? Used for debugging
renew_tools.log = false
renew_tools.log = true
-- Only support repairing tools when they are in the main inventory of the player
local function check_player(player, timer)
@ -41,7 +41,7 @@ elseif renew_tools.mcl then
minetest.log("action", "[renew_tools] Detected MCL")
dofile(renew_tools.modpath.."/mcl_support.lua")
else
error("Expected either MTG or MineClone2")
error("Expected either MTG or MineClone")
end
local timer = 0

View File

@ -1,3 +1,7 @@
-- Because MCL2 and MCL5 != the same system of indicating what can mine what. :(
local auto_group = 8
-- Assistant functions that really should have been placed into an API (Thus I have to lug it around)
local make_grass_path = function(itemstack, placer, pointed_thing)
-- Use pointed node's on_rightclick function first, if present
@ -152,22 +156,20 @@ end
minetest.register_tool("renew_tools:pick", {
description = renew_tools.S("Renewable Pickaxe"),
inventory_image = "renew_tools_pick.png",
groups = { tool=1, pickaxe=1, dig_speed_class=5, enchantability=10 },
groups = { tool=1, pickaxe=1, dig_speed_class=6, enchantability=10 },
tool_capabilities = {
-- 1/1.2
full_punch_interval = 0.83333333,
max_drop_level=5,
damage_groups = {fleshy=5},
damage_groups = {fleshy=6},
punch_attack_uses=renew_tools.uses,
groupcaps={
pickaxey_dig_diamond = {times=mcl_autogroup.digtimes.pickaxey_dig_diamond, uses=renew_tools.uses, maxlevel=0},
},
groupcaps = {
pickaxey_dig_diamond = {times = auto_group, uses=renew_tools.uses, maxlevel=0}
}
},
sound = { breaks = "default_tool_breaks" },
-- _repair_material = "mcl_core:diamond",
_mcl_toollike_wield = true,
_mcl_diggroups = {
pickaxey = { speed = 8, level = 5, uses=renew_tools.uses }
pickaxey = { speed = 9.5, level = 6, uses=renew_tools.uses }
},
})
@ -175,21 +177,21 @@ minetest.register_tool("renew_tools:pick", {
minetest.register_tool("renew_tools:shovel", {
description = renew_tools.S("Renewable Shovel"),
inventory_image = "renew_tools_shovel.png",
groups = { tool=1, shovel=1, dig_speed_class=5, enchantability=10 },
groups = { tool=1, shovel=1, dig_speed_class=6, enchantability=10 },
tool_capabilities = {
full_punch_interval = 1,
max_drop_level=5,
groupcaps={
shovely_dig_diamond = {times=mcl_autogroup.digtimes.shovely_dig_diamond, uses=renew_tools.uses, maxlevel=0},
},
damage_groups = {fleshy=5},
punch_attack_uses=renew_tools.uses,
groupcaps = {
shovely_dig_diamond = {times = auto_group, uses=renew_tools.uses, maxlevel=0}
}
},
on_place = make_grass_path,
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
shovely = { speed = 8, level = 5, uses=renew_tools.uses }
shovely = { speed = 9, level = 6, uses=renew_tools.uses }
},
})
@ -197,21 +199,21 @@ minetest.register_tool("renew_tools:shovel", {
minetest.register_tool("renew_tools:axe", {
description = renew_tools.S("Renewable Axe"),
inventory_image = "renew_tools_axe.png",
groups = { tool=1, axe=1, dig_speed_class=5, enchantability=10 },
groups = { tool=1, axe=1, dig_speed_class=6, enchantability=10 },
tool_capabilities = {
full_punch_interval = 1.0,
max_drop_level=5,
groupcaps={
axey_dig_diamond = {times=mcl_autogroup.digtimes.axey_dig_diamond, uses=renew_tools.uses, maxlevel=0},
},
damage_groups = {fleshy=9},
damage_groups = {fleshy=10},
punch_attack_uses=renew_tools.uses,
groupcaps = {
axey_dig_diamond = {times = auto_group, uses=renew_tools.uses, maxlevel=0}
}
},
on_place = make_stripped_trunk,
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
_mcl_diggroups = {
axey = { speed = 8, level = 5, uses=renew_tools.uses }
axey = { speed = 9, level = 6, uses=renew_tools.uses }
},
})
@ -223,12 +225,12 @@ minetest.register_tool("renew_tools:sword", {
tool_capabilities = {
full_punch_interval = 0.625,
max_drop_level=5,
groupcaps={
swordy_dig = {times=mcl_autogroup.digtimes.swordy_dig , uses=renew_tools.uses, maxlevel=0},
swordy_cobweb_dig = {times=mcl_autogroup.digtimes.swordy_cobweb_dig , uses=renew_tools.uses, maxlevel=0},
},
damage_groups = {fleshy=7},
damage_groups = {fleshy=9},
punch_attack_uses=renew_tools.uses,
groupcaps = {
swordy_dig = {times = 1.5, uses=renew_tools.uses, maxlevel=0},
swordy_cobweb_dig = {times = 14, uses=renew_tools.uses, maxlevel=0}
}
},
sound = { breaks = "default_tool_breaks" },
_mcl_toollike_wield = true,
@ -256,7 +258,7 @@ minetest.register_tool("renew_tools:hoe", {
},
})
local mat = "renew_plant:plant_tri"
local mat = "renew_plant:plant"
local stk = "group:stick"
minetest.register_craft({

View File

@ -1,4 +1,4 @@
name = renew_tools
description = Self-Repairing tools
depends = renew_plant
optional_depends = default, mcl_core, mcl_farming, farming, _mcl_autogroup
optional_depends = default, mcl_core, mcl_farming, farming

View File

@ -63,7 +63,7 @@ minetest.register_tool("renew_tools:sword", {
groups = {sword = 1}
})
local mat = "renew_plant:plant_tri"
local mat = "renew_plant:plant"
local stk = "group:stick"
minetest.register_craft({
@ -103,13 +103,15 @@ minetest.register_craft({
})
-- Hoe
if minetest.get_modpath("farming") or nil then
local farming = rawget(_G, "farming") or nil
local farming = rawget(_G, "farming") or nil
if farming ~= nil then
farming.register_hoe(":renew_tools:hoe", {
description = renew_tools.S("Renewable Hoe"),
inventory_image = "renew_tools_hoe.png",
max_uses=renew_tools.uses,
material = "renew_tools:renew_plant",
material = mat,
groups = {hoe = 1}
})
else
minetest.log("action", "[renew_tools] MTG farming mod not found? (No Hoe for you)")
end