Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
l_settings.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 PilzAdam <pilzadam@minetest.net>
4
5#pragma once
6
7#include "common/c_content.h"
8#include "lua_api/l_base.h"
9
10class Settings;
11
12class LuaSettings : public ModApiBase
13{
14private:
15 static const luaL_Reg methods[];
16
17 // garbage collector
18 static int gc_object(lua_State *L);
19
20 // get(self, key) -> value
21 static int l_get(lua_State *L);
22
23 // get_bool(self, key) -> boolean
24 static int l_get_bool(lua_State *L);
25
26 // get_np_group(self, key) -> noiseparam
27 static int l_get_np_group(lua_State *L);
28
29 // get_flags(self, key) -> key/value table
30 static int l_get_flags(lua_State *L);
31
32 // set(self, key, value)
33 static int l_set(lua_State *L);
34
35 // set_bool(self, key, value)
36 static int l_set_bool(lua_State *L);
37
38 // set_np_group(self, key, value)
39 static int l_set_np_group(lua_State *L);
40
41 // remove(self, key) -> success
42 static int l_remove(lua_State *L);
43
44 // get_names(self) -> {key1, ...}
45 static int l_get_names(lua_State *L);
46
47 // has(self, key) -> boolean
48 static int l_has(lua_State *L);
49
50 // write(self) -> success
51 static int l_write(lua_State *L);
52
53 // to_table(self) -> {[key1]=value1,...}
54 static int l_to_table(lua_State *L);
55
56 Settings *m_settings = nullptr;
57 std::string m_filename;
58 bool m_is_own_settings = false;
59 bool m_write_allowed = true;
60
61public:
62 LuaSettings(Settings *settings, const std::string &filename);
63 LuaSettings(const std::string &filename, bool write_allowed);
65
66 static void create(lua_State *L, Settings *settings, const std::string &filename);
67
68 // LuaSettings(filename)
69 // Creates a LuaSettings and leaves it on top of the stack
70 static int create_object(lua_State *L);
71
72 static void Register(lua_State *L);
73
74 static const char className[];
75};
Definition l_settings.h:13
Settings * m_settings
Definition l_settings.h:56
static int l_get_names(lua_State *L)
Definition l_settings.cpp:246
bool m_is_own_settings
Definition l_settings.h:58
static const luaL_Reg methods[]
Definition l_settings.h:353
static int l_to_table(lua_State *L)
Definition l_settings.cpp:315
static int l_get_np_group(lua_State *L)
Definition l_settings.cpp:138
static int gc_object(lua_State *L)
Definition l_settings.cpp:91
std::string m_filename
Definition l_settings.h:57
static int l_remove(lua_State *L)
Definition l_settings.cpp:230
static int l_set(lua_State *L)
Definition l_settings.cpp:180
static int l_write(lua_State *L)
Definition l_settings.cpp:276
LuaSettings(Settings *settings, const std::string &filename)
Definition l_settings.cpp:58
static int l_get_bool(lua_State *L)
Definition l_settings.cpp:117
static int l_get_flags(lua_State *L)
Definition l_settings.cpp:156
static void create(lua_State *L, Settings *settings, const std::string &filename)
Definition l_settings.cpp:80
static const char className[]
Definition l_settings.h:74
static int create_object(lua_State *L)
Definition l_settings.cpp:339
static int l_set_bool(lua_State *L)
Definition l_settings.cpp:197
~LuaSettings()
Definition l_settings.cpp:73
static int l_get(lua_State *L)
Definition l_settings.cpp:100
static int l_has(lua_State *L)
Definition l_settings.cpp:264
bool m_write_allowed
Definition l_settings.h:59
static int l_set_np_group(lua_State *L)
Definition l_settings.cpp:213
Definition l_base.h:28
Definition settings.h:109
static const char * settings[]
Definition fontengine.cpp:27