Add README.md
This commit is contained in:
parent
97091c6037
commit
a1456034ec
2 changed files with 82 additions and 25 deletions
82
mods/sfinv/README.md
Normal file
82
mods/sfinv/README.md
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
# Simple Fast Inventory
|
||||||
|
|
||||||
|
A cleaner, simpler, solution to having an advanced inventory in Minetest.
|
||||||
|
Formspec style based on the creative inventory.
|
||||||
|
|
||||||
|
Written by rubenwardy.
|
||||||
|
License: WTFPL
|
||||||
|
|
||||||
|
## Aims
|
||||||
|
|
||||||
|
* Unified Inventory compatible.
|
||||||
|
* Themable.
|
||||||
|
* Clean API.
|
||||||
|
|
||||||
|
# API
|
||||||
|
|
||||||
|
## Formspec Parser
|
||||||
|
|
||||||
|
sfinv has a variable based parser. Here is the formspec of the crafting tab:
|
||||||
|
|
||||||
|
{{ layout }}
|
||||||
|
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]
|
||||||
|
|
||||||
|
`{{ layout }}` will be replaced by the following:
|
||||||
|
|
||||||
|
size[8,8.6]
|
||||||
|
bgcolor[#080808BB;true]
|
||||||
|
background[5,5;1,1;gui_formbg.png;true]
|
||||||
|
{{ nav }}
|
||||||
|
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
|
||||||
|
list[current_player;main;0,4.25;8,1;]
|
||||||
|
list[current_player;main;0,5.5;8,3;8]
|
||||||
|
|
||||||
|
and `{{ nav }}` will be replaced by something like the following:
|
||||||
|
|
||||||
|
tabheader[0,0;tabs;Crafting,Page 1, Page 2;1]
|
||||||
|
|
||||||
|
Only two levels of variable parsing is guaranteed to succeed, as only two
|
||||||
|
passes are done.
|
||||||
|
|
||||||
|
Here is another example, this time a page with no inventory:
|
||||||
|
|
||||||
|
size[8,8.6]
|
||||||
|
bgcolor[#080808BB;true]
|
||||||
|
background[5,5;1,1;gui_formbg.png;true]
|
||||||
|
{{ nav }}
|
||||||
|
textlist[0,0;7.85,8.5;help;one,two,three]
|
||||||
|
|
||||||
|
The following variables are provided by the API:
|
||||||
|
|
||||||
|
* `name` - name of the player viewing
|
||||||
|
* `nav` - the navigation, probably a tabset
|
||||||
|
* `layout` - a default layout which has the players inventory at the bottom.
|
||||||
|
|
||||||
|
|
||||||
|
## sfinv.register_page
|
||||||
|
|
||||||
|
sfinv.register_page(name, def)
|
||||||
|
|
||||||
|
def is a table containing:
|
||||||
|
|
||||||
|
* `title(player, context)` - human readable page name (required)
|
||||||
|
* `get(player, context)` - returns a formspec string. See formspec variables. (required)
|
||||||
|
* `is_in_nav(player, context)` - return true if it appears in tab header
|
||||||
|
* `on_player_receive_fields(player, context, fields)` - on formspec submit
|
||||||
|
|
||||||
|
planned:
|
||||||
|
|
||||||
|
* `on_enter(player, context)` - when coming to this page from another
|
||||||
|
* `on_leave(player, context)` - when leaving this page to go to another
|
|
@ -81,31 +81,6 @@ function sfinv.set(player, context)
|
||||||
local fs = sfinv.get(player, context)
|
local fs = sfinv.get(player, context)
|
||||||
print(fs)
|
print(fs)
|
||||||
player:set_inventory_formspec(fs)
|
player:set_inventory_formspec(fs)
|
||||||
|
|
||||||
--[[local tmp = [ [
|
|
||||||
size[8,8.6]
|
|
||||||
image[4.06,3.4;0.8,0.8;creative_trash_icon.png]
|
|
||||||
list[current_player;main;0,4.7;8,1;]
|
|
||||||
list[current_player;main;0,5.85;8,3;8]
|
|
||||||
list[detached:creative_trash;main;4,3.3;1,1;]
|
|
||||||
tablecolumns[color;text;color;text]
|
|
||||||
tableoptions[background=#00000000;highlight=#00000000;border=false]
|
|
||||||
button[5.4,3.2;0.8,0.9;creative_prev;<]
|
|
||||||
button[7.25,3.2;0.8,0.9;creative_next;>]
|
|
||||||
button[2.1,3.4;0.8,0.5;search;?]
|
|
||||||
button[2.75,3.4;0.8,0.5;clear;X]
|
|
||||||
tooltip[search;Search]
|
|
||||||
tooltip[clear;Reset]
|
|
||||||
listring[current_player;main]
|
|
||||||
] ] ..
|
|
||||||
"field[0.3,3.5;2.2,1;filter;;".. filter .."]"..
|
|
||||||
"listring[detached:creative_".. player_name ..";main]"..
|
|
||||||
"tabheader[0,0;tabs;Crafting,All,Nodes,Tools,Items;".. tostring(tab_id) ..";true;false]"..
|
|
||||||
"list[detached:creative_".. player_name ..";main;0,0;8,3;".. tostring(start_i) .."]"..
|
|
||||||
"table[6.05,3.35;1.15,0.5;pagenum;#FFFF00,".. tostring(pagenum) ..",#FFFFFF,/ ".. tostring(pagemax) .."]"..
|
|
||||||
default.get_hotbar_bg(0,4.7)..
|
|
||||||
default.gui_bg .. default.gui_bg_img .. default.gui_slots
|
|
||||||
]]--
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
|
Loading…
Reference in a new issue