|
|
|
@ -5,6 +5,8 @@
|
|
|
|
|
#include <components/lua/luastate.hpp>
|
|
|
|
|
#include <components/queries/luabindings.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
#include "../mwbase/statemanager.hpp"
|
|
|
|
|
#include "../mwworld/inventorystore.hpp"
|
|
|
|
|
|
|
|
|
|
#include "eventqueue.hpp"
|
|
|
|
@ -31,7 +33,13 @@ namespace MWLua
|
|
|
|
|
{
|
|
|
|
|
auto* lua = context.mLua;
|
|
|
|
|
sol::table api(lua->sol(), sol::create);
|
|
|
|
|
api["API_REVISION"] = 2;
|
|
|
|
|
api["API_REVISION"] = 3;
|
|
|
|
|
api["quit"] = [lua]()
|
|
|
|
|
{
|
|
|
|
|
std::string traceback = lua->sol()["debug"]["traceback"]().get<std::string>();
|
|
|
|
|
Log(Debug::Warning) << "Quit requested by a Lua script.\n" << traceback;
|
|
|
|
|
MWBase::Environment::get().getStateManager()->requestQuit();
|
|
|
|
|
};
|
|
|
|
|
api["sendGlobalEvent"] = [context](std::string eventName, const sol::object& eventData)
|
|
|
|
|
{
|
|
|
|
|
context.mGlobalEventQueue->push_back({std::move(eventName), LuaUtil::serialize(eventData, context.mSerializer)});
|
|
|
|
|