rubenwardy / sfinv

Minetest Mod: Simple Fast Inventory
MIT License
7 stars 5 forks source link
minetest-mod

Simple Fast Inventory

SFINV Screeny

A cleaner, simpler solution to having an advanced inventory in Minetest.

Written by rubenwardy.\ License: MIT

API

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

sfinv Methods

Pages

Contexts

Theming

sfinv Members

Context

A table with these keys:

sfinv.register_page

sfinv.register_page(name, def)

def is a table containing:

get formspec

Use 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.

Customising themes

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