Add sfinv.get_page()
This commit is contained in:
parent
068e0b167f
commit
1fa8180e7f
|
@ -569,6 +569,7 @@ sfinv API by its author: https://rubenwardy.com/minetest_modding_book/en/chapter
|
|||
**Pages**
|
||||
|
||||
* sfinv.set_page(player, pagename) - changes the page
|
||||
* sfinv.get_page(player) - get the current page name. Will never return nil
|
||||
* sfinv.get_homepage_name(player) - get the page name of the first page to show to a player
|
||||
* sfinv.register_page(name, def) - register a page, see section below
|
||||
* sfinv.override_page(name, def) - overrides fields of an page registered with register_page.
|
||||
|
|
|
@ -135,6 +135,11 @@ function sfinv.set_page(player, pagename)
|
|||
sfinv.set_player_inventory_formspec(player, context)
|
||||
end
|
||||
|
||||
function sfinv.get_page(player)
|
||||
local context = sfinv.contexts[player:get_player_name()]
|
||||
return context and context.page or sfinv.get_homepage_name(player)
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
if sfinv.enabled then
|
||||
sfinv.set_player_inventory_formspec(player)
|
||||
|
|
Loading…
Reference in New Issue