mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 09:39:42 +00:00
Merge branch 'activatorluabinds' into 'master'
Lua API for Activator records See merge request OpenMW/openmw!1882
This commit is contained in:
commit
43f4a0cfc5
5 changed files with 46 additions and 2 deletions
|
@ -62,7 +62,7 @@ add_openmw_dir (mwlua
|
||||||
luamanagerimp object worldview userdataserializer eventqueue
|
luamanagerimp object worldview userdataserializer eventqueue
|
||||||
luabindings localscripts playerscripts objectbindings cellbindings asyncbindings settingsbindings
|
luabindings localscripts playerscripts objectbindings cellbindings asyncbindings settingsbindings
|
||||||
camerabindings uibindings inputbindings nearbybindings postprocessingbindings stats debugbindings
|
camerabindings uibindings inputbindings nearbybindings postprocessingbindings stats debugbindings
|
||||||
types/types types/door types/actor types/container types/weapon types/npc types/creature
|
types/types types/door types/actor types/container types/weapon types/npc types/creature types/activator
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwsound
|
add_openmw_dir (mwsound
|
||||||
|
|
30
apps/openmw/mwlua/types/activator.cpp
Normal file
30
apps/openmw/mwlua/types/activator.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
|
#include <components/esm3/loadacti.hpp>
|
||||||
|
|
||||||
|
#include <apps/openmw/mwworld/esmstore.hpp>
|
||||||
|
|
||||||
|
#include "../luabindings.hpp"
|
||||||
|
|
||||||
|
namespace sol
|
||||||
|
{
|
||||||
|
template <>
|
||||||
|
struct is_automagical<ESM::Activator> : std::false_type {};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
void addActivatorBindings(sol::table activator, const Context& context)
|
||||||
|
{
|
||||||
|
const MWWorld::Store<ESM::Activator>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Activator>();
|
||||||
|
activator["record"] = sol::overload(
|
||||||
|
[](const Object& obj) -> const ESM::Activator* { return obj.ptr().get<ESM::Activator>()->mBase; },
|
||||||
|
[store](const std::string& recordId) -> const ESM::Activator* { return store->find(recordId); });
|
||||||
|
sol::usertype<ESM::Activator> record = context.mLua->sol().new_usertype<ESM::Activator>("ESM3_Activator");
|
||||||
|
record[sol::meta_function::to_string] = [](const ESM::Activator& rec) { return "ESM3_Activator[" + rec.mId + "]"; };
|
||||||
|
record["id"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mId; });
|
||||||
|
record["name"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mName; });
|
||||||
|
record["model"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mModel; });
|
||||||
|
record["mwscript"] = sol::readonly_property([](const ESM::Activator& rec) -> std::string { return rec.mScript; });
|
||||||
|
}
|
||||||
|
}
|
|
@ -172,7 +172,7 @@ namespace MWLua
|
||||||
addType(ObjectTypeName::Probe, {ESM::REC_PROB}, ObjectTypeName::Item);
|
addType(ObjectTypeName::Probe, {ESM::REC_PROB}, ObjectTypeName::Item);
|
||||||
addType(ObjectTypeName::Repair, {ESM::REC_REPA}, ObjectTypeName::Item);
|
addType(ObjectTypeName::Repair, {ESM::REC_REPA}, ObjectTypeName::Item);
|
||||||
|
|
||||||
addType(ObjectTypeName::Activator, {ESM::REC_ACTI});
|
addActivatorBindings(addType(ObjectTypeName::Activator, {ESM::REC_ACTI}), context);
|
||||||
addContainerBindings(addType(ObjectTypeName::Container, {ESM::REC_CONT}), context);
|
addContainerBindings(addType(ObjectTypeName::Container, {ESM::REC_CONT}), context);
|
||||||
addDoorBindings(addType(ObjectTypeName::Door, {ESM::REC_DOOR}), context);
|
addDoorBindings(addType(ObjectTypeName::Door, {ESM::REC_DOOR}), context);
|
||||||
addType(ObjectTypeName::Static, {ESM::REC_STAT});
|
addType(ObjectTypeName::Static, {ESM::REC_STAT});
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace MWLua
|
||||||
sol::table initTypesPackage(const Context& context);
|
sol::table initTypesPackage(const Context& context);
|
||||||
|
|
||||||
// used in initTypesPackage
|
// used in initTypesPackage
|
||||||
|
void addActivatorBindings(sol::table activator, const Context& context);
|
||||||
void addContainerBindings(sol::table container, const Context& context);
|
void addContainerBindings(sol::table container, const Context& context);
|
||||||
void addDoorBindings(sol::table door, const Context& context);
|
void addDoorBindings(sol::table door, const Context& context);
|
||||||
void addActorBindings(sol::table actor, const Context& context);
|
void addActorBindings(sol::table actor, const Context& context);
|
||||||
|
|
|
@ -748,6 +748,19 @@
|
||||||
-- @param openmw.core#GameObject object
|
-- @param openmw.core#GameObject object
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the read-only @{#ActivatorRecord} of an activator
|
||||||
|
-- @function [parent=#Activator] record
|
||||||
|
-- @param #any objectOrRecordId
|
||||||
|
-- @return #ActivatorRecord
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type ActivatorRecord
|
||||||
|
-- @field #string id Record id
|
||||||
|
-- @field #string name Human-readable name
|
||||||
|
-- @field #string model VFS path to the model
|
||||||
|
-- @field #string mwscript MWScript on this activator (can be empty)
|
||||||
|
|
||||||
--- @{#Container} functions
|
--- @{#Container} functions
|
||||||
-- @field [parent=#types] #Container Container
|
-- @field [parent=#types] #Container Container
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue