bugfix for crash with last commit

master
Alexander Weber 2018-04-13 21:46:20 +02:00
parent 289f7f17e5
commit 7c7dd54aea
3 changed files with 9 additions and 25 deletions

View File

@ -189,13 +189,8 @@ local function update_from_recipelist(state, recipelist, preview_item, replace_n
if duplicate_index_tmp[def.name] then
table.insert(duplicate_index_tmp[def.name].recipes, recipe)
else
local entry = {
itemdef = def,
recipes = {},
-- buttons_grid related
item = def.name,
is_button = true
}
local entry = table.copy(cache.citems[def.name].ui_item)
entry.recipes = {}
duplicate_index_tmp[def.name] = entry
table.insert(entry.recipes, recipe)
table.insert(craftable_itemlist, entry)

View File

@ -35,15 +35,9 @@ local function update_grid(state, listname)
if itemdef then
cache.add_item(itemdef) -- analyze groups in case of hidden armor
if cache.citems[itemdef.name].cgroups["armor"] then
local entry = table.copy(cache.citems[itemdef.name].ui_item)
entry.stack_index = stack_index
local wear = stack:get_wear()
local entry = {
itemdef = itemdef,
stack_index = stack_index,
-- buttons_grid related
item = itemdef.name,
is_button = true
}
if wear > 0 then
entry.text = tostring(math.floor((1 - wear / 65535) * 100 + 0.5)).." %"
end
@ -58,18 +52,13 @@ local function update_grid(state, listname)
for _, itemdef in pairs(cache.cgroups["armor"].items) do
if not list_dedup[itemdef.name] and not itemdef.groups.not_in_creative_inventory then
list_dedup[itemdef.name] = itemdef
table.insert(list, {
itemdef = itemdef,
-- buttons_grid related
item = itemdef.name,
is_button = true
})
table.insert(list, cache.citems[itemdef.name].ui_item)
end
end
end
table.sort(list, function(a,b)
return a.item < b.item
return a.sort_value < b.sort_value
end)
local grid = state:get(listname.."_grid")
grid:setList(list)

View File

@ -437,7 +437,7 @@ if minetest.global_exists("unifieddyes") then
function unifieddyes_getpaletteidx(entry)
local ret = unifieddyes.getpaletteidx(entry.item, "extended")
if ret then
local ret2= string.format("%02X", ret)
local ret2 = string.format("%02X", ret)
return 'dye '..ret2
end
end
@ -462,8 +462,8 @@ local function prepare_root_lists()
}
entry.sort_value = unifieddyes_getpaletteidx(entry) or itemname
if cache.citems[itemname].cgroups["shape"] then
citem.ui_item = entry
if citem.cgroups["shape"] then
table.insert(ui_tools.root_list_shape, entry)
else
table.insert(ui_tools.root_list, entry)