mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-28 14:53:58 +00:00
Merge branch 'addmiscluabinds' into 'master'
Lua API for Miscellaneous records See merge request OpenMW/openmw!1954
This commit is contained in:
commit
11f21c39ec
@ -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/lockpick types/probe types/apparatus
|
types/types types/door types/actor types/container types/weapon types/npc types/creature types/activator types/book types/lockpick types/probe types/apparatus types/misc
|
||||||
)
|
)
|
||||||
|
|
||||||
add_openmw_dir (mwsound
|
add_openmw_dir (mwsound
|
||||||
|
34
apps/openmw/mwlua/types/misc.cpp
Normal file
34
apps/openmw/mwlua/types/misc.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "types.hpp"
|
||||||
|
|
||||||
|
#include <components/esm3/loadmisc.hpp>
|
||||||
|
|
||||||
|
#include <apps/openmw/mwworld/esmstore.hpp>
|
||||||
|
|
||||||
|
#include "../luabindings.hpp"
|
||||||
|
|
||||||
|
namespace sol
|
||||||
|
{
|
||||||
|
template <>
|
||||||
|
struct is_automagical<ESM::Miscellaneous> : std::false_type {};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace MWLua
|
||||||
|
{
|
||||||
|
void addMiscellaneousBindings(sol::table miscellaneous, const Context& context)
|
||||||
|
{
|
||||||
|
const MWWorld::Store<ESM::Miscellaneous>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Miscellaneous>();
|
||||||
|
miscellaneous["record"] = sol::overload(
|
||||||
|
[](const Object& obj) -> const ESM::Miscellaneous* { return obj.ptr().get<ESM::Miscellaneous>()->mBase; },
|
||||||
|
[store](const std::string& recordId) -> const ESM::Miscellaneous* { return store->find(recordId); });
|
||||||
|
sol::usertype<ESM::Miscellaneous> record = context.mLua->sol().new_usertype<ESM::Miscellaneous>("ESM3_Miscellaneous");
|
||||||
|
record[sol::meta_function::to_string] = [](const ESM::Miscellaneous& rec) { return "ESM3_Miscellaneous[" + rec.mId + "]"; };
|
||||||
|
record["id"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mId; });
|
||||||
|
record["name"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mName; });
|
||||||
|
record["model"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mModel; });
|
||||||
|
record["mwscript"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mScript; });
|
||||||
|
record["icon"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> std::string { return rec.mIcon; });
|
||||||
|
record["isKey"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> bool { return rec.mData.mIsKey; });
|
||||||
|
record["value"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> int { return rec.mData.mValue; });
|
||||||
|
record["weight"] = sol::readonly_property([](const ESM::Miscellaneous& rec) -> float { return rec.mData.mWeight; });
|
||||||
|
}
|
||||||
|
}
|
@ -163,7 +163,7 @@ namespace MWLua
|
|||||||
addType(ObjectTypeName::Clothing, {ESM::REC_CLOT}, ObjectTypeName::Item);
|
addType(ObjectTypeName::Clothing, {ESM::REC_CLOT}, ObjectTypeName::Item);
|
||||||
addType(ObjectTypeName::Ingredient, {ESM::REC_INGR}, ObjectTypeName::Item);
|
addType(ObjectTypeName::Ingredient, {ESM::REC_INGR}, ObjectTypeName::Item);
|
||||||
addType(ObjectTypeName::Light, {ESM::REC_LIGH}, ObjectTypeName::Item);
|
addType(ObjectTypeName::Light, {ESM::REC_LIGH}, ObjectTypeName::Item);
|
||||||
addType(ObjectTypeName::MiscItem, {ESM::REC_MISC}, ObjectTypeName::Item);
|
addMiscellaneousBindings(addType(ObjectTypeName::MiscItem, {ESM::REC_MISC}, ObjectTypeName::Item), context);
|
||||||
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);
|
addBookBindings(addType(ObjectTypeName::Book, {ESM::REC_BOOK}, ObjectTypeName::Item), context);
|
||||||
|
@ -35,6 +35,7 @@ namespace MWLua
|
|||||||
void addLockpickBindings(sol::table lockpick, const Context& context);
|
void addLockpickBindings(sol::table lockpick, const Context& context);
|
||||||
void addProbeBindings(sol::table probe, const Context& context);
|
void addProbeBindings(sol::table probe, const Context& context);
|
||||||
void addApparatusBindings(sol::table apparatus, const Context& context);
|
void addApparatusBindings(sol::table apparatus, const Context& context);
|
||||||
|
void addMiscellaneousBindings(sol::table miscellaneous, const Context& context);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MWLUA_TYPES_H
|
#endif // MWLUA_TYPES_H
|
||||||
|
@ -650,7 +650,22 @@
|
|||||||
-- @param openmw.core#GameObject object
|
-- @param openmw.core#GameObject object
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Returns the read-only @{#MiscellaneousRecord} of a miscellaneous item
|
||||||
|
-- @function [parent=#Miscellaneous] record
|
||||||
|
-- @param #any objectOrRecordId
|
||||||
|
-- @return #MiscellaneousRecord
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type MiscellaneousRecord
|
||||||
|
-- @field #string id The record ID of the miscellaneous item
|
||||||
|
-- @field #string name The name of the miscellaneous item
|
||||||
|
-- @field #string model VFS path to the model
|
||||||
|
-- @field #string mwscript MWScript on this miscellaneous item (can be empty)
|
||||||
|
-- @field #string icon VFS path to the icon
|
||||||
|
-- @field #number weight
|
||||||
|
-- @field #number value
|
||||||
|
-- @field #boolean isKey
|
||||||
|
|
||||||
--- @{#Potion} functions
|
--- @{#Potion} functions
|
||||||
-- @field [parent=#types] #Potion Potion
|
-- @field [parent=#types] #Potion Potion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user