player: sort armor by material
parent
7c7dd54aea
commit
374286caa6
17
ui_tools.lua
17
ui_tools.lua
|
@ -432,9 +432,9 @@ function ui_tools.get_list_grouped(itemtable)
|
|||
end
|
||||
|
||||
|
||||
local function unifieddyes_getpaletteidx() end
|
||||
local function unifieddyes_sort_order() end
|
||||
if minetest.global_exists("unifieddyes") then
|
||||
function unifieddyes_getpaletteidx(entry)
|
||||
function unifieddyes_sort_order(entry)
|
||||
local ret = unifieddyes.getpaletteidx(entry.item, "extended")
|
||||
if ret then
|
||||
local ret2 = string.format("%02X", ret)
|
||||
|
@ -443,6 +443,17 @@ if minetest.global_exists("unifieddyes") then
|
|||
end
|
||||
end
|
||||
|
||||
local function armor_sort_order(entry) end
|
||||
if minetest.global_exists("armor") then
|
||||
function armor_sort_order(entry)
|
||||
if not cache.citems[entry.item].cgroups["armor"] then
|
||||
return
|
||||
end
|
||||
local split = entry.item:split("_")
|
||||
return "armor "..split[#split]..entry.item
|
||||
end
|
||||
end
|
||||
|
||||
-----------------------------------------------------
|
||||
-- Prepare root lists for all users
|
||||
-----------------------------------------------------
|
||||
|
@ -461,7 +472,7 @@ local function prepare_root_lists()
|
|||
is_button = true
|
||||
}
|
||||
|
||||
entry.sort_value = unifieddyes_getpaletteidx(entry) or itemname
|
||||
entry.sort_value = unifieddyes_sort_order(entry) or armor_sort_order(entry) or itemname
|
||||
citem.ui_item = entry
|
||||
if citem.cgroups["shape"] then
|
||||
table.insert(ui_tools.root_list_shape, entry)
|
||||
|
|
Loading…
Reference in New Issue