mirror of
https://github.com/OpenMW/openmw.git
synced 2026-01-07 13:30:57 +00:00
FEAT: AddTopic in Lua, close #8334
This commit is contained in:
parent
f5de0d1c40
commit
4150f5fad6
1 changed files with 13 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "types.hpp"
|
||||
|
||||
#include <apps/openmw/mwbase/dialoguemanager.hpp>
|
||||
#include <components/esm3/loadbsgn.hpp>
|
||||
#include <components/esm3/loadfact.hpp>
|
||||
|
||||
|
|
@ -195,6 +196,18 @@ namespace MWLua
|
|||
throw std::runtime_error("Only player and global scripts can toggle teleportation.");
|
||||
MWBase::Environment::get().getWorld()->enableTeleporting(state);
|
||||
};
|
||||
player["addTopic"] = [](const Object& player, std::string topicId) {
|
||||
if (dynamic_cast<const LObject*>(&player) && !dynamic_cast<const SelfObject*>(&player))
|
||||
throw std::runtime_error("Only player and global scripts may add topics.");
|
||||
|
||||
ESM::RefId topic = ESM::RefId::stringRefId(topicId);
|
||||
if (!MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(topic))
|
||||
{
|
||||
throw std::runtime_error("Failed to add topic " + topicId + ": topic record not found");
|
||||
}
|
||||
|
||||
MWBase::Environment::get().getDialogueManager()->addTopic(topic);
|
||||
};
|
||||
player["sendMenuEvent"] = [context](const Object& player, std::string eventName, const sol::object& eventData) {
|
||||
verifyPlayer(player);
|
||||
context.mLuaEvents->addMenuEvent({ std::move(eventName), LuaUtil::serialize(eventData) });
|
||||
|
|
|
|||
Loading…
Reference in a new issue