mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-12-13 18:20:17 +01:00
Fix list size counting
This commit is contained in:
parent
7e1b2b8260
commit
f321647a6b
6
init.lua
6
init.lua
@ -209,7 +209,7 @@ function craftguide:recipe_in_inv(player_name, item_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function craftguide:get_items(player_name)
|
function craftguide:get_items(player_name)
|
||||||
local items_list, data, list_size = {}, datas[player_name]
|
local items_list, data, list_size = {}, datas[player_name], 0
|
||||||
for name, def in pairs(minetest.registered_items) do
|
for name, def in pairs(minetest.registered_items) do
|
||||||
local is_fuel = minetest.get_craft_result({
|
local is_fuel = minetest.get_craft_result({
|
||||||
method="fuel", width=1, items={name}}).time > 0
|
method="fuel", width=1, items={name}}).time > 0
|
||||||
@ -219,7 +219,6 @@ function craftguide:get_items(player_name)
|
|||||||
(def.name:find(data.filter, 1, true) or
|
(def.name:find(data.filter, 1, true) or
|
||||||
def.description:lower():find(data.filter, 1, true)) then
|
def.description:lower():find(data.filter, 1, true)) then
|
||||||
|
|
||||||
list_size = #items_list
|
|
||||||
if progressive_mode then
|
if progressive_mode then
|
||||||
local _, player_has_item =
|
local _, player_has_item =
|
||||||
self:recipe_in_inv(player_name, name)
|
self:recipe_in_inv(player_name, name)
|
||||||
@ -229,12 +228,13 @@ function craftguide:get_items(player_name)
|
|||||||
else
|
else
|
||||||
items_list[list_size+1] = name
|
items_list[list_size+1] = name
|
||||||
end
|
end
|
||||||
|
list_size = #items_list
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.sort(items_list)
|
table.sort(items_list)
|
||||||
data.items = items_list
|
data.items = items_list
|
||||||
data.size = list_size or 0
|
data.size = list_size
|
||||||
data.pagemax = max(1, ceil(data.size / ipp))
|
data.pagemax = max(1, ceil(data.size / ipp))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user