fix craftguide registration
This commit is contained in:
parent
d31a7d6050
commit
3e48788251
47
register.lua
47
register.lua
@ -230,19 +230,35 @@ local function _flatten(arr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("craftguide") ~= nil then
|
if minetest.get_modpath("craftguide") ~= nil then
|
||||||
|
local function construct_gridset(list)
|
||||||
|
local final = {}
|
||||||
|
for a,v in pairs(list) do
|
||||||
|
local height = math.ceil(a / 3)
|
||||||
|
if not final[height] then
|
||||||
|
if v == "" then v = "," end
|
||||||
|
final[height] = v
|
||||||
|
else
|
||||||
|
final[height] = final[height] .. "," .. v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return final
|
||||||
|
end
|
||||||
|
|
||||||
|
local function register_craftguide_recipe(type,output,items)
|
||||||
|
craftguide.register_craft({
|
||||||
|
type = type,
|
||||||
|
output = output,
|
||||||
|
items = construct_gridset(items),
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
craftguide.register_craft_type("arcane", {
|
craftguide.register_craft_type("arcane", {
|
||||||
description = "Arcane Crafting",
|
description = "Arcane Crafting",
|
||||||
icon = "magicalities_table_arcane_top.png",
|
icon = "magicalities_table_arcane_top.png",
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, recipe in pairs(recipes) do
|
for _, recipe in pairs(recipes) do
|
||||||
craftguide.register_craft({
|
register_craftguide_recipe("arcane", recipe.output, _flatten(recipe.input))
|
||||||
type = "arcane",
|
|
||||||
output = recipe.output,
|
|
||||||
width = 3,
|
|
||||||
height = 3,
|
|
||||||
items = _flatten(recipe.input),
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- How to make things with wand
|
-- How to make things with wand
|
||||||
@ -253,12 +269,7 @@ if minetest.get_modpath("craftguide") ~= nil then
|
|||||||
|
|
||||||
for g,v in pairs(magicalities.wands.transform_recipes) do
|
for g,v in pairs(magicalities.wands.transform_recipes) do
|
||||||
if v.result and type(v.result) == "string" then
|
if v.result and type(v.result) == "string" then
|
||||||
craftguide.register_craft({
|
register_craftguide_recipe("wand", v.result, {g})
|
||||||
type = "wand",
|
|
||||||
output = v.result,
|
|
||||||
width = 1,
|
|
||||||
items = {g},
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -269,14 +280,6 @@ if minetest.get_modpath("craftguide") ~= nil then
|
|||||||
})
|
})
|
||||||
|
|
||||||
for g,v in pairs(magicalities.cauldron.recipes) do
|
for g,v in pairs(magicalities.cauldron.recipes) do
|
||||||
local height = math.ceil(#v.items / 3)
|
register_craftguide_recipe("cauldron", v.output, v.items)
|
||||||
local width = math.floor(#v.items % 3)
|
|
||||||
craftguide.register_craft({
|
|
||||||
type = "cauldron",
|
|
||||||
output = v.output,
|
|
||||||
height = height,
|
|
||||||
width = width,
|
|
||||||
items = v.items,
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -133,7 +133,7 @@ function magicalities.wands.update_wand_desc(stack)
|
|||||||
local str = "["..amount.."/"..capcontents.."] "
|
local str = "["..amount.."/"..capcontents.."] "
|
||||||
str = str .. minetest.colorize(dataelem.color, dataelem.description)
|
str = str .. minetest.colorize(dataelem.color, dataelem.description)
|
||||||
if focus and fdef and fdef['_wand_requirements'] and fdef['_wand_requirements'][elem] ~= nil then
|
if focus and fdef and fdef['_wand_requirements'] and fdef['_wand_requirements'][elem] ~= nil then
|
||||||
str = str .. minetest.colorize("#5716ad", " ("..fdef['_wand_requirements'][elem]..") ")
|
str = str .. minetest.colorize("#a070e0", " ("..fdef['_wand_requirements'][elem]..") ")
|
||||||
end
|
end
|
||||||
elems[#elems + 1] = str
|
elems[#elems + 1] = str
|
||||||
end
|
end
|
||||||
@ -144,7 +144,7 @@ function magicalities.wands.update_wand_desc(stack)
|
|||||||
focusstr = fdef.description
|
focusstr = fdef.description
|
||||||
end
|
end
|
||||||
|
|
||||||
strbld = strbld .. minetest.colorize("#5716ad", focusstr) .. "\n"
|
strbld = strbld .. minetest.colorize("#a070e0", focusstr) .. "\n"
|
||||||
if #elems > 0 then
|
if #elems > 0 then
|
||||||
table.sort(elems)
|
table.sort(elems)
|
||||||
strbld = strbld .. "\n" .. table.concat(elems, "\n")
|
strbld = strbld .. "\n" .. table.concat(elems, "\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user