Merge branch 'master' of https://github.com/t4im/xdecor
This commit is contained in:
commit
d82f60a904
@ -90,52 +90,50 @@ xdecor.register("enchantment_table", {
|
|||||||
allow_metadata_inventory_move = function(...) return 0 end
|
allow_metadata_inventory_move = function(...) return 0 end
|
||||||
})
|
})
|
||||||
|
|
||||||
function enchanting.register_enchtools(init, m, def)
|
local function capitalize(str)
|
||||||
local longer = init.uses * 1.2 -- Higher number = longer use.
|
return str:gsub("^%l", string.upper)
|
||||||
local faster = {}
|
end
|
||||||
for i = 1, 3 do
|
|
||||||
faster[i] = init.times[i] - 0.1 -- Higher number = faster dig.
|
|
||||||
end
|
|
||||||
|
|
||||||
local fast = {times=faster, uses=def.uses, maxlevel=def.maxlvl}
|
-- Higher number = longer use.
|
||||||
local long = {times=def.times, uses=longer, maxlevel=def.maxlvl}
|
local use_factor = 1.2
|
||||||
|
-- Higher number = faster dig.
|
||||||
|
local times_subtractor = 0.1
|
||||||
|
|
||||||
local enchtools = {
|
function enchanting.register_enchtools()
|
||||||
{"axe", "durable", {choppy = long}}, {"axe", "fast", {choppy = fast}},
|
local materials = {"steel", "bronze", "mese", "diamond"}
|
||||||
{"pick", "durable", {cracky = long}}, {"pick", "fast", {cracky = fast}},
|
local tools = { {"axe", "choppy"}, {"pick", "cracky"}, {"shovel", "crumbly"} }
|
||||||
{"shovel", "durable", {crumbly = long}}, {"shovel", "fast", {crumbly = fast}}
|
local chants = { "durable", "fast" }
|
||||||
}
|
for j = 1, #materials do
|
||||||
for i = 1, #enchtools do
|
local material = materials[j]
|
||||||
local x = enchtools[i]
|
for t = 1, #tools do
|
||||||
local t, e, g = x[1], x[2], x[3]
|
local tool_name = tools[t][1]
|
||||||
minetest.register_tool("xdecor:enchanted_"..t.."_"..m.."_"..e, {
|
local original_tool = minetest.registered_tools["default:"..tool_name.."_"..material]
|
||||||
description = "Enchanted "..m:gsub("%l", string.upper, 1).." "..
|
local original_groupcaps = original_tool.tool_capabilities.groupcaps
|
||||||
t:gsub("%l", string.upper, 1).." ("..e:gsub("%l", string.upper, 1)..")",
|
local main_groupcap = tools[t][2]
|
||||||
inventory_image = minetest.registered_tools["default:"..t.."_"..m].inventory_image,
|
|
||||||
wield_image = minetest.registered_tools["default:"..t.."_"..m].wield_image,
|
for i = 1, #chants do
|
||||||
groups = {not_in_creative_inventory=1},
|
local chant = chants[i]
|
||||||
tool_capabilities = {groupcaps = g, damage_groups = def.dmg}
|
|
||||||
})
|
local groupcaps = table.copy(original_groupcaps)
|
||||||
|
if chant == "durable" then
|
||||||
|
groupcaps[main_groupcap].uses = original_groupcaps[main_groupcap].uses * use_factor
|
||||||
|
elseif chant == "fast" then
|
||||||
|
for i = 1, 3 do
|
||||||
|
groupcaps[main_groupcap].times[i] = original_groupcaps[main_groupcap].times[i] - times_subtractor
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_tool(string.format("xdecor:enchanted_%s_%s_%s", tool_name, material, chant), {
|
||||||
|
description = string.format("Enchanted %s %s (%s)", capitalize(material), capitalize(tool_name), capitalize(chant)),
|
||||||
|
inventory_image = original_tool.inventory_image,
|
||||||
|
wield_image = original_tool.wield_image,
|
||||||
|
groups = {not_in_creative_inventory=1},
|
||||||
|
tool_capabilities = {groupcaps = groupcaps, damage_groups = original_tool.damage_groups}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tools = {
|
enchanting.register_enchtools()
|
||||||
{"axe", "choppy"}, {"pick", "cracky"}, {"shovel", "crumbly"}
|
|
||||||
}
|
|
||||||
local materials = {"steel", "bronze", "mese", "diamond"}
|
|
||||||
|
|
||||||
for i = 1, #tools do
|
|
||||||
for j = 1, #materials do
|
|
||||||
local t, m = tools[i], materials[j]
|
|
||||||
local toolname = t[1].."_"..m
|
|
||||||
local init_def = minetest.registered_tools["default:"..toolname].tool_capabilities.groupcaps[t[2]]
|
|
||||||
|
|
||||||
local tooldef = {
|
|
||||||
times = init_def.times,
|
|
||||||
uses = init_def.uses,
|
|
||||||
dmg = init_def.damage_groups,
|
|
||||||
maxlvl = init_def.maxlevel
|
|
||||||
}
|
|
||||||
enchanting.register_enchtools(init_def, m, tooldef)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
Loading…
Reference in New Issue
Block a user