]> git.lizzy.rs Git - minetest.git/blob - src/scriptapi.h
Fix world selection a bit (also fixes a main menu segfault)
[minetest.git] / src / scriptapi.h
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef SCRIPTAPI_HEADER
21 #define SCRIPTAPI_HEADER
22
23 #include <string>
24 #include <set>
25 #include <map>
26 #include "irr_v3d.h"
27 #include "irr_v2d.h"
28
29 extern "C" {
30 #include <lua.h>
31 }
32 #include "scriptapi_inventory.h"
33 #include "scriptapi_nodemeta.h"
34 #include "scriptapi_entity.h"
35 #include "scriptapi_object.h"
36 #include "scriptapi_env.h"
37 #include "scriptapi_item.h"
38 #include "scriptapi_node.h"
39
40 #define luamethod(class, name) {#name, class::l_##name}
41
42 class Server;
43
44 void scriptapi_export(lua_State *L, Server *server);
45 bool scriptapi_loadmod(lua_State *L, const std::string &scriptpath,
46                 const std::string &modname);
47
48 // Returns true if script handled message
49 bool scriptapi_on_chat_message(lua_State *L, const std::string &name,
50                 const std::string &message);
51
52 /* server */
53 void scriptapi_on_shutdown(lua_State *L);
54
55 /* misc */
56 void scriptapi_on_newplayer(lua_State *L, ServerActiveObject *player);
57 void scriptapi_on_dieplayer(lua_State *L, ServerActiveObject *player);
58 bool scriptapi_on_respawnplayer(lua_State *L, ServerActiveObject *player);
59 void scriptapi_on_joinplayer(lua_State *L, ServerActiveObject *player);
60 void scriptapi_on_leaveplayer(lua_State *L, ServerActiveObject *player);
61 bool scriptapi_get_auth(lua_State *L, const std::string &playername,
62                 std::string *dst_password, std::set<std::string> *dst_privs);
63 void scriptapi_create_auth(lua_State *L, const std::string &playername,
64                 const std::string &password);
65 bool scriptapi_set_password(lua_State *L, const std::string &playername,
66                 const std::string &password);
67
68 /* player */
69 void scriptapi_on_player_receive_fields(lua_State *L, 
70                 ServerActiveObject *player,
71                 const std::string &formname,
72                 const std::map<std::string, std::string> &fields);
73
74 #endif
75