fix: lua coroutines support
This commit is contained in:
@@ -16,29 +16,28 @@ namespace scripting {
|
||||
extern lua::LuaState* state;
|
||||
extern Hud* hud;
|
||||
}
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
static int l_keycode(lua_State* L) {
|
||||
const char* name = state->requireString(1);
|
||||
auto name = lua::require_string(L, 1);
|
||||
lua_pushinteger(L, static_cast<int>(input_util::keycode_from(name)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_mousecode(lua_State* L) {
|
||||
const char* name = state->requireString(1);
|
||||
auto name = lua::require_string(L, 1);
|
||||
lua_pushinteger(L, static_cast<int>(input_util::mousecode_from(name)));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_add_callback(lua_State*) {
|
||||
auto bindname = state->requireString(1);
|
||||
static int l_add_callback(lua_State* L) {
|
||||
auto bindname = lua::require_string(L, 1);
|
||||
const auto& bind = Events::bindings.find(bindname);
|
||||
if (bind == Events::bindings.end()) {
|
||||
throw std::runtime_error("unknown binding "+util::quote(bindname));
|
||||
}
|
||||
state->pushvalue(2);
|
||||
runnable actual_callback = state->createRunnable();
|
||||
lua_pushvalue(L, 2);
|
||||
runnable actual_callback = state->createRunnable(L);
|
||||
runnable callback = [=]() {
|
||||
if (!scripting::engine->getGUI()->isFocusCaught()) {
|
||||
actual_callback();
|
||||
|
||||
Reference in New Issue
Block a user