mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 08:53:52 +00:00
Lua API for Lockpick and Probe records
This commit is contained in:
parent
09757d0b87
commit
1b37d5d2ad
6 changed files with 112 additions and 4 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/activator types/book
|
types/types types/door types/actor types/container types/weapon types/npc types/creature types/activator types/book types/lockpick types/probe
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwsound
|
add_openmw_dir (mwsound
|
||||||
|
|
35
apps/openmw/mwlua/types/lockpick.cpp
Normal file
35
apps/openmw/mwlua/types/lockpick.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
|
#include <components/esm3/loadlock.hpp>
|
||||||
|
|
||||||
|
#include <apps/openmw/mwworld/esmstore.hpp>
|
||||||
|
|
||||||
|
#include "../luabindings.hpp"
|
||||||
|
|
||||||
|
namespace sol
|
||||||
|
{
|
||||||
|
template <>
|
||||||
|
struct is_automagical<ESM::Lockpick> : std::false_type {};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
void addLockpickBindings(sol::table lockpick, const Context& context)
|
||||||
|
{
|
||||||
|
const MWWorld::Store<ESM::Lockpick>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Lockpick>();
|
||||||
|
lockpick["record"] = sol::overload(
|
||||||
|
[](const Object& obj) -> const ESM::Lockpick* { return obj.ptr().get<ESM::Lockpick>()->mBase;},
|
||||||
|
[store](const std::string& recordId) -> const ESM::Lockpick* { return store->find(recordId);});
|
||||||
|
sol::usertype<ESM::Lockpick> record = context.mLua->sol().new_usertype<ESM::Lockpick>("ESM3_Lockpick");
|
||||||
|
record[sol::meta_function::to_string] = [](const ESM::Lockpick& rec) { return "ESM3_Lockpick[" + rec.mId + "]";};
|
||||||
|
record["id"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mId;});
|
||||||
|
record["name"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mName;});
|
||||||
|
record["model"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mModel;});
|
||||||
|
record["mwscript"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mScript;});
|
||||||
|
record["icon"] = sol::readonly_property([](const ESM::Lockpick& rec) -> std::string { return rec.mIcon;});
|
||||||
|
record["maxCondition"] = sol::readonly_property([](const ESM::Lockpick& rec) -> int { return rec.mData.mUses;});
|
||||||
|
record["value"] = sol::readonly_property([](const ESM::Lockpick& rec) -> int { return rec.mData.mValue;});
|
||||||
|
record["weight"] = sol::readonly_property([](const ESM::Lockpick& rec) -> float { return rec.mData.mWeight;});
|
||||||
|
record["quality"] = sol::readonly_property([](const ESM::Lockpick& rec) -> float { return rec.mData.mQuality;});
|
||||||
|
}
|
||||||
|
}
|
35
apps/openmw/mwlua/types/probe.cpp
Normal file
35
apps/openmw/mwlua/types/probe.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
|
#include <components/esm3/loadprob.hpp>
|
||||||
|
|
||||||
|
#include <apps/openmw/mwworld/esmstore.hpp>
|
||||||
|
|
||||||
|
#include "../luabindings.hpp"
|
||||||
|
|
||||||
|
namespace sol
|
||||||
|
{
|
||||||
|
template <>
|
||||||
|
struct is_automagical<ESM::Probe> : std::false_type {};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
void addProbeBindings(sol::table probe, const Context& context)
|
||||||
|
{
|
||||||
|
const MWWorld::Store<ESM::Probe>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Probe>();
|
||||||
|
probe["record"] = sol::overload(
|
||||||
|
[](const Object& obj) -> const ESM::Probe* { return obj.ptr().get<ESM::Probe>()->mBase;},
|
||||||
|
[store](const std::string& recordId) -> const ESM::Probe* { return store->find(recordId);});
|
||||||
|
sol::usertype<ESM::Probe> record = context.mLua->sol().new_usertype<ESM::Probe>("ESM3_Probe");
|
||||||
|
record[sol::meta_function::to_string] = [](const ESM::Probe& rec) { return "ESM3_Probe[" + rec.mId + "]";};
|
||||||
|
record["id"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mId;});
|
||||||
|
record["name"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mName;});
|
||||||
|
record["model"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mModel;});
|
||||||
|
record["mwscript"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mScript;});
|
||||||
|
record["icon"] = sol::readonly_property([](const ESM::Probe& rec) -> std::string { return rec.mIcon;});
|
||||||
|
record["maxCondition"] = sol::readonly_property([](const ESM::Probe& rec) -> int { return rec.mData.mUses;});
|
||||||
|
record["value"] = sol::readonly_property([](const ESM::Probe& rec) -> int { return rec.mData.mValue;});
|
||||||
|
record["weight"] = sol::readonly_property([](const ESM::Probe& rec) -> float { return rec.mData.mWeight;});
|
||||||
|
record["quality"] = sol::readonly_property([](const ESM::Probe& rec) -> float { return rec.mData.mQuality;});
|
||||||
|
}
|
||||||
|
}
|
|
@ -166,13 +166,13 @@ namespace MWLua
|
||||||
addType(ObjectTypeName::MiscItem, {ESM::REC_MISC}, ObjectTypeName::Item);
|
addType(ObjectTypeName::MiscItem, {ESM::REC_MISC}, ObjectTypeName::Item);
|
||||||
addType(ObjectTypeName::Potion, {ESM::REC_ALCH}, ObjectTypeName::Item);
|
addType(ObjectTypeName::Potion, {ESM::REC_ALCH}, ObjectTypeName::Item);
|
||||||
addWeaponBindings(addType(ObjectTypeName::Weapon, {ESM::REC_WEAP}, ObjectTypeName::Item), context);
|
addWeaponBindings(addType(ObjectTypeName::Weapon, {ESM::REC_WEAP}, ObjectTypeName::Item), context);
|
||||||
|
addBookBindings(addType(ObjectTypeName::Book, {ESM::REC_BOOK}, ObjectTypeName::Item), context);
|
||||||
|
addLockpickBindings(addType(ObjectTypeName::Lockpick, {ESM::REC_LOCK}, ObjectTypeName::Item), context);
|
||||||
|
addProbeBindings(addType(ObjectTypeName::Probe, {ESM::REC_PROB}, ObjectTypeName::Item), context);
|
||||||
addType(ObjectTypeName::Apparatus, {ESM::REC_APPA}, ObjectTypeName::Item);
|
addType(ObjectTypeName::Apparatus, {ESM::REC_APPA}, ObjectTypeName::Item);
|
||||||
addType(ObjectTypeName::Lockpick, {ESM::REC_LOCK}, 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);
|
||||||
|
|
||||||
addActivatorBindings(addType(ObjectTypeName::Activator, {ESM::REC_ACTI}), context);
|
addActivatorBindings(addType(ObjectTypeName::Activator, {ESM::REC_ACTI}), context);
|
||||||
addBookBindings(addType(ObjectTypeName::Book, {ESM::REC_BOOK}), 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});
|
||||||
|
|
|
@ -32,6 +32,8 @@ namespace MWLua
|
||||||
void addWeaponBindings(sol::table weapon, const Context& context);
|
void addWeaponBindings(sol::table weapon, const Context& context);
|
||||||
void addNpcBindings(sol::table npc, const Context& context);
|
void addNpcBindings(sol::table npc, const Context& context);
|
||||||
void addCreatureBindings(sol::table creature, const Context& context);
|
void addCreatureBindings(sol::table creature, const Context& context);
|
||||||
|
void addLockpickBindings(sol::table lockpick, const Context& context);
|
||||||
|
void addProbeBindings(sol::table probe, const Context& context);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MWLUA_TYPES_H
|
#endif // MWLUA_TYPES_H
|
||||||
|
|
|
@ -762,6 +762,24 @@
|
||||||
-- @param openmw.core#GameObject object
|
-- @param openmw.core#GameObject object
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the read-only @{#LockpickRecord} of a lockpick
|
||||||
|
-- @function [parent=#Lockpick] record
|
||||||
|
-- @param #any objectOrRecordId
|
||||||
|
-- @return #LockpickRecord
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type LockpickRecord
|
||||||
|
-- @field #string id The record ID of the lockpick
|
||||||
|
-- @field #string name The name of the lockpick
|
||||||
|
-- @field #string model VFS path to the model
|
||||||
|
-- @field #string mwscript MWScript on this lockpick (can be empty)
|
||||||
|
-- @field #string icon VFS path to the icon
|
||||||
|
-- @field #number maxCondition The maximum number of uses of this lockpick
|
||||||
|
-- @field #number weight
|
||||||
|
-- @field #number value
|
||||||
|
-- @field #number quality The quality of the lockpick
|
||||||
|
|
||||||
--- @{#Probe} functions
|
--- @{#Probe} functions
|
||||||
-- @field [parent=#types] #Probe Probe
|
-- @field [parent=#types] #Probe Probe
|
||||||
|
|
||||||
|
@ -776,6 +794,24 @@
|
||||||
-- @param openmw.core#GameObject object
|
-- @param openmw.core#GameObject object
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the read-only @{#ProbeRecord} of a probe
|
||||||
|
-- @function [parent=#Probe] record
|
||||||
|
-- @param #any objectOrRecordId
|
||||||
|
-- @return #ProbeRecord
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type ProbeRecord
|
||||||
|
-- @field #string id The record ID of the probe
|
||||||
|
-- @field #string name The name of the probe
|
||||||
|
-- @field #string model VFS path to the model
|
||||||
|
-- @field #string mwscript MWScript on this probe (can be empty)
|
||||||
|
-- @field #string icon VFS path to the icon
|
||||||
|
-- @field #number maxCondition The maximum number of uses of this probe
|
||||||
|
-- @field #number weight
|
||||||
|
-- @field #number value
|
||||||
|
-- @field #number quality The quality of the probe
|
||||||
|
|
||||||
--- @{#Repair} functions
|
--- @{#Repair} functions
|
||||||
-- @field [parent=#types] #Repair Repair
|
-- @field [parent=#types] #Repair Repair
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue