]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/cpp_api/scriptapi.h
Fix my name.
[dragonfireclient.git] / src / script / cpp_api / 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_H_
21 #define SCRIPTAPI_H_
22
23 #include <map>
24 #include <set>
25 #include <vector>
26
27 #include "cpp_api/s_base.h"
28 #include "cpp_api/s_player.h"
29 #include "cpp_api/s_env.h"
30 #include "cpp_api/s_node.h"
31 #include "cpp_api/s_inventory.h"
32 #include "cpp_api/s_entity.h"
33
34 class ModApiBase;
35
36 /*****************************************************************************/
37 /* Scriptapi <-> Core Interface                                              */
38 /*****************************************************************************/
39
40 class ScriptApi
41                 : virtual public ScriptApiBase,
42                   public ScriptApiPlayer,
43                   public ScriptApiEnv,
44                   public ScriptApiNode,
45                   public ScriptApiDetached,
46                   public ScriptApiEntity
47 {
48 public:
49         ScriptApi();
50         ScriptApi(Server* server);
51         ~ScriptApi();
52
53         // Returns true if script handled message
54         bool on_chat_message(const std::string &name, const std::string &message);
55
56         /* server */
57         void on_shutdown();
58
59         /* auth */
60         bool getAuth(const std::string &playername,
61                         std::string *dst_password, std::set<std::string> *dst_privs);
62         void createAuth(const std::string &playername,
63                         const std::string &password);
64         bool setPassword(const std::string &playername,
65                         const std::string &password);
66
67         /** register a lua api module to scriptapi */
68         static bool registerModApiModule(ModApiBase* prototype);
69         /** load a mod **/
70         bool loadMod(const std::string &scriptpath,const std::string &modname);
71
72 private:
73         void getAuthHandler();
74         void readPrivileges(int index,std::set<std::string> &result);
75
76         bool scriptLoad(const char *path);
77
78         static std::vector<ModApiBase*>* m_mod_api_modules;
79
80 };
81
82 #endif /* SCRIPTAPI_H_ */