local enchanting = {}
screwdriver = screwdriver or {}
+-- Cost in Mese crystal(s) for enchanting.
+local mese_cost = 1
+
+-- Force of the enchantments.
+enchanting.uses = 1.2
+enchanting.times = 0.1
+enchanting.damages = 1
+enchanting.strength = 1.2
+enchanting.speed = 0.2
+enchanting.jump = 0.2
+
+-- Enchanted tools registration.
+enchanting.tools = {
+ --[[ Registration format:
+ [Mod name] = {
+ materials,
+ {tool name, tool group, enchantments}
+ }
+ --]]
+ ["default"] = {
+ "steel bronze mese diamond",
+ {"axe", "choppy", "durable, fast"},
+ {"pick", "cracky", "durable, fast"},
+ {"shovel", "crumbly", "durable, fast"},
+ {"sword", "fleshy", "sharp"}
+ },
+ ["3d_armor"] = {
+ "steel bronze gold diamond",
+ {"boots", nil, "strong, speed"},
+ {"chestplate", nil, "strong"},
+ {"helmet", nil, "strong"},
+ {"leggings", nil, "strong"}
+ }
+}
+
function enchanting.formspec(pos, num)
local formspec = [[ size[9,9;]
bgcolor[#080808BB;true]
local orig_wear = tool:get_wear()
local mod, name = tool:get_name():match("(.*):(.*)")
local enchanted_tool = mod..":enchanted_"..name.."_"..next(fields)
- local mese_cost = 1
if mese:get_count() >= mese_cost and minetest.registered_tools[enchanted_tool] then
tool:replace(enchanted_tool)
allow_metadata_inventory_move = function() return 0 end
})
-local function cap(str)
- return str:gsub("^%l", string.upper)
-end
-
- -- Higher number = stronger enchant.
-enchanting.uses = 1.2
-enchanting.times = 0.1
-enchanting.damages = 1
-enchanting.strength = 1.2
-enchanting.speed = 0.2
-enchanting.jump = 0.2
-
-local tools = {
- --[[ Registration format:
- [Mod name] = {
- materials,
- {tool name, tool group, enchantments}
- }
- --]]
- ["default"] = {
- "steel, bronze, mese, diamond",
- {"axe", "choppy", "durable, fast"},
- {"pick", "cracky", "durable, fast"},
- {"shovel", "crumbly", "durable, fast"},
- {"sword", "fleshy", "sharp"}
- },
- ["3d_armor"] = {
- "steel, bronze, gold, diamond",
- {"boots", nil, "strong, speed"},
- {"chestplate", nil, "strong"},
- {"helmet", nil, "strong"},
- {"leggings", nil, "strong"}
- }
-}
+local function cap(S) return S:gsub("^%l", string.upper) end
-for mod, defs in pairs(tools) do
+for mod, defs in pairs(enchanting.tools) do
for material in defs[1]:gmatch("[%w_]+") do
for _, tooldef in next, defs, 1 do
for enchant in tooldef[3]:gmatch("[%w_]+") do
local worktable = {}
screwdriver = screwdriver or {}
-local nodes = { -- Nodes allowed to be cut. Registration format: [mod name] = [[ node names ]].
+-- Nodes allowed to be cut. Registration format: [mod name] = [[ node names ]].
+worktable.nodes = {
["default"] = [[
wood tree cobble desert_stone
junglewood jungletree mossycobble stonebrick
]],
}
-local defs = {
+-- Nodeboxes definitions.
+worktable.defs = {
-- Name Yield X Y Z W H L
{"nanoslab", 16, { 0, 0, 0, 8, 1, 8 }},
{"micropanel", 16, { 0, 0, 0, 16, 1, 8 }},
return stack:get_count()
end
end
- if (listname == "input" and worktable.allowed(nodes[mod], node)) or
+ if (listname == "input" and worktable.allowed(worktable.nodes[mod], node)) or
(listname == "hammer" and stackname == "xdecor:hammer") or
listname == "storage" or listname == "trash" then
if listname == "trash" then trash_delete(pos) end
end
local output = {}
- for _, n in pairs(defs) do
+ for _, n in pairs(worktable.defs) do
local count = math.min(n[2] * input:get_count(), input:get_stack_max())
local item = name.."_"..n[1]
if not n[3] then item = "stairs:"..n[1].."_"..name:match(":(.*)") end
inv:set_list("forms", {})
end
elseif listname == "forms" then
- input:take_item(math.ceil(stack:get_count() / defs[index][2]))
+ input:take_item(math.ceil(stack:get_count() / worktable.defs[index][2]))
inv:set_stack("input", 1, input)
worktable.get_output(inv, input, input:get_name())
end
allow_metadata_inventory_move = worktable.move
})
-for _, d in pairs(defs) do
-for mod, n in pairs(nodes) do
+for _, d in pairs(worktable.defs) do
+for mod, n in pairs(worktable.nodes) do
for name in n:gmatch("[%w_]+") do
local ndef = minetest.registered_nodes[mod..":"..name]
if ndef and d[3] then
if not x[3] then
newnode = mod..":"..name
else
- newnode = mod..":"..name.."_"..defs[x[3]][1]
+ newnode = mod..":"..name.."_"..worktable.defs[x[3]][1]
end
end
end