THIS IS A FORKED VERSION! ALL THE DIFFERENCES LISTED HERE!
CLICK HERE TO READ TUTORIAL.
A cleaner, simpler solution to having an advanced inventory in Minetest.
Written by rubenwardy.\ License: MIT
It is recommended that you read this link for a good introduction to the sfinv API by its author: https://rubenwardy.com/minetest_modding_book/en/players/sfinv.html
Pages
Contexts
Theming
size[8,8.6]
if not specifiedA table with these keys:
sfinv.register_page(name, def)
def is a table containing:
title
- human readable page name (required)get(self, player, context)
- returns a formspec string. See formspec
variables. (required)is_in_nav(self, player, context)
- return true to show in the navigation
(the tab header, by default)on_player_receive_fields(self, player, context, fields)
- on formspec
submit.on_enter(self, player, context)
- called when the player changes pages,
usually using the tabs.on_leave(self, player, context)
- when leaving this page to go to another,
called before other's on_enterUse sfinv.make_formspec to apply a layout:
return sfinv.make_formspec(player, context, [[
list[current_player;craft;1.75,0.5;3,3;]
list[current_player;craftpreview;5.75,1.5;1,1;]
image[4.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]
listring[current_player;main]
listring[current_player;craft]
image[0,4.25;1,1;gui_hb_bg.png]
image[1,4.25;1,1;gui_hb_bg.png]
image[2,4.25;1,1;gui_hb_bg.png]
image[3,4.25;1,1;gui_hb_bg.png]
image[4,4.25;1,1;gui_hb_bg.png]
image[5,4.25;1,1;gui_hb_bg.png]
image[6,4.25;1,1;gui_hb_bg.png]
image[7,4.25;1,1;gui_hb_bg.png]
]], true)
See above (methods section) for more options.
Simply override this function to change the navigation:
function sfinv.get_nav_fs(player, context, nav, current_idx)
return "navformspec"
end
And override this function to change the layout:
function sfinv.make_formspec(player, context, content, show_inv, size)
local tmp = {
size or "size[8,8.6]",
theme_main,
sfinv.get_nav_fs(player, context, context.nav_titles, context.nav_idx),
content
}
if show_inv then
tmp[4] = theme_inv
end
return table.concat(tmp, "")
end