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