mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Merge branch 'onactivate' into 'master'
(Lua) onActivate handler in global scripts See merge request OpenMW/openmw!2864
This commit is contained in:
commit
be413fb0c7
@ -56,6 +56,7 @@ namespace MWLua
|
||||
MWWorld::Ptr actor = getPtr(event.mActor);
|
||||
if (actor.isEmpty() || obj.isEmpty())
|
||||
return;
|
||||
mGlobalScripts.onActivate(GObject(obj), GObject(actor));
|
||||
if (auto* scripts = getLocalScripts(obj))
|
||||
scripts->onActivated(LObject(actor));
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace MWLua
|
||||
: LuaUtil::ScriptsContainer(lua, "Global")
|
||||
{
|
||||
registerEngineHandlers({ &mObjectActiveHandlers, &mActorActiveHandlers, &mItemActiveHandlers,
|
||||
&mNewGameHandlers, &mPlayerAddedHandlers });
|
||||
&mNewGameHandlers, &mPlayerAddedHandlers, &mOnActivateHandlers });
|
||||
}
|
||||
|
||||
void newGameStarted() { callEngineHandlers(mNewGameHandlers); }
|
||||
@ -28,6 +28,10 @@ namespace MWLua
|
||||
void actorActive(const GObject& obj) { callEngineHandlers(mActorActiveHandlers, obj); }
|
||||
void itemActive(const GObject& obj) { callEngineHandlers(mItemActiveHandlers, obj); }
|
||||
void playerAdded(const GObject& obj) { callEngineHandlers(mPlayerAddedHandlers, obj); }
|
||||
void onActivate(const GObject& obj, const GObject& actor)
|
||||
{
|
||||
callEngineHandlers(mOnActivateHandlers, obj, actor);
|
||||
}
|
||||
|
||||
private:
|
||||
EngineHandlerList mObjectActiveHandlers{ "onObjectActive" };
|
||||
@ -35,6 +39,7 @@ namespace MWLua
|
||||
EngineHandlerList mItemActiveHandlers{ "onItemActive" };
|
||||
EngineHandlerList mNewGameHandlers{ "onNewGame" };
|
||||
EngineHandlerList mPlayerAddedHandlers{ "onPlayerAdded" };
|
||||
EngineHandlerList mOnActivateHandlers{ "onActivate" };
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace MWLua
|
||||
{
|
||||
auto* lua = context.mLua;
|
||||
sol::table api(lua->sol(), sol::create);
|
||||
api["API_REVISION"] = 33;
|
||||
api["API_REVISION"] = 34;
|
||||
api["quit"] = [lua]() {
|
||||
Log(Debug::Warning) << "Quit requested by a Lua script.\n" << lua->debugTraceback();
|
||||
MWBase::Environment::get().getStateManager()->requestQuit();
|
||||
|
@ -37,7 +37,7 @@ Engine handler is a function defined by a script, that can be called by the engi
|
||||
:widths: 20 80
|
||||
|
||||
* - onNewGame()
|
||||
- New game is started
|
||||
- New game is started.
|
||||
* - onPlayerAdded(player)
|
||||
- Player added to the game world. The argument is a `Game object`.
|
||||
* - onObjectActive(object)
|
||||
@ -47,6 +47,8 @@ Engine handler is a function defined by a script, that can be called by the engi
|
||||
* - onItemActive(item)
|
||||
- | Item (Weapon, Potion, ...) becomes active in a cell.
|
||||
| Does not apply to items in inventories or containers.
|
||||
* - onActivate(object, actor)
|
||||
- Object is activated by an actor.
|
||||
|
||||
**Only for local scripts**
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user