]> git.lizzy.rs Git - minetest.git/blob - src/scriptapi.h
split scriptapi.cpp
[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
27 extern "C" {
28 #include <lua.h>
29 }
30 #include "scriptapi_inventory.h"
31 #include "scriptapi_nodemeta.h"
32 #include "scriptapi_entity.h"
33 #include "scriptapi_object.h"
34 #include "scriptapi_env.h"
35 #include "scriptapi_item.h"
36 #include "scriptapi_node.h"
37
38 #define luamethod(class, name) {#name, class::l_##name}
39
40 class Server;
41
42 void scriptapi_export(lua_State *L, Server *server);
43 bool scriptapi_loadmod(lua_State *L, const std::string &scriptpath,
44                 const std::string &modname);
45
46 // Returns true if script handled message
47 bool scriptapi_on_chat_message(lua_State *L, const std::string &name,
48                 const std::string &message);
49
50 /* server */
51 void scriptapi_on_shutdown(lua_State *L);
52
53 /* misc */
54 void scriptapi_on_newplayer(lua_State *L, ServerActiveObject *player);
55 void scriptapi_on_dieplayer(lua_State *L, ServerActiveObject *player);
56 bool scriptapi_on_respawnplayer(lua_State *L, ServerActiveObject *player);
57 void scriptapi_on_joinplayer(lua_State *L, ServerActiveObject *player);
58 void scriptapi_on_leaveplayer(lua_State *L, ServerActiveObject *player);
59 bool scriptapi_get_auth(lua_State *L, const std::string &playername,
60                 std::string *dst_password, std::set<std::string> *dst_privs);
61 void scriptapi_create_auth(lua_State *L, const std::string &playername,
62                 const std::string &password);
63 bool scriptapi_set_password(lua_State *L, const std::string &playername,
64                 const std::string &password);
65
66 /* player */
67 void scriptapi_on_player_receive_fields(lua_State *L, 
68                 ServerActiveObject *player,
69                 const std::string &formname,
70                 const std::map<std::string, std::string> &fields);
71
72 #endif
73