diff options
Diffstat (limited to 'indra/newview/llluamanager.cpp')
-rw-r--r-- | indra/newview/llluamanager.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp index 931faadf4b..483075583c 100644 --- a/indra/newview/llluamanager.cpp +++ b/indra/newview/llluamanager.cpp @@ -32,6 +32,7 @@ #include "llappearancemgr.h" #include "llcallbacklist.h" #include "llerror.h" +#include "lleventcoro.h" #include "llevents.h" #include "llfloaterreg.h" #include "llfloaterimnearbychat.h" @@ -274,6 +275,7 @@ lua_function(print_debug) return 0; } +// also used for print(); see LuaState constructor lua_function(print_info) { luaL_where(L, 1); @@ -677,6 +679,29 @@ lua_function(listen_events) return 2; } +lua_function(await_event) +{ + // await_event(pumpname [, timeout [, value to return if timeout (default nil)]]) + auto pumpname{ lua_tostdstring(L, 1) }; + LLSD result; + if (lua_gettop(L) > 1) + { + auto timeout{ lua_tonumber(L, 2) }; + // with no 3rd argument, should be LLSD() + auto dftval{ lua_tollsd(L, 3) }; + lua_pop(L, lua_gettop(L)); + result = llcoro::suspendUntilEventOnWithTimeout(pumpname, timeout, dftval); + } + else + { + // no timeout + lua_pop(L, 1); + result = llcoro::suspendUntilEventOn(pumpname); + } + lua_pushllsd(L, result); + return 1; +} + /** * RAII class to manage the lifespan of a lua_State */ |