From 2124f3b9b6104f54a935e7bab9dbce9ddf41a8e6 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Tue, 6 Mar 2012 05:24:43 +0200 Subject: [PATCH] Add emulator_ready() lua function This function gives a flag telling if emulator has finished booting up. --- include/core/lua-int.hpp | 1 + src/core/lua.cpp | 2 ++ src/lua/core.cpp | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/include/core/lua-int.hpp b/include/core/lua-int.hpp index b05b91b2..a9cef162 100644 --- a/include/core/lua-int.hpp +++ b/include/core/lua-int.hpp @@ -14,6 +14,7 @@ bool get_boolean_argument(lua_State* LS, unsigned argindex, const char* fname); void push_keygroup_parameters(lua_State* LS, const struct keygroup::parameters& p); extern lua_render_context* lua_render_ctx; extern controller_frame* lua_input_controllerdata; +extern bool lua_booted_flag; template T get_numeric_argument(lua_State* LS, unsigned argindex, const char* fname) diff --git a/src/core/lua.cpp b/src/core/lua.cpp index a919e12a..d8973e7d 100644 --- a/src/core/lua.cpp +++ b/src/core/lua.cpp @@ -196,6 +196,7 @@ void push_keygroup_parameters(lua_State* LS, const struct keygroup::parameters& lua_render_context* lua_render_ctx = NULL; controller_frame* lua_input_controllerdata = NULL; +bool lua_booted_flag = false; namespace { @@ -420,6 +421,7 @@ void lua_callback_do_readwrite() throw() void lua_callback_startup() throw() { + lua_booted_flag = true; if(!callback_exists("on_startup")) return; run_lua_cb(0); diff --git a/src/lua/core.cpp b/src/lua/core.cpp index c2d3861a..3404f3b8 100644 --- a/src/lua/core.cpp +++ b/src/lua/core.cpp @@ -45,4 +45,9 @@ namespace command::invokeC(text); return 0; }); + + function_ptr_luafun lua_booted("emulator_ready", [](lua_State* LS, const std::string& fname) -> int { + lua_pushboolean(LS, lua_booted_flag ? 1 : 0); + return 1; + }); }