More quality of life
This commit is contained in:
@@ -52,7 +52,10 @@ void Lua::Update(double delta) {
|
||||
if (HasHook("update")) {
|
||||
lua_getglobal(L, "update");
|
||||
lua_pushnumber(L, delta);
|
||||
lua_call(L, 1, 0);
|
||||
int err = lua_pcall(L, 1, 0, 0);
|
||||
if (err != LUA_OK) {
|
||||
Error();
|
||||
}
|
||||
}
|
||||
#endif // LUA_SCRIPTING
|
||||
}
|
||||
@@ -89,7 +92,10 @@ void Lua::LuaKeyHandler(Window *window, int key, int code, int action, int mods)
|
||||
lua_pushinteger(L, code);
|
||||
lua_pushinteger(L, action);
|
||||
lua_pushinteger(L, mods);
|
||||
lua_call(L, 4, 0);
|
||||
int err = lua_pcall(L, 4, 0, 0);
|
||||
if (err != LUA_OK) {
|
||||
Error();
|
||||
}
|
||||
#endif // LUA_SCRIPTING
|
||||
}
|
||||
|
||||
@@ -101,6 +107,9 @@ void Lua::LuaMousePositionHandler(Window *window, double xpos, double ypos, doub
|
||||
lua_pushnumber(L, ypos);
|
||||
lua_pushnumber(L, relx);
|
||||
lua_pushnumber(L, rely);
|
||||
lua_call(L, 4, 0);
|
||||
int err = lua_pcall(L, 4, 0, 1);
|
||||
if (err != LUA_OK) {
|
||||
Error();
|
||||
}
|
||||
#endif // LUA_SCRIPTING
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
void Initialize();
|
||||
void Update(double delta);
|
||||
void Close();
|
||||
void Error();
|
||||
static void Error();
|
||||
bool HasHook(const char *name);
|
||||
private:
|
||||
#ifdef LUA_SCRIPTING
|
||||
|
||||
@@ -8,7 +8,6 @@ public:
|
||||
virtual void Initialize() = 0;
|
||||
virtual void Update(double delta) = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void Error() = 0;
|
||||
virtual bool HasHook(const char * name) = 0;
|
||||
static ScriptingLanguage *GetCurrentLanguage();
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user