mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-18 07:10:21 +01:00
Use minetest.colorize
This commit is contained in:
parent
060caad104
commit
21e4ec8700
26
init.lua
26
init.lua
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user