file.find fix + input.mousecode
This commit is contained in:
@@ -17,8 +17,12 @@ static fs::path resolve_path(lua_State*, const std::string& path) {
|
|||||||
|
|
||||||
static int l_file_find(lua_State* L) {
|
static int l_file_find(lua_State* L) {
|
||||||
std::string path = lua_tostring(L, 1);
|
std::string path = lua_tostring(L, 1);
|
||||||
lua_pushstring(L, scripting::engine->getResPaths()->findRaw(path).c_str());
|
try {
|
||||||
return 1;
|
lua_pushstring(L, scripting::engine->getResPaths()->findRaw(path).c_str());
|
||||||
|
return 1;
|
||||||
|
} catch (const std::runtime_error& err) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int l_file_resolve(lua_State* L) {
|
static int l_file_resolve(lua_State* L) {
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ static int l_keycode(lua_State* L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_mousecode(lua_State* L) {
|
||||||
|
const char* name = state->requireString(1);
|
||||||
|
lua_pushinteger(L, static_cast<int>(input_util::mousecode_from(name)));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_add_callback(lua_State* L) {
|
static int l_add_callback(lua_State* L) {
|
||||||
auto bindname = state->requireString(1);
|
auto bindname = state->requireString(1);
|
||||||
const auto& bind = Events::bindings.find(bindname);
|
const auto& bind = Events::bindings.find(bindname);
|
||||||
@@ -51,6 +57,7 @@ static int l_get_mouse_pos(lua_State* L) {
|
|||||||
|
|
||||||
const luaL_Reg inputlib [] = {
|
const luaL_Reg inputlib [] = {
|
||||||
{"keycode", lua_wrap_errors<l_keycode>},
|
{"keycode", lua_wrap_errors<l_keycode>},
|
||||||
|
{"mousecode", lua_wrap_errors<l_mousecode>},
|
||||||
{"add_callback", lua_wrap_errors<l_add_callback>},
|
{"add_callback", lua_wrap_errors<l_add_callback>},
|
||||||
{"get_mouse_pos", lua_wrap_errors<l_get_mouse_pos>},
|
{"get_mouse_pos", lua_wrap_errors<l_get_mouse_pos>},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
|
|||||||
Reference in New Issue
Block a user