mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-08-03 15:27:13 -04:00
add mwscript bindings to core
This commit is contained in:
parent
9228f90f46
commit
fa8ba57ab3
@ -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 "")
|
||||
|
@ -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
|
||||
|
@ -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"]
|
||||
|
28
apps/openmw/mwlua/coremwscriptbindings.cpp
Normal file
28
apps/openmw/mwlua/coremwscriptbindings.cpp
Normal 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);
|
||||
}
|
||||
}
|
13
apps/openmw/mwlua/coremwscriptbindings.hpp
Normal file
13
apps/openmw/mwlua/coremwscriptbindings.hpp
Normal 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
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user