2 #include "settings.hpp"
6 class lua_settings_set
: public lua_function
9 lua_settings_set() : lua_function("settings.set") {}
10 int invoke(lua_State
* LS
)
12 std::string name
= get_string_argument(LS
, 1, fname
.c_str());
13 std::string value
= get_string_argument(LS
, 2, fname
.c_str());
15 setting::set(name
, value
);
16 } catch(std::exception
& e
) {
18 lua_pushstring(LS
, e
.what());
21 lua_pushboolean(LS
, 1);
26 class lua_settings_get
: public lua_function
29 lua_settings_get() : lua_function("settings.get") {}
30 int invoke(lua_State
* LS
)
32 std::string name
= get_string_argument(LS
, 1, fname
.c_str());
34 if(!setting::is_set(name
))
35 lua_pushboolean(LS
, 0);
37 std::string value
= setting::get(name
);
38 lua_pushlstring(LS
, value
.c_str(), value
.length());
41 } catch(std::exception
& e
) {
43 lua_pushstring(LS
, e
.what());
49 class lua_settings_blank
: public lua_function
52 lua_settings_blank() : lua_function("settings.blank") {}
53 int invoke(lua_State
* LS
)
55 std::string name
= get_string_argument(LS
, 1, fname
.c_str());
58 lua_pushboolean(LS
, 1);
60 } catch(std::exception
& e
) {
62 lua_pushstring(LS
, e
.what());
68 class lua_settings_is_set
: public lua_function
71 lua_settings_is_set() : lua_function("settings.is_set") {}
72 int invoke(lua_State
* LS
)
74 std::string name
= get_string_argument(LS
, 1, fname
.c_str());
76 bool x
= setting::is_set(name
);
77 lua_pushboolean(LS
, x
? 1 : 0);
79 } catch(std::exception
& e
) {
81 lua_pushstring(LS
, e
.what());