forked from Mineclonia/Mineclonia
items/mcl_banners: reuse `escape` across functions
This commit is contained in:
parent
412c1ac5d6
commit
164b65a2ca
|
@ -144,6 +144,10 @@ local on_destruct_hanging_banner = function(pos)
|
||||||
return on_destruct_banner(pos, true)
|
return on_destruct_banner(pos, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function escape(text)
|
||||||
|
return text:gsub("%^", "\\%^"):gsub(":", "\\:") -- :gsub("%(", "\\%("):gsub("%)", "\\%)")
|
||||||
|
end
|
||||||
|
|
||||||
local make_banner_overlay = function(base_color, layers)
|
local make_banner_overlay = function(base_color, layers)
|
||||||
local colorize = mcl_banners.colors[base_color][4]
|
local colorize = mcl_banners.colors[base_color][4]
|
||||||
-- Base texture with base color
|
-- Base texture with base color
|
||||||
|
@ -163,10 +167,6 @@ local make_banner_overlay = function(base_color, layers)
|
||||||
lovl = (lovl ~= "" and (lovl .. "^") or "") .. layer
|
lovl = (lovl ~= "" and (lovl .. "^") or "") .. layer
|
||||||
end
|
end
|
||||||
|
|
||||||
local function escape(text)
|
|
||||||
return text:gsub("%^", "\\%^"):gsub(":", "\\:") -- :gsub("%(", "\\%("):gsub("%)", "\\%)")
|
|
||||||
end
|
|
||||||
|
|
||||||
return "[combine:32x32:0,0=" .. escape(base) .. ":7,3=" .. escape("("..lovl.."^[resize:50x38)")
|
return "[combine:32x32:0,0=" .. escape(base) .. ":7,3=" .. escape("("..lovl.."^[resize:50x38)")
|
||||||
end
|
end
|
||||||
return base
|
return base
|
||||||
|
@ -430,10 +430,6 @@ for colorid, colortab in pairs(mcl_banners.colors) do
|
||||||
|
|
||||||
local layer = "(([combine:20x40:-2,-2="..pattern.."^[resize:16x24^[colorize:"..color..":"..layer_ratio.."))"
|
local layer = "(([combine:20x40:-2,-2="..pattern.."^[resize:16x24^[colorize:"..color..":"..layer_ratio.."))"
|
||||||
|
|
||||||
function escape(text)
|
|
||||||
return text:gsub("%^", "\\%^"):gsub(":", "\\:") -- :gsub("%(", "\\%("):gsub("%)", "\\%)")
|
|
||||||
end
|
|
||||||
|
|
||||||
finished_banner = "[combine:32x32:0,0=" .. escape(base) .. ":8,4=" .. escape(layer)
|
finished_banner = "[combine:32x32:0,0=" .. escape(base) .. ":8,4=" .. escape(layer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue