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 // get_pos(self, key) -> vector or nil
33 static int l_get_pos(lua_State *L);
34
35 // set(self, key, value)
36 static int l_set(lua_State *L);
37
38 // set_bool(self, key, value)
39 static int l_set_bool(lua_State *L);
40
41 // set_np_group(self, key, value)
42 static int l_set_np_group(lua_State *L);
43
44 // set_pos(self, key, value)
45 static int l_set_pos(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 // has(self, key) -> boolean
54 static int l_has(lua_State *L);
55
56 // write(self) -> success
57 static int l_write(lua_State *L);
58
59 // to_table(self) -> {[key1]=value1,...}
60 static int l_to_table(lua_State *L);
61
62 Settings *m_settings = nullptr;
63 std::string m_filename;
64 bool m_is_own_settings = false;
65 bool m_write_allowed = true;
66
67public:
68 LuaSettings(Settings *settings, const std::string &filename);
69 LuaSettings(const std::string &filename, bool write_allowed);
71
72 static void create(lua_State *L, Settings *settings, const std::string &filename);
73
74 // LuaSettings(filename)
75 // Creates a LuaSettings and leaves it on top of the stack
76 static int create_object(lua_State *L);
77
78 static void Register(lua_State *L);
79
80 static const char className[];
81};
Definition l_settings.h:13
static int l_set_pos(lua_State *L)
Definition l_settings.cpp:247
Settings * m_settings
Definition l_settings.h:62
static int l_get_names(lua_State *L)
Definition l_settings.cpp:279
bool m_is_own_settings
Definition l_settings.h:64
static const luaL_Reg methods[]
Definition l_settings.h:386
static int l_to_table(lua_State *L)
Definition l_settings.cpp:348
static int l_get_np_group(lua_State *L)
Definition l_settings.cpp:140
static int gc_object(lua_State *L)
Definition l_settings.cpp:93
std::string m_filename
Definition l_settings.h:63
static int l_remove(lua_State *L)
Definition l_settings.cpp:263
static int l_set(lua_State *L)
Definition l_settings.cpp:197
static int l_write(lua_State *L)
Definition l_settings.cpp:309
LuaSettings(Settings *settings, const std::string &filename)
Definition l_settings.cpp:60
static int l_get_bool(lua_State *L)
Definition l_settings.cpp:119
static int l_get_pos(lua_State *L)
Definition l_settings.cpp:182
static int l_get_flags(lua_State *L)
Definition l_settings.cpp:158
static void create(lua_State *L, Settings *settings, const std::string &filename)
Definition l_settings.cpp:82
static const char className[]
Definition l_settings.h:80
static int create_object(lua_State *L)
Definition l_settings.cpp:372
static int l_set_bool(lua_State *L)
Definition l_settings.cpp:214
~LuaSettings()
Definition l_settings.cpp:75
static int l_get(lua_State *L)
Definition l_settings.cpp:102
static int l_has(lua_State *L)
Definition l_settings.cpp:297
bool m_write_allowed
Definition l_settings.h:65
static int l_set_np_group(lua_State *L)
Definition l_settings.cpp:230
Definition l_base.h:28
Definition settings.h:109
static const char * settings[]
Definition fontengine.cpp:27