1
0
Fork 0

Add banner emblazoning recipes (WIP)

This commit is contained in:
Wuzzy 2017-07-28 17:23:13 +02:00
parent ba224104c8
commit 423196d65c
2 changed files with 244 additions and 106 deletions

View File

@ -9,24 +9,26 @@ local function round(num, idp)
return math.floor(num * mult + 0.5) / mult return math.floor(num * mult + 0.5) / mult
end end
local colors = { mcl_banners = {}
-- ID, description, wool, unified dyes color group, overlay color,
["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF" }, mcl_banners.colors = {
["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030" }, -- ID, description, wool, unified dyes color group, overlay color, dye
["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B" }, ["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF", "mcl_dye:white" },
["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000" }, ["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030", "mcl_dye:dark_grey" },
["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000" }, ["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B", "mcl_dye:grey" },
["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800" }, ["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000", "mcl_dye:black" },
["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000" }, ["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000", "mcl_dye:red" },
["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC" }, ["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800", "mcl_dye:yellow" },
["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC" }, ["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000", "mcl_dye:dark_green" },
["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C" }, ["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC", "mcl_dye:cyan" },
["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900" }, ["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC", "mcl_dye:blue" },
["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC" }, ["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C", "mcl_dye:magenta" },
["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100" }, ["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900", "mcl_dye:orange" },
["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C" }, ["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC", "mcl_dye:violet" },
["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00"}, ["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100", "mcl_dye:brown" },
["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF" }, ["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C", "mcl_dye:pink" },
["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00", "mcl_dye:green" },
["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF", "mcl_dye:lightblue" },
} }
-- Overlay ratios (0-255) -- Overlay ratios (0-255)
local base_color_ratio = 224 local base_color_ratio = 224
@ -45,8 +47,8 @@ end
local make_banner_texture = function(base_color, layers) local make_banner_texture = function(base_color, layers)
local colorize local colorize
if colors[base_color] then if mcl_banners.colors[base_color] then
colorize = colors[base_color][4] colorize = mcl_banners.colors[base_color][4]
end end
if colorize then if colorize then
-- Base texture with base color -- Base texture with base color
@ -58,7 +60,7 @@ local make_banner_texture = function(base_color, layers)
for l=1, #layers do for l=1, #layers do
local layerinfo = layers[l] local layerinfo = layers[l]
local pattern = "mcl_banners_" .. layerinfo.pattern .. ".png" local pattern = "mcl_banners_" .. layerinfo.pattern .. ".png"
local color = colors[layerinfo.color][4] local color = mcl_banners.colors[layerinfo.color][4]
-- Generate layer texture -- Generate layer texture
local layer = "(("..pattern.."^[colorize:"..color..":"..layer_ratio..")^[mask:"..pattern..")" local layer = "(("..pattern.."^[colorize:"..color..":"..layer_ratio..")^[mask:"..pattern..")"
@ -97,7 +99,7 @@ minetest.register_node("mcl_banners:standing_banner", {
_mcl_blast_resistance = 5, _mcl_blast_resistance = 5,
}) })
for colorid, colortab in pairs(colors) do for colorid, colortab in pairs(mcl_banners.colors) do
local itemid = colortab[1] local itemid = colortab[1]
local desc = colortab[2] local desc = colortab[2]
local wool = colortab[3] local wool = colortab[3]
@ -221,7 +223,7 @@ minetest.register_entity("mcl_banners:standing_banner", {
pos.y = pos.y + 1 pos.y = pos.y + 1
if not minetest.settings:get_bool("creative_mode") and self._base_color then if not minetest.settings:get_bool("creative_mode") and self._base_color then
minetest.add_item(pos, "mcl_banners:banner_item_"..colors[self._base_color][1]) minetest.add_item(pos, "mcl_banners:banner_item_"..mcl_banners.colors[self._base_color][1])
end end
-- Destroy entity -- Destroy entity

View File

@ -1,42 +1,192 @@
-- List of patterns with crafting rules
local d = "%D" -- dye
local e = "" -- empty slot (one of them must contain the banner)
local patterns = { local patterns = {
"border", ["border"] = {
"bricks", { d, d, d },
"circle", { d, e, d },
"creeper", { d, d, d },
"cross", },
"curly_border", ["bricks"] = {
"diagonal_left", type = "shapeless",
"diagonal_right", { "mcl_core:brick_block", d },
"diagonal_up_left", },
"diagonal_up_right", ["circle"] = {
"flower", { e, e, e },
"gradient", { e, d, e },
"gradient_up", { e, e, e },
"half_horizontal_bottom", },
"half_horizontal", ["creeper"] = {
"half_vertical", type = "shapeless",
"half_vertical_right", { "mcl_heads:creeper", d },
"thing", },
"rhombus", ["cross"] = {
"skull", { d, e, d },
"small_stripes", { e, d, e },
"square_bottom_left", { d, e, d },
"square_bottom_right", },
"square_top_left", ["curly_border"] = {
"square_top_right", type = "shapless",
"straight_cross", { "mcl_core:vine", d },
"stripe_bottom", },
"stripe_center", ["diagonal_left"] = {
"stripe_downleft", { e, e, e },
"stripe_downright", { d, e, e },
"stripe_left", { d, d, e },
"stripe_middle", },
"stripe_right", ["diagonal_right"] = {
"stripe_top", { e, e, e },
"triangle_bottom", { e, e, d },
"triangles_bottom", { e, d, d },
"triangles_top", },
"triangle_top", ["diagonal_up_left"] = {
{ e, d, d },
{ e, e, d },
{ e, e, e },
},
["diagonal_up_right"] = {
{ d, d, e },
{ d, e, e },
{ e, e, e },
},
["flower"] = {
type = "shapeless",
{ "mcl_flowers:oxeye_daisy", d },
},
["gradient"] = {
{ d, e, d },
{ e, d, e },
{ e, d, e },
},
["gradient_up"] = {
{ e, d, e },
{ e, d, e },
{ d, e, d },
},
["half_horizontal_bottom"] = {
{ e, e, e },
{ d, d, d },
{ d, d, d },
},
["half_horizontal"] = {
{ d, d, d },
{ d, d, d },
{ e, e, e },
},
["half_vertical"] = {
{ d, d, e },
{ d, d, e },
{ d, d, e },
},
["half_vertical_right"] = {
{ e, d, d },
{ e, d, d },
{ e, d, d },
},
["thing"] = {
type = "shapeless",
{ "mcl_core:apple_gold", d },
},
["rhombus"] = {
{ e, d, e },
{ d, e, d },
{ e, d, e },
},
["skull"] = {
type = "shapeless",
{ "mcl_heads:wither_skeleton", d },
},
["small_stripes"] = {
{ d, e, d },
{ d, e, d },
{ e, e, e },
},
["square_bottom_left"] = {
{ e, e, e },
{ e, e, e },
{ d, e, e },
},
["square_bottom_right"] = {
{ e, e, e },
{ e, e, e },
{ e, e, d },
},
["square_top_left"] = {
{ d, e, e },
{ e, e, e },
{ e, e, e },
},
["square_top_right"] = {
{ e, e, d },
{ e, e, e },
{ e, e, e },
},
["straight_cross"] = {
{ e, d, e },
{ d, d, d },
{ e, d, e },
},
["stripe_bottom"] = {
{ e, e, e },
{ e, e, e },
{ d, d, d },
},
["stripe_center"] = {
{ e, e, e },
{ d, d, d },
{ e, e, e },
},
["stripe_downleft"] = {
{ e, e, d },
{ e, d, e },
{ d, e, e },
},
["stripe_downright"] = {
{ d, e, e },
{ e, d, e },
{ e, e, d },
},
["stripe_left"] = {
{ d, e, e },
{ d, e, e },
{ d, e, e },
},
["stripe_middle"] = {
{ e, d, e },
{ e, d, e },
{ e, d, e },
},
["stripe_right"] = {
{ e, e, d },
{ e, e, d },
{ e, e, d },
},
["stripe_top"] = {
{ d, d, d },
{ e, e, e },
{ e, e, e },
},
["triangle_bottom"] = {
{ e, e, e },
{ e, d, e },
{ d, e, d },
},
["triangles_bottom"] = {
{ e, e, e },
{ d, e, d },
{ e, d, e },
},
["triangles_top"] = {
{ e, d, e },
{ d, e, d },
{ e, e, e },
},
["triangle_top"] = {
{ d, e, d },
{ e, d, e },
{ e, e, e },
},
} }
minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv)
@ -97,50 +247,36 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
return itemstack return itemstack
end) end)
-- Register crafting recipes for all the patterns
minetest.register_craft({ for pattern_name, pattern in pairs(patterns) do
recipe = { if pattern.type == nil then
{ "", "", "" }, for colorid, colortab in pairs(mcl_banners.colors) do
{ "", "mcl_banners:banner_item_red", "" }, local banner = "mcl_banners:banner_item_"..colortab[1]
{ "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, local bannered = false
}, local recipe = {}
output = "mcl_banners:banner_item_red", for row_id=1, #pattern do
}) local row = pattern[row_id]
local newrow = {}
minetest.register_craft({ for r=1, #row do
recipe = { if row[r] == d then
{ "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, newrow[r] = "group:dye"
{ "", "mcl_banners:banner_item_red", "" }, elseif row[r] == e and not bannered then
{ "", "", "" }, newrow[r] = banner
}, bannered = true
output = "mcl_banners:banner_item_red", else
}) newrow[r] = row[r]
end
minetest.register_craft({ end
recipe = { table.insert(recipe, newrow)
{ "mcl_dye:yellow", "", "" }, end
{ "mcl_dye:yellow", "mcl_banners:banner_item_red", "" }, minetest.register_craft({
{ "mcl_dye:yellow", "", "" }, output = "mcl_banners:banner_item_"..colortab[1],
}, recipe = recipe,
output = "mcl_banners:banner_item_red", })
}) end
elseif pattern.type == "shapeless" then
minetest.register_craft({ -- TODO
recipe = { end
{ "", "mcl_dye:yellow", "" }, end
{ "", "mcl_dye:yellow", "mcl_banners:banner_item_red", },
{ "", "mcl_dye:yellow", "" },
},
output = "mcl_banners:banner_item_red",
})
minetest.register_craft({
recipe = {
{ "", "", "mcl_dye:yellow", },
{ "", "mcl_banners:banner_item_red", "mcl_dye:yellow", },
{ "", "", "mcl_dye:yellow" },
},
output = "mcl_banners:banner_item_red",
})