Use minetest.colorize

This commit is contained in:
Paul Ouellette 2019-01-20 00:19:34 -05:00
parent 060caad104
commit 21e4ec8700
1 changed files with 8 additions and 18 deletions

View File

@ -108,16 +108,6 @@ local function cache_fuel(item)
end
end
local color_codes = {
red = "#FF0000",
yellow = "#FFFF00",
}
local function colorize(str, color)
color = color or "yellow"
return mt.colorize(color_codes[color], str)
end
local function extract_groups(str)
return str:sub(7):split(",")
end
@ -158,7 +148,7 @@ local function get_tooltip(item, groups, cooktime, burntime)
if groups then
local groupstr = {}
for i = 1, #groups do
groupstr[#groupstr + 1] = colorize(groups[i])
groupstr[#groupstr + 1] = mt.colorize("yellow", groups[i])
end
groupstr = concat(groupstr, ", ")
tooltip = S("Any item belonging to the group(s):") .. " " .. groupstr
@ -168,12 +158,12 @@ local function get_tooltip(item, groups, cooktime, burntime)
if cooktime then
tooltip = tooltip .. "\n" .. S("Cooking time:") .. " " ..
colorize(cooktime)
mt.colorize("yellow", cooktime)
end
if burntime then
tooltip = tooltip .. "\n" .. S("Burning time:") .. " " ..
colorize(burntime)
mt.colorize("yellow", burntime)
end
return "tooltip[" .. item .. ";" .. tooltip .. "]"
@ -361,8 +351,8 @@ local function make_formspec(player_name)
fs[#fs + 1] = "tooltip[next;" .. S("Next page") .. "]"
fs[#fs + 1] = "image_button[" .. (data.iX - (sfinv_only and 2.6 or 3.1)) ..
",0.12;0.8,0.8;craftguide_prev_icon.png;prev;]"
fs[#fs + 1] = "label[" .. (data.iX - (sfinv_only and 1.7 or 2.2)) ..
",0.22;" .. colorize(data.pagenum) .. " / " .. data.pagemax .. "]"
fs[#fs + 1] = "label[" .. (data.iX - (sfinv_only and 1.7 or 2.2)) .. ",0.22;" ..
mt.colorize("yellow", data.pagenum) .. " / " .. data.pagemax .. "]"
fs[#fs + 1] = "image_button[" .. (data.iX - (sfinv_only and 0.7 or 1.2) -
(data.iX >= 11 and 0.08 or 0)) ..
",0.12;0.8,0.8;craftguide_next_icon.png;next;]"
@ -877,7 +867,7 @@ if not progressive_mode then
end
if not node_name then
return false, colorize("[craftguide] ", "red") ..
return false, mt.colorize("red", "[craftguide] ") ..
S("No node pointed")
elseif not player_data[name] then
init_data(player, name)
@ -891,9 +881,9 @@ if not progressive_mode then
local is_fuel = fuel_cache[node_name]
if no_recipes and not is_fuel then
return false, colorize("[craftguide] ", "red") ..
return false, mt.colorize("red", "[craftguide] ") ..
S("No recipe for this node:") .. " " ..
colorize(node_name)
mt.colorize("yellow", node_name)
end
if is_fuel and no_recipes then