1
0
Fork 0

Revert "Refactor mcl_banners"

This reverts commit 9f76b5e973.
This commit is contained in:
Wuzzy 2017-07-29 01:24:52 +02:00
parent 739d90f0b8
commit caf5104d8e
3 changed files with 62 additions and 71 deletions

View File

@ -1,9 +1,3 @@
-- Load shared stuff
dofile(minetest.get_modpath("mcl_banners").."/shared.lua")
-- Add pattern/emblazoning crafting recipes
dofile(minetest.get_modpath("mcl_banners").."/patterncraft.lua")
local node_sounds
if minetest.get_modpath("mcl_sounds") then
node_sounds = mcl_sounds.node_sound_wood_defaults()
@ -15,6 +9,32 @@ local function round(num, idp)
return math.floor(num * mult + 0.5) / mult
end
mcl_banners = {}
mcl_banners.colors = {
-- Format:
-- [ID] = { banner description, wool, unified dyes color group, overlay color, dye, color name for emblazonings }
["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF", "mcl_dye:white", "White" },
["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030", "mcl_dye:dark_grey", "Grey" },
["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B", "mcl_dye:grey", "Light Grey" },
["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000", "mcl_dye:black", "Black" },
["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000", "mcl_dye:red", "Red" },
["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800", "mcl_dye:yellow", "Yellow" },
["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000", "mcl_dye:dark_green", "Green" },
["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC", "mcl_dye:cyan", "Cyan" },
["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC", "mcl_dye:blue", "Blue" },
["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C", "mcl_dye:magenta", "Magenta"},
["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900", "mcl_dye:orange", "Orange" },
["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC", "mcl_dye:violet", "Violet" },
["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100", "mcl_dye:brown", "Brown" },
["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C", "mcl_dye:pink", "Pink" },
["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00", "mcl_dye:green", "Lime" },
["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF", "mcl_dye:lightblue", "Light Blue" },
}
-- Add pattern/emblazoning crafting recipes
dofile(minetest.get_modpath("mcl_banners").."/patterncraft.lua")
-- Overlay ratios (0-255)
local base_color_ratio = 224
local layer_ratio = 255

View File

@ -5,6 +5,10 @@
-- Maximum number of layers which can be put on a banner by crafting.
local max_layers_crafting = 6
-- Max. number lines in the descriptions for the banner layers.
-- This is done to avoid huge tooltips.
local max_layer_lines = 6
-- List of patterns with crafting rules
local d = "group:dye" -- dye
local e = "" -- empty slot (one of them must contain the banner)
@ -243,6 +247,38 @@ for colorid, colortab in pairs(mcl_banners.colors) do
dye_to_colorid_mapping[colortab[5]] = colorid
end
-- Create a banner description containing all the layer names
mcl_banners.make_advanced_banner_description = function(description, layers)
if layers == nil or #layers == 0 then
-- No layers, revert to default
return ""
else
local layerstrings = {}
for l=1, #layers do
-- Prevent excess length description
if l > max_layer_lines then
break
end
-- Layer text line.
local color = mcl_banners.colors[layers[l].color][6]
local pattern_name = patterns[layers[l].pattern].name
-- The pattern name is a format string (e.g. “%s Base”)
table.insert(layerstrings, string.format(pattern_name, color))
end
-- Warn about missing information
if #layers == max_layer_lines + 1 then
table.insert(layerstrings, "And one addional layer")
elseif #layers > max_layer_lines + 1 then
table.insert(layerstrings, string.format("And %d addional layers", #layers - max_layer_lines))
end
-- Final string concatenations: Just a list of strings
local append = table.concat(layerstrings, "\n")
description = description .. "\n" .. core.colorize("#8F8F8F", append)
return description
end
end
-- This is for handling all those complex pattern crafting recipes
local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_inv)
if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then

View File

@ -1,65 +0,0 @@
-- Shared functions and variables
mcl_banners = {}
-- Global banner definitions
mcl_banners.colors = {
-- Format:
-- [ID] = { banner description, wool, unified dyes color group, overlay color, dye, color name for emblazonings }
["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF", "mcl_dye:white", "White" },
["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030", "mcl_dye:dark_grey", "Grey" },
["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B", "mcl_dye:grey", "Light Grey" },
["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000", "mcl_dye:black", "Black" },
["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000", "mcl_dye:red", "Red" },
["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800", "mcl_dye:yellow", "Yellow" },
["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000", "mcl_dye:dark_green", "Green" },
["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC", "mcl_dye:cyan", "Cyan" },
["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC", "mcl_dye:blue", "Blue" },
["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C", "mcl_dye:magenta", "Magenta"},
["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900", "mcl_dye:orange", "Orange" },
["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC", "mcl_dye:violet", "Violet" },
["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100", "mcl_dye:brown", "Brown" },
["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C", "mcl_dye:pink", "Pink" },
["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00", "mcl_dye:green", "Lime" },
["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF", "mcl_dye:lightblue", "Light Blue" },
}
-- Max. number lines in the descriptions for the banner layers.
-- This is done to avoid huge tooltips.
local max_layer_lines = 6
-- Returns a banner description containing all the layer names.
-- description: Base description (from item definition)
-- layers: Table of layers
mcl_banners.make_advanced_banner_description = function(description, layers)
if layers == nil or #layers == 0 then
-- No layers, revert to default
return ""
else
local layerstrings = {}
for l=1, #layers do
-- Prevent excess length description
if l > max_layer_lines then
break
end
-- Layer text line.
local color = mcl_banners.colors[layers[l].color][6]
local pattern_name = patterns[layers[l].pattern].name
-- The pattern name is a format string (e.g. “%s Base”)
table.insert(layerstrings, string.format(pattern_name, color))
end
-- Warn about missing information
if #layers == max_layer_lines + 1 then
table.insert(layerstrings, "And one addional layer")
elseif #layers > max_layer_lines + 1 then
table.insert(layerstrings, string.format("And %d addional layers", #layers - max_layer_lines))
end
-- Final string concatenations: Just a list of strings
local append = table.concat(layerstrings, "\n")
description = description .. "\n" .. core.colorize("#8F8F8F", append)
return description
end
end