mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-23 03:13:44 +01:00
Start item listing at index instead of skipping there.
Also fixes a linter warning.
This commit is contained in:
parent
18dd120784
commit
51a00b957e
7
.luacheckrc
Normal file
7
.luacheckrc
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
unused_args = false
|
||||||
|
allow_defined_top = true
|
||||||
|
|
||||||
|
read_globals = {
|
||||||
|
"minetest",
|
||||||
|
"default",
|
||||||
|
}
|
14
init.lua
14
init.lua
@ -30,18 +30,16 @@ function craftguide:get_formspec(player_name, pagenum, recipe_num)
|
|||||||
"field[0.3,0.32;2.6,1;filter;;"..data.filter.."]"..
|
"field[0.3,0.32;2.6,1;filter;;"..data.filter.."]"..
|
||||||
default.gui_bg..default.gui_bg_img
|
default.gui_bg..default.gui_bg_img
|
||||||
|
|
||||||
local i, s = 0, 0
|
local first_item = (pagenum - 1) * npp
|
||||||
for _, name in pairs(data.items) do
|
for i = first_item, first_item + npp - 1 do
|
||||||
if s < (pagenum - 1) * npp then
|
local name = data.items[i + 1]
|
||||||
s = s + 1
|
if not name then break end -- last page
|
||||||
else if i >= npp then break end
|
|
||||||
local X = i % 8
|
local X = i % 8
|
||||||
local Y = ((i-X) / 8) + 1
|
local Y = ((i % npp - X) / 8) + 1
|
||||||
|
|
||||||
formspec = formspec.."item_image_button["..X..","..Y..";1,1;"..
|
formspec = formspec.."item_image_button["..X..","..Y..";1,1;"..
|
||||||
name..";"..name..";]"
|
name..";"..name..";]"
|
||||||
i = i + 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.item and minetest.registered_items[data.item] then
|
if data.item and minetest.registered_items[data.item] then
|
||||||
|
Loading…
Reference in New Issue
Block a user