mirror of
https://github.com/minetest-mods/craftguide.git
synced 2025-07-14 05:50:16 +02:00
Compare commits
3 Commits
9412ac740a
...
6e6ff93d29
Author | SHA1 | Date | |
---|---|---|---|
6e6ff93d29 | |||
2fd3604cac | |||
96f9c85c77 |
29
init.lua
29
init.lua
@ -23,6 +23,7 @@ local reg_aliases = core.registered_aliases
|
||||
local log = core.log
|
||||
local after = core.after
|
||||
local clr = core.colorize
|
||||
local sound_play = core.sound_play
|
||||
local parse_json = core.parse_json
|
||||
local write_json = core.write_json
|
||||
local chat_send = core.chat_send_player
|
||||
@ -103,6 +104,7 @@ local FMT = {
|
||||
image = "image[%f,%f;%f,%f;%s]",
|
||||
button = "button[%f,%f;%f,%f;%s;%s]",
|
||||
tooltip = "tooltip[%f,%f;%f,%f;%s]",
|
||||
hypertext = "hypertext[%f,%f;%f,%f;;%s]",
|
||||
item_image = "item_image[%f,%f;%f,%f;%s]",
|
||||
image_button = "image_button[%f,%f;%f,%f;%s;%s;%s]",
|
||||
animated_image = "animated_image[%f,%f;%f,%f;;%s;%u;%u]",
|
||||
@ -792,7 +794,7 @@ local function is_fav(favs, query_item)
|
||||
end
|
||||
|
||||
local function weird_desc(str)
|
||||
return not true_str(str) or find(str, "\n") or not find(str, "%u")
|
||||
return not true_str(str) or find(str, "[\\]*") or not find(str, "%u")
|
||||
end
|
||||
|
||||
local function toupper(str)
|
||||
@ -803,6 +805,10 @@ local function strip_newline(str)
|
||||
return match(str, "[^\n]*")
|
||||
end
|
||||
|
||||
local function strip_prefix(str)
|
||||
return match(str, ".*@.*%)(.*)()") or str
|
||||
end
|
||||
|
||||
local function get_desc(item, lang_code)
|
||||
if sub(item, 1, 1) == "_" then
|
||||
item = sub(item, 2)
|
||||
@ -813,10 +819,16 @@ local function get_desc(item, lang_code)
|
||||
if def then
|
||||
local desc = def.description
|
||||
if true_str(desc) then
|
||||
desc = translate(lang_code, desc)
|
||||
desc = desc:trim()
|
||||
desc = strip_newline(desc)
|
||||
desc = strip_prefix(desc)
|
||||
|
||||
if not find(desc, "%u") then
|
||||
return strip_newline(toupper(desc))
|
||||
desc = toupper(desc)
|
||||
end
|
||||
return strip_newline(translate(lang_code, desc))
|
||||
|
||||
return desc
|
||||
|
||||
elseif true_str(item) then
|
||||
return toupper(match(item, ":(.*)"))
|
||||
@ -1163,8 +1175,8 @@ local function get_title_fs(query_item, lang_code, favs, fs, spacing)
|
||||
local t_desc = query_item
|
||||
t_desc = #t_desc > 40 and fmt("%s...", sub(t_desc, 1, 37)) or t_desc
|
||||
|
||||
fs[#fs + 1] = fmt("hypertext[9.05,%f;5.85,1.2;;%s]",
|
||||
spacing - 0.1,
|
||||
fs[#fs + 1] = fmt(FMT.hypertext,
|
||||
9.05, spacing - 0.1, 5.85, 1.2,
|
||||
fmt("<item name=%s float=right width=64 height=64 rotate=yes>" ..
|
||||
"<big><b>%s</b></big>\n<style color=#7bf font=mono>%s</style>",
|
||||
query_item, desc, t_desc))
|
||||
@ -1332,7 +1344,7 @@ local function make_fs(data)
|
||||
lbl = ES"Collect items to reveal more recipes"
|
||||
end
|
||||
|
||||
fs[#fs + 1] = fmt("hypertext[%f,%f;%f,%f;;%s]",
|
||||
fs[#fs + 1] = fmt(FMT.hypertext,
|
||||
0.05, 3, 8.29, 1,
|
||||
fmt("<center><style size=20><b>%s</b></style></center>]",
|
||||
translate(data.lang_code, lbl)))
|
||||
@ -1631,9 +1643,14 @@ on_joinplayer(function(player)
|
||||
end)
|
||||
|
||||
local function fields(player, _f)
|
||||
if _f.quit then return end
|
||||
local name = player:get_player_name()
|
||||
local data = pdata[name]
|
||||
|
||||
if not _f.key_enter_field then
|
||||
sound_play("craftguide_click", {to_player = name, gain = 0.2})
|
||||
end
|
||||
|
||||
if _f.clear then
|
||||
reset_data(data)
|
||||
|
||||
|
BIN
sounds/craftguide_click.ogg
Normal file
BIN
sounds/craftguide_click.ogg
Normal file
Binary file not shown.
Reference in New Issue
Block a user