1 #include "lua/internal.hpp"
2 #include "core/settings.hpp"
6 function_ptr_luafun
ss("settings.set", [](lua_State
* LS
, const std::string
& fname
) -> int {
7 std::string name
= get_string_argument(LS
, 1, fname
.c_str());
8 std::string value
= get_string_argument(LS
, 2, fname
.c_str());
10 setting::set(name
, value
);
11 } catch(std::exception
& e
) {
13 lua_pushstring(LS
, e
.what());
16 lua_pushboolean(LS
, 1);
20 function_ptr_luafun
sg("settings.get", [](lua_State
* LS
, const std::string
& fname
) -> int {
21 std::string name
= get_string_argument(LS
, 1, fname
.c_str());
23 if(!setting::is_set(name
))
24 lua_pushboolean(LS
, 0);
26 std::string value
= setting::get(name
);
27 lua_pushlstring(LS
, value
.c_str(), value
.length());
30 } catch(std::exception
& e
) {
32 lua_pushstring(LS
, e
.what());
37 function_ptr_luafun
sb("settings.blank", [](lua_State
* LS
, const std::string
& fname
) -> int {
38 std::string name
= get_string_argument(LS
, 1, fname
.c_str());
41 lua_pushboolean(LS
, 1);
43 } catch(std::exception
& e
) {
45 lua_pushstring(LS
, e
.what());
50 function_ptr_luafun
si("settings.is_set", [](lua_State
* LS
, const std::string
& fname
) -> int {
51 std::string name
= get_string_argument(LS
, 1, fname
.c_str());
53 bool x
= setting::is_set(name
);
54 lua_pushboolean(LS
, x
? 1 : 0);
56 } catch(std::exception
& e
) {
58 lua_pushstring(LS
, e
.what());