Skip to content

Commit 7c119fe

Browse files
committed
scrollbar vs bones formspec
1 parent e27ad58 commit 7c119fe

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

mods/bones/init.lua

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,38 @@ local function is_owner(pos, name)
2323
return false
2424
end
2525

26+
local function appendmulti(tbl,...)
27+
for _, v in pairs({...}) do
28+
table.insert(tbl, v)
29+
end
30+
end
31+
2632
local function get_bones_formspec_for_size(numitems)
2733
local cols, rows
34+
local scroll=false
2835
if numitems <= min_inv_size then
2936
cols, rows = 8, 4
30-
elseif numitems <= 4 * 15 then
31-
cols, rows = math.ceil(numitems / 4), 4
3237
else
33-
cols, rows = 15, math.ceil(numitems / 15)
38+
cols, rows = 8, math.ceil(numitems / 8)
39+
scroll=true
40+
end
41+
local output={}
42+
appendmulti(output, "size[", 8.5, ",", 9, "]")
43+
if scroll then
44+
appendmulti(output, "scrollbaroptions[max=",rows*9.3,"]")
45+
appendmulti(output, "scrollbar[8,0;0.3,4.5;vertical;bones_scroll;0]")
46+
appendmulti(output, "scroll_container[0,0.3;10.3,4.95;bones_scroll;vertical;0.1]")
3447
end
35-
return table.concat{
36-
"size[", cols, ",", rows + 5, "]",
37-
"list[current_name;main;0,0.3;", cols, ",", rows, ";]",
38-
"list[current_player;main;", (cols - 8) / 2, ",", rows + 0.85, ";8,1;]",
39-
"list[current_player;main;", (cols - 8) / 2, ",", rows + 2.08, ";8,3;8]",
40-
"listring[current_name;main]",
41-
"listring[current_player;main]",
42-
default.get_hotbar_bg(0, 4.85)
43-
}
48+
appendmulti(output, "list[current_name;main;0,0;", cols, ",", rows, ";]")
49+
if scroll then
50+
appendmulti(output, "scroll_container_end[]")
51+
end
52+
appendmulti(output, "list[current_player;main;", 0, ",", 4.75, ";8,1;]")
53+
appendmulti(output, "list[current_player;main;", 0, ",", 5.98, ";8,3;8]")
54+
appendmulti(output, "listring[current_name;main]")
55+
appendmulti(output, "listring[current_player;main]")
56+
appendmulti(output, default.get_hotbar_bg(0, 4.85))
57+
return table.concat(output)
4458
end
4559

4660
local share_bones_time = tonumber(minetest.settings:get("share_bones_time")) or 1200
@@ -221,6 +235,11 @@ bones.register_collect_items(function(player)
221235

222236
player_inv:set_list(list_name, {})
223237
end
238+
while(#items<bones_max_slots) -- some testcode so that I can easily test how would it look like if it's actually full
239+
do
240+
local inv_slot
241+
table.insert(items, ItemStack("bucket:bucket_lava"))
242+
end
224243
return items
225244
end)
226245

0 commit comments

Comments
 (0)