Move enchant registrations to separate file
This commit is contained in:
parent
c81ed3725d
commit
2a2cfa4113
6
init.lua
6
init.lua
@ -21,8 +21,12 @@ local subpart = {
|
||||
"mailbox",
|
||||
"mechanisms",
|
||||
"rope",
|
||||
-- Workbench MUST be loaded last for the default 'cut node' registrations to work
|
||||
-- Workbench MUST be loaded after all other subparts that register nodes
|
||||
-- last for the default 'cut node' registrations to work
|
||||
"workbench",
|
||||
-- Enchanted tools registered last because they depend on previous
|
||||
-- subparts
|
||||
"enchanted_tools",
|
||||
}
|
||||
|
||||
for _, name in ipairs(subpart) do
|
||||
|
50
src/enchanted_tools.lua
Normal file
50
src/enchanted_tools.lua
Normal file
@ -0,0 +1,50 @@
|
||||
-- Register enchanted tools.
|
||||
|
||||
-- Number of uses for the (normal) steel hoe from Minetest Game (as of 01/12/20224)
|
||||
-- This is technically redundant because we cannot access that number
|
||||
-- directly, but it's unlikely to change in future because Minetest Game is
|
||||
-- unlikely to change.
|
||||
local STEEL_HOE_USES = 500
|
||||
|
||||
-- Modifier of the steel hoe uses for the enchanted steel hoe
|
||||
local STEEL_HOE_USES_MODIFIER = 3
|
||||
|
||||
-- Register enchantments for default tools from Minetest Game
|
||||
local materials = {"steel", "bronze", "mese", "diamond"}
|
||||
local tooltypes = {
|
||||
{ "axe", { "durable", "fast" }, "choppy" },
|
||||
{ "pick", { "durable", "fast" }, "cracky" },
|
||||
{ "shovel", { "durable", "fast" }, "crumbly" },
|
||||
{ "sword", { "sharp" }, nil },
|
||||
}
|
||||
for t=1, #tooltypes do
|
||||
for m=1, #materials do
|
||||
local tooltype = tooltypes[t][1]
|
||||
local enchants = tooltypes[t][2]
|
||||
local dig_group = tooltypes[t][3]
|
||||
local material = materials[m]
|
||||
xdecor.register_enchantable_tool("default:"..tooltype.."_"..material, {
|
||||
enchants = enchants,
|
||||
dig_group = dig_group,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Register enchanted steel hoe (more durability)
|
||||
if farming.register_hoe then
|
||||
local percent = math.round((STEEL_HOE_USES_MODIFIER - 1) * 100)
|
||||
local hitem = ItemStack("farming:hoe_steel")
|
||||
local hdesc = hitem:get_short_description() or "farming:hoe_steel"
|
||||
local ehdesc, ehsdesc = xdecor.enchant_description(hdesc, "durable", percent)
|
||||
farming.register_hoe(":farming:enchanted_hoe_steel_durable", {
|
||||
description = ehdesc,
|
||||
short_description = ehsdesc,
|
||||
inventory_image = xdecor.enchant_texture("farming_tool_steelhoe.png"),
|
||||
max_uses = STEEL_HOE_USES * STEEL_HOE_USES_MODIFIER,
|
||||
groups = {hoe = 1, not_in_creative_inventory = 1}
|
||||
})
|
||||
|
||||
xdecor.register_custom_enchantable_tool("farming:hoe_steel", {
|
||||
durable = "farming:enchanted_hoe_steel_durable",
|
||||
})
|
||||
end
|
@ -17,15 +17,6 @@ local DEFAULT_ENCHANTING_USES = 1.2 -- Durability
|
||||
local DEFAULT_ENCHANTING_TIMES = 0.1 -- Efficiency
|
||||
local DEFAULT_ENCHANTING_DAMAGES = 1 -- Sharpness
|
||||
|
||||
-- Number of uses for the (normal) steel hoe from Minetest Game (as of 01/12/20224)
|
||||
-- This is technically redundant because we cannot access that number
|
||||
-- directly, but it's unlikely to change in future because Minetest Game is
|
||||
-- unlikely to change.
|
||||
local STEEL_HOE_USES = 500
|
||||
|
||||
-- Modifier of the steel hoe uses for the enchanted steel hoe
|
||||
local STEEL_HOE_USES_MODIFIER = 3
|
||||
|
||||
local function to_percent(orig_value, final_value)
|
||||
return abs(ceil(((final_value - orig_value) / orig_value) * 100))
|
||||
end
|
||||
@ -492,45 +483,3 @@ xdecor.enchant_description = function(description, enchant, percent)
|
||||
return desc, short_desc
|
||||
end
|
||||
|
||||
|
||||
--[[ END OF API ]]
|
||||
|
||||
-- Register enchantments for default tools from Minetest Game
|
||||
local materials = {"steel", "bronze", "mese", "diamond"}
|
||||
local tooltypes = {
|
||||
{ "axe", { "durable", "fast" }, "choppy" },
|
||||
{ "pick", { "durable", "fast" }, "cracky" },
|
||||
{ "shovel", { "durable", "fast" }, "crumbly" },
|
||||
{ "sword", { "sharp" }, nil },
|
||||
}
|
||||
for t=1, #tooltypes do
|
||||
for m=1, #materials do
|
||||
local tooltype = tooltypes[t][1]
|
||||
local enchants = tooltypes[t][2]
|
||||
local dig_group = tooltypes[t][3]
|
||||
local material = materials[m]
|
||||
enchanting:register_tool("default:"..tooltype.."_"..material, {
|
||||
enchants = enchants,
|
||||
dig_group = dig_group,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
-- Register enchanted steel hoe (more durability)
|
||||
if farming.register_hoe then
|
||||
local percent = math.round((STEEL_HOE_USES_MODIFIER - 1) * 100)
|
||||
local hitem = ItemStack("farming:hoe_steel")
|
||||
local hdesc = hitem:get_short_description() or "farming:hoe_steel"
|
||||
local ehdesc, ehsdesc = xdecor.enchant_description(hdesc, "durable", percent)
|
||||
farming.register_hoe(":farming:enchanted_hoe_steel_durable", {
|
||||
description = ehdesc,
|
||||
short_description = ehsdesc,
|
||||
inventory_image = enchanting:enchant_texture("farming_tool_steelhoe.png"),
|
||||
max_uses = STEEL_HOE_USES * STEEL_HOE_USES_MODIFIER,
|
||||
groups = {hoe = 1, not_in_creative_inventory = 1}
|
||||
})
|
||||
|
||||
enchanting:register_custom_tool("farming:hoe_steel", {
|
||||
durable = "farming:enchanted_hoe_steel_durable",
|
||||
})
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user