Luanti 5.11.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:247
bool m_is_own_settings
Definition l_settings.h:58
static const luaL_Reg methods[]
Definition l_settings.h:354
static int l_to_table(lua_State *L)
Definition l_settings.cpp:316
static int l_get_np_group(lua_State *L)
Definition l_settings.cpp:139
static int gc_object(lua_State *L)
Definition l_settings.cpp:92
std::string m_filename
Definition l_settings.h:57
static int l_remove(lua_State *L)
Definition l_settings.cpp:231
static int l_set(lua_State *L)
Definition l_settings.cpp:181
static int l_write(lua_State *L)
Definition l_settings.cpp:277
LuaSettings(Settings *settings, const std::string &filename)
Definition l_settings.cpp:59
static int l_get_bool(lua_State *L)
Definition l_settings.cpp:118
static int l_get_flags(lua_State *L)
Definition l_settings.cpp:157
static void create(lua_State *L, Settings *settings, const std::string &filename)
Definition l_settings.cpp:81
static const char className[]
Definition l_settings.h:74
static int create_object(lua_State *L)
Definition l_settings.cpp:340
static int l_set_bool(lua_State *L)
Definition l_settings.cpp:198
~LuaSettings()
Definition l_settings.cpp:74
static int l_get(lua_State *L)
Definition l_settings.cpp:101
static int l_has(lua_State *L)
Definition l_settings.cpp:265
bool m_write_allowed
Definition l_settings.h:59
static int l_set_np_group(lua_State *L)
Definition l_settings.cpp:214
Definition l_base.h:28
Definition settings.h:109
static const char * settings[]
Definition fontengine.cpp:27