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
end
local colors = {
-- ID, description, wool, unified dyes color group, overlay color,
["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF" },
["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030" },
["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B" },
["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000" },
["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000" },
["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800" },
["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000" },
["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC" },
["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC" },
["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C" },
["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900" },
["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC" },
["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100" },
["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C" },
["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00"},
["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF" },
mcl_banners = {}
mcl_banners.colors = {
-- ID, description, wool, unified dyes color group, overlay color, dye
["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF", "mcl_dye:white" },
["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030", "mcl_dye:dark_grey" },
["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B", "mcl_dye:grey" },
["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000", "mcl_dye:black" },
["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000", "mcl_dye:red" },
["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800", "mcl_dye:yellow" },
["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000", "mcl_dye:dark_green" },
["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC", "mcl_dye:cyan" },
["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC", "mcl_dye:blue" },
["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C", "mcl_dye:magenta" },
["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900", "mcl_dye:orange" },
["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC", "mcl_dye:violet" },
["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100", "mcl_dye:brown" },
["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)
local base_color_ratio = 224
@ -45,8 +47,8 @@ end
local make_banner_texture = function(base_color, layers)
local colorize
if colors[base_color] then
colorize = colors[base_color][4]
if mcl_banners.colors[base_color] then
colorize = mcl_banners.colors[base_color][4]
end
if colorize then
-- Base texture with base color
@ -58,7 +60,7 @@ local make_banner_texture = function(base_color, layers)
for l=1, #layers do
local layerinfo = layers[l]
local pattern = "mcl_banners_" .. layerinfo.pattern .. ".png"
local color = colors[layerinfo.color][4]
local color = mcl_banners.colors[layerinfo.color][4]
-- Generate layer texture
local layer = "(("..pattern.."^[colorize:"..color..":"..layer_ratio..")^[mask:"..pattern..")"
@ -97,7 +99,7 @@ minetest.register_node("mcl_banners:standing_banner", {
_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 desc = colortab[2]
local wool = colortab[3]
@ -221,7 +223,7 @@ minetest.register_entity("mcl_banners:standing_banner", {
pos.y = pos.y + 1
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
-- 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 = {
"border",
"bricks",
"circle",
"creeper",
"cross",
"curly_border",
"diagonal_left",
"diagonal_right",
"diagonal_up_left",
"diagonal_up_right",
"flower",
"gradient",
"gradient_up",
"half_horizontal_bottom",
"half_horizontal",
"half_vertical",
"half_vertical_right",
"thing",
"rhombus",
"skull",
"small_stripes",
"square_bottom_left",
"square_bottom_right",
"square_top_left",
"square_top_right",
"straight_cross",
"stripe_bottom",
"stripe_center",
"stripe_downleft",
"stripe_downright",
"stripe_left",
"stripe_middle",
"stripe_right",
"stripe_top",
"triangle_bottom",
"triangles_bottom",
"triangles_top",
"triangle_top",
["border"] = {
{ d, d, d },
{ d, e, d },
{ d, d, d },
},
["bricks"] = {
type = "shapeless",
{ "mcl_core:brick_block", d },
},
["circle"] = {
{ e, e, e },
{ e, d, e },
{ e, e, e },
},
["creeper"] = {
type = "shapeless",
{ "mcl_heads:creeper", d },
},
["cross"] = {
{ d, e, d },
{ e, d, e },
{ d, e, d },
},
["curly_border"] = {
type = "shapless",
{ "mcl_core:vine", d },
},
["diagonal_left"] = {
{ e, e, e },
{ d, e, e },
{ d, d, e },
},
["diagonal_right"] = {
{ e, e, e },
{ e, e, d },
{ e, d, d },
},
["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)
@ -97,50 +247,36 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
return itemstack
end)
-- Register crafting recipes for all the patterns
for pattern_name, pattern in pairs(patterns) do
if pattern.type == nil then
for colorid, colortab in pairs(mcl_banners.colors) do
local banner = "mcl_banners:banner_item_"..colortab[1]
local bannered = false
local recipe = {}
for row_id=1, #pattern do
local row = pattern[row_id]
local newrow = {}
for r=1, #row do
if row[r] == d then
newrow[r] = "group:dye"
elseif row[r] == e and not bannered then
newrow[r] = banner
bannered = true
else
newrow[r] = row[r]
end
end
table.insert(recipe, newrow)
end
minetest.register_craft({
recipe = {
{ "", "", "" },
{ "", "mcl_banners:banner_item_red", "" },
{ "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" },
},
output = "mcl_banners:banner_item_red",
})
minetest.register_craft({
recipe = {
{ "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" },
{ "", "mcl_banners:banner_item_red", "" },
{ "", "", "" },
},
output = "mcl_banners:banner_item_red",
})
minetest.register_craft({
recipe = {
{ "mcl_dye:yellow", "", "" },
{ "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_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",
output = "mcl_banners:banner_item_"..colortab[1],
recipe = recipe,
})
end
elseif pattern.type == "shapeless" then
-- TODO
end
end