1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-07 18:04:34 +00:00

Merge branch 'add_scripText_to_mwscriptbindings' into 'master'

lua - add mwscript bindings to core (#8320)

Closes #8320

See merge request OpenMW/openmw!4517
This commit is contained in:
psi29a 2025-07-02 09:42:25 +00:00
commit 5a292624a5
6 changed files with 62 additions and 2 deletions

View file

@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 50)
set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_LUA_API_REVISION 76)
set(OPENMW_LUA_API_REVISION 77)
set(OPENMW_POSTPROCESSING_API_REVISION 2)
set(OPENMW_VERSION_COMMITHASH "")

View file

@ -60,7 +60,7 @@ add_openmw_dir (mwscript
add_openmw_dir (mwlua
luamanagerimp object objectlists userdataserializer luaevents engineevents objectvariant
context menuscripts globalscripts localscripts playerscripts luabindings objectbindings cellbindings
context menuscripts globalscripts localscripts playerscripts luabindings objectbindings cellbindings coremwscriptbindings
mwscriptbindings camerabindings vfsbindings uibindings soundbindings inputbindings nearbybindings dialoguebindings
postprocessingbindings stats recordstore debugbindings corebindings worldbindings worker magicbindings factionbindings
classbindings itemdata inputprocessor animationbindings birthsignbindings racebindings markupbindings

View file

@ -19,6 +19,7 @@
#include "../mwworld/datetimemanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "coremwscriptbindings.hpp"
#include "dialoguebindings.hpp"
#include "factionbindings.hpp"
#include "luaevents.hpp"
@ -97,6 +98,9 @@ namespace MWLua
api["stats"]
= context.cachePackage("openmw_core_stats", [context]() { return initCoreStatsBindings(context); });
api["mwscripts"]
= context.cachePackage("openmw_core_mwscripts", [context]() { return initCoreMwScriptBindings(context); });
api["factions"]
= context.cachePackage("openmw_core_factions", [context]() { return initCoreFactionBindings(context); });
api["dialogue"]

View file

@ -0,0 +1,28 @@
#include "coremwscriptbindings.hpp"
#include <components/esm3/loadscpt.hpp>
#include "../mwworld/esmstore.hpp"
#include "context.hpp"
#include "recordstore.hpp"
namespace MWLua
{
sol::table initCoreMwScriptBindings(const Context& context)
{
sol::state_view lua = context.sol();
sol::table api(lua, sol::create);
auto recordBindingsClass = lua.new_usertype<ESM::Script>("ESM3_Script");
recordBindingsClass[sol::meta_function::to_string]
= [](const ESM::Script& rec) { return "ESM3_Script[" + rec.mId.toDebugString() + "]"; };
recordBindingsClass["id"]
= sol::readonly_property([](const ESM::Script& rec) { return rec.mId.serializeText(); });
recordBindingsClass["text"] = sol::readonly_property([](const ESM::Script& rec) { return rec.mScriptText; });
addRecordFunctionBinding<ESM::Script>(api, context);
return LuaUtil::makeReadOnly(api);
}
}

View file

@ -0,0 +1,13 @@
#ifndef MWLUA_COREMWSCRIPTBINDINGS_H
#define MWLUA_COREMWSCRIPTBINDINGS_H
#include <sol/forward.hpp>
namespace MWLua
{
struct Context;
sol::table initCoreMwScriptBindings(const Context& context);
}
#endif // MWLUA_COREMWSCRIPTBINDINGS_H

View file

@ -1143,4 +1143,19 @@
-- @field #number favouredSkillValue Secondary skill value required to get this rank.
-- @field #number factionReaction Reaction of faction members if player is in this faction.
--- @{#MWScripts}: MWScripts
-- @field [parent=#core] #MWScript mwscripts
---
-- A read-only list of all @{#MWScriptRecord}s in the world database.
-- @field [parent=#MWScripts] #list<#MWScriptRecord> records
-- @usage local record = core.mwscripts.records['example_recordid']
-- @usage local record = core.mwscripts.records[1]
---
-- MWScript data record
-- @type MWScriptRecord
-- @field #string id MWScript id
-- @field #string text MWScript content
return nil