core.get_setting test

This commit is contained in:
MihailRis
2024-04-01 18:08:09 +03:00
parent 75a7b89fc8
commit f8ec75b121
5 changed files with 20 additions and 8 deletions
+2 -2
View File
@@ -280,9 +280,9 @@ dynamic::Value lua::LuaState::tovalue(int idx) {
switch (type) {
case LUA_TNIL:
case LUA_TNONE:
return dynamic::Value(valtype::none, 0);
return dynamic::Value(valtype::none, (integer_t)0);
case LUA_TBOOLEAN:
return dynamic::Value::of(lua_toboolean(L, idx) == 1);
return dynamic::Value::boolean(lua_toboolean(L, idx) == 1);
case LUA_TNUMBER: {
auto number = lua_tonumber(L, idx);
auto integer = lua_tointeger(L, idx);
+12
View File
@@ -13,6 +13,10 @@
#include <vector>
#include <memory>
namespace scripting {
extern lua::LuaState* state;
}
static int l_get_worlds_list(lua_State* L) {
auto paths = scripting::engine->getPaths();
auto worlds = paths->scanForWorlds();
@@ -66,6 +70,13 @@ static int l_get_bindings(lua_State* L) {
return 1;
}
static int l_get_setting(lua_State* L) {
auto name = lua_tostring(L, 1);
const auto value = scripting::engine->getSettingsHandler().getValue(name);
scripting::state->pushvalue(value);
return 1;
}
static int l_quit(lua_State* L) {
Window::setShouldClose(true);
return 0;
@@ -77,6 +88,7 @@ const luaL_Reg corelib [] = {
{"close_world", lua_wrap_errors<l_close_world>},
{"delete_world", lua_wrap_errors<l_delete_world>},
{"get_bindings", lua_wrap_errors<l_get_bindings>},
{"get_setting", lua_wrap_errors<l_get_setting>},
{"quit", lua_wrap_errors<l_quit>},
{NULL, NULL}
};