1 /* 2 script/lua_api/l_settings.h 3 Copyright (C) 2013 PilzAdam <pilzadam@minetest.net> 4 */ 5 6 /* 7 This file is part of Freeminer. 8 9 Freeminer is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Freeminer is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Freeminer. If not, see <http://www.gnu.org/licenses/>. 21 */ 22 23 #ifndef L_SETTINGS_H_ 24 #define L_SETTINGS_H_ 25 26 #include "lua_api/l_base.h" 27 28 class Settings; 29 30 class LuaSettings : public ModApiBase { 31 private: 32 static const char className[]; 33 static const luaL_reg methods[]; 34 35 // garbage collector 36 static int gc_object(lua_State* L); 37 38 // get(self, key) -> value 39 static int l_get(lua_State* L); 40 41 // get_bool(self, key) -> boolean 42 static int l_get_bool(lua_State* L); 43 44 // set(self, key, value) 45 static int l_set(lua_State* L); 46 47 // remove(self, key) -> success 48 static int l_remove(lua_State* L); 49 50 // get_names(self) -> {key1, ...} 51 static int l_get_names(lua_State* L); 52 53 // write(self) -> success 54 static int l_write(lua_State* L); 55 56 // to_table(self) -> {[key1]=value1,...} 57 static int l_to_table(lua_State* L); 58 59 Settings* m_settings; 60 std::string m_filename; 61 62 public: 63 LuaSettings(const char* filename); 64 ~LuaSettings(); 65 66 // LuaSettings(filename) 67 // Creates an LuaSettings and leaves it on top of stack 68 static int create_object(lua_State* L); 69 70 static LuaSettings* checkobject(lua_State* L, int narg); 71 72 static void Register(lua_State* L); 73 74 }; 75 76 #endif 77