summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2013-08-23 12:24:11 +0200
committerShadowNinja <shadowninja@minetest.net>2014-01-13 18:11:08 -0500
commit8966c16ad298f94be1f4542afa6b081a1d286eda (patch)
tree00e50224528a7f0bbb46cb05d81177f5e8086c41 /doc
parent2b1eff772524fca8249fd64028e5cbfeabc127a0 (diff)
downloadminetest-8966c16ad298f94be1f4542afa6b081a1d286eda.tar.gz
minetest-8966c16ad298f94be1f4542afa6b081a1d286eda.tar.bz2
minetest-8966c16ad298f94be1f4542afa6b081a1d286eda.zip
Add formspec table
Diffstat (limited to 'doc')
-rw-r--r--doc/lua_api.txt62
-rw-r--r--doc/menu_lua_api.txt40
2 files changed, 85 insertions, 17 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 1fae0ebbf..8bd83995e 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -1011,6 +1011,7 @@ textlist[<X>,<Y>;<W>,<H>;<name>;<listelem 1>,<listelem 2>,...,<listelem n>;<sele
^ if you want a listelement to start with # write ##
^ index to be selected within textlist
^ true/false draw transparent background
+^ see also minetest.explode_textlist_event (main menu: engine.explode_textlist_event)
tabheader[<X>,<Y>;<name>;<caption 1>,<caption 2>,...,<caption n>;<current_tab>;<transparent>;<draw_border>]
^ show a tabHEADER at specific position (ignores formsize)
@@ -1043,6 +1044,57 @@ checkbox[<X>,<Y>;<name>;<label>;<selected>]
^ label to be shown left of checkbox
^ selected (optional) true/false
+table[<X>,<Y>;<W>,<H>;<name>;<cell 1>,<cell 2>,...,<cell n>;<selected idx>]
+^ show scrollable table using options defined by the previous tableoptions[]
+^ displays cells as defined by the previous tablecolumns[]
+^ x and y position the itemlist relative to the top left of the menu
+^ w and h are the size of the itemlist
+^ name fieldname sent to server on row select or doubleclick
+^ cell 1...n cell contents given in row-major order
+^ selected idx: index of row to be selected within table (first row = 1)
+^ see also minetest.explode_table_event (main menu: engine.explode_table_event)
+
+tableoptions[<opt 1>;<opt 2>;...]
+^ sets options for table[]:
+^ color=#RRGGBB
+^^ default text color (HEX-Color), defaults to #FFFFFF
+^ background=#RRGGBB
+^^ table background color (HEX-Color), defaults to #000000
+^ border=<true/false>
+^^ should the table be drawn with a border? (default true)
+^ highlight=#RRGGBB
+^^ highlight background color (HEX-Color), defaults to #466432
+^ highlight_text=#RRGGBB
+^^ highlight text color (HEX-Color), defaults to #FFFFFF
+^ opendepth=<value>
+^^ all subtrees up to depth < value are open (default value = 0)
+^^ only useful when there is a column of type "tree"
+
+tablecolumns[<type 1>,<opt 1a>,<opt 1b>,...;<type 2>,<opt 2a>,<opt 2b>;...]
+^ sets columns for table[]:
+^ types: text, image, color, indent, tree
+^^ text: show cell contents as text
+^^ image: cell contents are an image index, use column options to define images
+^^ color: cell contents are a HEX-Color and define color of following cell
+^^ indent: cell contents are a number and define indentation of following cell
+^^ tree: same as indent, but user can open and close subtrees (treeview-like)
+^ column options:
+^^ align=<value> for "text" and "image": content alignment within cells
+^^ available values: left (default), center, right, inline
+^^ width=<value> for "text" and "image": minimum width in em (default 0)
+^^ for "indent" and "tree": indent width in em (default 1.5)
+^^ padding=<value> padding left of the column, in em (default 0.5)
+^^ exception: defaults to 0 for indent columns
+^^ tooltip=<value> tooltip text (default empty)
+^ "image" column options:
+^^ 0=<value> sets image for image index 0
+^^ 1=<value> sets image for image index 1
+^^ 2=<value> sets image for image index 2
+^^ and so on; defined indices need not be contiguous
+^^ empty or non-numeric cells are treated as 0
+^ "color" column options:
+^^ span=<value> number of following columns to affect (default infinite)
+
Note: do NOT use a element name starting with "key_" those names are reserved to
pass key press events to formspec!
@@ -1346,11 +1398,21 @@ minetest.get_inventory(location) -> InvRef
minetest.create_detached_inventory(name, callbacks) -> InvRef
^ callbacks: See "Detached inventory callbacks"
^ Creates a detached inventory. If it already exists, it is cleared.
+
+Formspec:
minetest.show_formspec(playername, formname, formspec)
^ playername: name of player to show formspec
^ formname: name passed to on_player_receive_fields callbacks
^ should follow "modname:<whatever>" naming convention
^ formspec: formspec to display
+minetest.formspec_escape(string) -> string
+^ escapes characters [ ] \ , ; that can not be used in formspecs
+minetest.explode_table_event(string) -> table
+^ returns e.g. {type="CHG", row=1, column=2}
+^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
+minetest.explode_textlist_event(string) -> table
+^ returns e.g. {type="CHG", index=1}
+^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
Item handling:
minetest.inventorycube(img1, img2, img3)
diff --git a/doc/menu_lua_api.txt b/doc/menu_lua_api.txt
index b50e43887..87e37dd0d 100644
--- a/doc/menu_lua_api.txt
+++ b/doc/menu_lua_api.txt
@@ -89,12 +89,33 @@ engine.sound_play(spec, looped) -> handle
^ looped = bool
engine.sound_stop(handle)
-GUI:
+Formspec:
engine.update_formspec(formspec)
-- engine.set_background(type, texturepath)
+engine.get_table_index(tablename) -> index
+^ can also handle textlists
+engine.formspec_escape(string) -> string
+^ escapes characters [ ] \ , ; that can not be used in formspecs
+engine.explode_table_event(string) -> table
+^ returns e.g. {type="CHG", row=1, column=2}
+^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
+engine.explode_textlist_event(string) -> table
+^ returns e.g. {type="CHG", index=1}
+^ type: "INV" (no row selected), "CHG" (selected) or "DCL" (double-click)
+
+GUI:
+engine.set_background(type, texturepath)
^ type: "background", "overlay", "header" or "footer"
engine.set_clouds(<true/false>)
engine.set_topleft_text(text)
+engine.show_keys_menu()
+engine.file_open_dialog(formname,caption)
+^ shows a file open dialog
+^ formname is base name of dialog response returned in fields
+^ -if dialog was accepted "_accepted"
+^^ will be added to fieldname containing the path
+^ -if dialog was canceled "_cancelled"
+^ will be added to fieldname value is set to formname itself
+^ returns nil or selected file/folder
Games:
engine.get_game(index)
@@ -155,22 +176,7 @@ engine.get_worlds() -> list of worlds (possible in async calls)
engine.create_world(worldname, gameid)
engine.delete_world(index)
-
-UI:
-engine.get_textlist_index(textlistname) -> index
-engine.show_keys_menu()
-engine.file_open_dialog(formname,caption)
-^ shows a file open dialog
-^ formname is base name of dialog response returned in fields
-^ -if dialog was accepted "_accepted"
-^^ will be added to fieldname containing the path
-^ -if dialog was canceled "_cancelled"
-^ will be added to fieldname value is set to formname itself
-^ returns nil or selected file/folder
-
Helpers:
-engine.formspec_escape(string) -> string
-^ escapes characters [ ] \ , ; that can not be used in formspecs
engine.gettext(string) -> string
^ look up the translation of a string in the gettext message catalog
fgettext(string, ...) -> string