From 64b106c13e18c33be0f2b0de532054e0ed3f731d Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 13 Dec 2023 16:10:08 +1100 Subject: add a cool lua repl --- src/lua/lua_thread.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/lua/lua_thread.cpp') diff --git a/src/lua/lua_thread.cpp b/src/lua/lua_thread.cpp index 4704c3e8..dc588144 100644 --- a/src/lua/lua_thread.cpp +++ b/src/lua/lua_thread.cpp @@ -114,6 +114,15 @@ auto LuaThread::RunScript(const std::string& path) -> bool { return true; } +auto LuaThread::RunString(const std::string& script) -> bool { + int res = luaL_loadstring(state_, script.c_str()); + if (res != LUA_OK) { + return false; + } + CallProtected(state_, 0, 0); + return true; +} + static int msg_handler(lua_State* L) { if (!lua_isstring(L, 1)) { return 1; -- cgit v1.2.3