1 Minetest Lua Mainmenu API Reference 0.4.6
2 ========================================
6 The main menu is defined as a formspec by Lua in builtin/mainmenu.lua
7 Description of formspec language to show your menu is in lua_api.txt
11 engine.buttonhandler(fields): called when a button is pressed.
12 ^ fields = {name1 = value1, name2 = value2, ...}
13 engine.event_handler(event)
14 ^ event: "MenuQuit", "KeyEnter", "ExitButton" or "EditBoxEnter"
18 The "gamedata" table is read when calling engine.start(). It should contain:
21 password = <password>,
22 address = <IP/adress>,
24 selected_world = <index>, -- 0 for client mode
25 singleplayer = <true/false>,
34 engine.get_scriptdir()
35 ^ returns directory of script
37 ^ returns path to global modpath
38 engine.get_modstore_details(modid)
39 ^ modid numeric id of mod in modstore
41 id = <numeric id of mod in modstore>,
42 title = <human readable title>,
43 basename = <basename for mod>,
44 description = <description of mod>,
45 author = <author of mod>,
46 download_url= <best match download url>,
47 license = <short description of license>,
48 rating = <float value of current rating>
50 engine.get_modstore_list()
53 id = <numeric id of mod in modstore>,
54 title = <human readable title>,
55 basename = <basename for mod>
59 ^ returns path to global gamepath
60 engine.get_dirlist(path,onlydirs)
61 ^ path to get subdirs from
62 ^ onlydirs should result contain only dirs?
63 ^ returns list of folders within path
64 engine.create_dir(absolute_path)
65 ^ absolute_path to directory to create (needs to be absolute)
67 engine.delete_dir(absolute_path)
68 ^ absolute_path to directory to delete (needs to be absolute)
70 engine.copy_dir(source,destination,keep_soure)
73 ^ keep_source DEFAULT true --> if set to false source is deleted after copying
75 engine.extract_zip(zipfile,destination) [unzip within path required]
77 ^ destination folder to extract to
79 engine.download_file(url,target)
84 ^ returns current minetest version
87 engine.update_formspec(formspec)
88 - engine.set_background(type, texturepath)
89 ^ type: "background", "overlay", "header" or "footer"
90 engine.set_clouds(<true/false>)
91 engine.set_topleft_text(text)
94 engine.get_game(index)
97 path = <full path to game>,
98 gamemods_path = <path>,
99 name = <name of game>,
100 menuicon_path = <full path to menuicon>,
102 addon_mods_paths = {[1] = <path>,},
104 engine.get_games() -> table of all games in upper format
107 engine.get_favorites(location) -> list of favorites
108 ^ location: "local" or "online"
111 clients = <number of clients/nil>,
112 clients_max = <maximum number of clients/nil>,
113 version = <server version/nil>,
114 password = <true/nil>,
115 creative = <true/nil>,
118 description = <server description/nil>,
119 name = <server name/nil>,
120 address = <address of server/nil>,
124 engine.delete_favorite(id, location) -> success
127 engine.setting_set(name, value)
128 engine.setting_get(name) -> string or nil
129 engine.setting_setbool(name, value)
130 engine.setting_getbool(name) -> bool or nil
133 engine.get_worlds() -> list of worlds
136 path = <full path to world>,
137 name = <name of world>,
138 gameid = <gameid of world>,
141 engine.create_world(worldname, gameid)
142 engine.delete_world(index)
146 engine.get_textlist_index(textlistname) -> index
147 engine.show_keys_menu()
148 engine.file_open_dialog(formname,caption)
149 ^ shows a file open dialog
150 ^ formname is base name of dialog response returned in fields
151 ^ -if dialog was accepted "_accepted"
152 ^^ will be added to fieldname containing the path
153 ^ -if dialog was canceled "_cancelled"
154 ^ will be added to fieldname value is set to formname itself
155 ^ returns nil or selected file/folder
159 ^ Return object serialized as a string
160 string:split(separator)
161 ^ eg. string:split("a,b", ",") == {"a","b"}
163 ^ eg. string.trim("\n \t\tfoo bar\t ") == "foo bar"