mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-09 09:04:31 +00:00
Merge branch 'talk-to-me-about-something-else' into 'master'
FEAT: AddTopic in Lua, close #8334 Closes #8334 See merge request OpenMW/openmw!4529
This commit is contained in:
commit
4f95ca4196
2 changed files with 18 additions and 1 deletions
|
|
@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
|
||||||
set(OPENMW_VERSION_MAJOR 0)
|
set(OPENMW_VERSION_MAJOR 0)
|
||||||
set(OPENMW_VERSION_MINOR 50)
|
set(OPENMW_VERSION_MINOR 50)
|
||||||
set(OPENMW_VERSION_RELEASE 0)
|
set(OPENMW_VERSION_RELEASE 0)
|
||||||
set(OPENMW_LUA_API_REVISION 80)
|
set(OPENMW_LUA_API_REVISION 81)
|
||||||
set(OPENMW_POSTPROCESSING_API_REVISION 3)
|
set(OPENMW_POSTPROCESSING_API_REVISION 3)
|
||||||
|
|
||||||
set(OPENMW_VERSION_COMMITHASH "")
|
set(OPENMW_VERSION_COMMITHASH "")
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
#include "../birthsignbindings.hpp"
|
#include "../birthsignbindings.hpp"
|
||||||
#include "../luamanagerimp.hpp"
|
#include "../luamanagerimp.hpp"
|
||||||
|
|
||||||
|
#include "apps/openmw/mwbase/dialoguemanager.hpp"
|
||||||
#include "apps/openmw/mwbase/inputmanager.hpp"
|
#include "apps/openmw/mwbase/inputmanager.hpp"
|
||||||
#include "apps/openmw/mwbase/journal.hpp"
|
#include "apps/openmw/mwbase/journal.hpp"
|
||||||
#include "apps/openmw/mwbase/mechanicsmanager.hpp"
|
#include "apps/openmw/mwbase/mechanicsmanager.hpp"
|
||||||
|
|
@ -195,6 +196,22 @@ namespace MWLua
|
||||||
throw std::runtime_error("Only player and global scripts can toggle teleportation.");
|
throw std::runtime_error("Only player and global scripts can toggle teleportation.");
|
||||||
MWBase::Environment::get().getWorld()->enableTeleporting(state);
|
MWBase::Environment::get().getWorld()->enableTeleporting(state);
|
||||||
};
|
};
|
||||||
|
player["addTopic"] = [](const Object& player, std::string_view topicId) {
|
||||||
|
verifyPlayer(player);
|
||||||
|
|
||||||
|
ESM::RefId topic = ESM::RefId::deserializeText(topicId);
|
||||||
|
const ESM::Dialogue* dialogueRecord
|
||||||
|
= MWBase::Environment::get().getESMStore()->get<ESM::Dialogue>().search(topic);
|
||||||
|
|
||||||
|
if (!dialogueRecord)
|
||||||
|
throw std::runtime_error(
|
||||||
|
"Failed to add topic \"" + std::string(topicId) + "\": topic record not found");
|
||||||
|
|
||||||
|
if (dialogueRecord->mType != ESM::Dialogue::Topic)
|
||||||
|
throw std::runtime_error("Failed to add topic \"" + std::string(topicId) + "\": record is not a topic");
|
||||||
|
|
||||||
|
MWBase::Environment::get().getDialogueManager()->addTopic(topic);
|
||||||
|
};
|
||||||
player["sendMenuEvent"] = [context](const Object& player, std::string eventName, const sol::object& eventData) {
|
player["sendMenuEvent"] = [context](const Object& player, std::string eventName, const sol::object& eventData) {
|
||||||
verifyPlayer(player);
|
verifyPlayer(player);
|
||||||
context.mLuaEvents->addMenuEvent({ std::move(eventName), LuaUtil::serialize(eventData) });
|
context.mLuaEvents->addMenuEvent({ std::move(eventName), LuaUtil::serialize(eventData) });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue