Move and regroup enchanting params and registrations on top of page
This commit is contained in:
parent
e52ca85393
commit
8f8ba904c1
@ -1,6 +1,41 @@
|
|||||||
local enchanting = {}
|
local enchanting = {}
|
||||||
screwdriver = screwdriver or {}
|
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)
|
function enchanting.formspec(pos, num)
|
||||||
local formspec = [[ size[9,9;]
|
local formspec = [[ size[9,9;]
|
||||||
bgcolor[#080808BB;true]
|
bgcolor[#080808BB;true]
|
||||||
@ -48,7 +83,6 @@ function enchanting.fields(pos, _, fields)
|
|||||||
local orig_wear = tool:get_wear()
|
local orig_wear = tool:get_wear()
|
||||||
local mod, name = tool:get_name():match("(.*):(.*)")
|
local mod, name = tool:get_name():match("(.*):(.*)")
|
||||||
local enchanted_tool = mod..":enchanted_"..name.."_"..next(fields)
|
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
|
if mese:get_count() >= mese_cost and minetest.registered_tools[enchanted_tool] then
|
||||||
tool:replace(enchanted_tool)
|
tool:replace(enchanted_tool)
|
||||||
@ -116,42 +150,9 @@ xdecor.register("enchantment_table", {
|
|||||||
allow_metadata_inventory_move = function() return 0 end
|
allow_metadata_inventory_move = function() return 0 end
|
||||||
})
|
})
|
||||||
|
|
||||||
local function cap(str)
|
local function cap(S) return S:gsub("^%l", string.upper) end
|
||||||
return str:gsub("^%l", string.upper)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Higher number = stronger enchant.
|
for mod, defs in pairs(enchanting.tools) do
|
||||||
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"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for mod, defs in pairs(tools) do
|
|
||||||
for material in defs[1]:gmatch("[%w_]+") do
|
for material in defs[1]:gmatch("[%w_]+") do
|
||||||
for _, tooldef in next, defs, 1 do
|
for _, tooldef in next, defs, 1 do
|
||||||
for enchant in tooldef[3]:gmatch("[%w_]+") do
|
for enchant in tooldef[3]:gmatch("[%w_]+") do
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
local worktable = {}
|
local worktable = {}
|
||||||
screwdriver = screwdriver or {}
|
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"] = [[
|
["default"] = [[
|
||||||
wood tree cobble desert_stone
|
wood tree cobble desert_stone
|
||||||
junglewood jungletree mossycobble stonebrick
|
junglewood jungletree mossycobble stonebrick
|
||||||
@ -26,7 +27,8 @@ local nodes = { -- Nodes allowed to be cut. Registration format: [mod name] = [[
|
|||||||
]],
|
]],
|
||||||
}
|
}
|
||||||
|
|
||||||
local defs = {
|
-- Nodeboxes definitions.
|
||||||
|
worktable.defs = {
|
||||||
-- Name Yield X Y Z W H L
|
-- Name Yield X Y Z W H L
|
||||||
{"nanoslab", 16, { 0, 0, 0, 8, 1, 8 }},
|
{"nanoslab", 16, { 0, 0, 0, 8, 1, 8 }},
|
||||||
{"micropanel", 16, { 0, 0, 0, 16, 1, 8 }},
|
{"micropanel", 16, { 0, 0, 0, 16, 1, 8 }},
|
||||||
@ -305,7 +307,7 @@ function worktable.put(pos, listname, _, stack)
|
|||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
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 == "hammer" and stackname == "xdecor:hammer") or
|
||||||
listname == "storage" or listname == "trash" then
|
listname == "storage" or listname == "trash" then
|
||||||
if listname == "trash" then trash_delete(pos) end
|
if listname == "trash" then trash_delete(pos) end
|
||||||
@ -343,7 +345,7 @@ function worktable.get_output(inv, input, name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local output = {}
|
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 count = math.min(n[2] * input:get_count(), input:get_stack_max())
|
||||||
local item = name.."_"..n[1]
|
local item = name.."_"..n[1]
|
||||||
if not n[3] then item = "stairs:"..n[1].."_"..name:match(":(.*)") end
|
if not n[3] then item = "stairs:"..n[1].."_"..name:match(":(.*)") end
|
||||||
@ -373,7 +375,7 @@ function worktable.on_take(pos, listname, index, stack)
|
|||||||
inv:set_list("forms", {})
|
inv:set_list("forms", {})
|
||||||
end
|
end
|
||||||
elseif listname == "forms" then
|
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)
|
inv:set_stack("input", 1, input)
|
||||||
worktable.get_output(inv, input, input:get_name())
|
worktable.get_output(inv, input, input:get_name())
|
||||||
end
|
end
|
||||||
@ -399,8 +401,8 @@ xdecor.register("worktable", {
|
|||||||
allow_metadata_inventory_move = worktable.move
|
allow_metadata_inventory_move = worktable.move
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, d in pairs(defs) do
|
for _, d in pairs(worktable.defs) do
|
||||||
for mod, n in pairs(nodes) do
|
for mod, n in pairs(worktable.nodes) do
|
||||||
for name in n:gmatch("[%w_]+") do
|
for name in n:gmatch("[%w_]+") do
|
||||||
local ndef = minetest.registered_nodes[mod..":"..name]
|
local ndef = minetest.registered_nodes[mod..":"..name]
|
||||||
if ndef and d[3] then
|
if ndef and d[3] then
|
||||||
@ -472,7 +474,7 @@ for name in n:gmatch("[%w_]+") do
|
|||||||
if not x[3] then
|
if not x[3] then
|
||||||
newnode = mod..":"..name
|
newnode = mod..":"..name
|
||||||
else
|
else
|
||||||
newnode = mod..":"..name.."_"..defs[x[3]][1]
|
newnode = mod..":"..name.."_"..worktable.defs[x[3]][1]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user