mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-20 15:40:32 +00:00
Lua api for potion records
This commit is contained in:
parent
7021b1607e
commit
fb5eb542ff
@ -62,7 +62,7 @@ add_openmw_dir (mwlua
|
||||
luamanagerimp object worldview userdataserializer eventqueue
|
||||
luabindings localscripts playerscripts objectbindings cellbindings asyncbindings settingsbindings
|
||||
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/misc
|
||||
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/potion types/misc
|
||||
)
|
||||
|
||||
add_openmw_dir (mwsound
|
||||
|
34
apps/openmw/mwlua/types/potion.cpp
Normal file
34
apps/openmw/mwlua/types/potion.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "types.hpp"
|
||||
|
||||
#include <components/esm3/loadalch.hpp>
|
||||
|
||||
#include <apps/openmw/mwworld/esmstore.hpp>
|
||||
|
||||
#include "../luabindings.hpp"
|
||||
|
||||
namespace sol
|
||||
{
|
||||
template <>
|
||||
struct is_automagical<ESM::Potion> : std::false_type {};
|
||||
}
|
||||
|
||||
namespace MWLua
|
||||
{
|
||||
void addPotionBindings(sol::table potion, const Context& context)
|
||||
{
|
||||
const MWWorld::Store<ESM::Potion>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>();
|
||||
potion["record"] = sol::overload(
|
||||
[](const Object& obj) -> const ESM::Potion* { return obj.ptr().get<ESM::Potion>()->mBase; },
|
||||
[store](const std::string& recordId) -> const ESM::Potion* { return store->find(recordId); });
|
||||
|
||||
sol::usertype<ESM::Potion> record = context.mLua->sol().new_usertype<ESM::Potion>("ESM3_Potion");
|
||||
record[sol::meta_function::to_string] = [](const ESM::Potion& rec) { return "ESM3_Potion[" + rec.mId + "]"; };
|
||||
record["id"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mId; });
|
||||
record["name"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mName; });
|
||||
record["model"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mModel; });
|
||||
record["icon"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mIcon; });
|
||||
record["mwscript"] = sol::readonly_property([](const ESM::Potion& rec) -> std::string { return rec.mScript; });
|
||||
record["weight"] = sol::readonly_property([](const ESM::Potion& rec) -> float { return rec.mData.mWeight; });
|
||||
record["value"] = sol::readonly_property([](const ESM::Potion& rec) -> int { return rec.mData.mValue; });
|
||||
}
|
||||
}
|
@ -164,7 +164,7 @@ namespace MWLua
|
||||
addType(ObjectTypeName::Ingredient, {ESM::REC_INGR}, ObjectTypeName::Item);
|
||||
addType(ObjectTypeName::Light, {ESM::REC_LIGH}, ObjectTypeName::Item);
|
||||
addMiscellaneousBindings(addType(ObjectTypeName::MiscItem, {ESM::REC_MISC}, ObjectTypeName::Item), context);
|
||||
addType(ObjectTypeName::Potion, {ESM::REC_ALCH}, ObjectTypeName::Item);
|
||||
addPotionBindings(addType(ObjectTypeName::Potion, {ESM::REC_ALCH}, 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);
|
||||
|
@ -36,6 +36,7 @@ namespace MWLua
|
||||
void addProbeBindings(sol::table probe, const Context& context);
|
||||
void addApparatusBindings(sol::table apparatus, const Context& context);
|
||||
void addMiscellaneousBindings(sol::table miscellaneous, const Context& context);
|
||||
void addPotionBindings(sol::table potion, const Context& context);
|
||||
}
|
||||
|
||||
#endif // MWLUA_TYPES_H
|
||||
|
@ -681,6 +681,22 @@
|
||||
-- @param openmw.core#GameObject object
|
||||
-- @return #boolean
|
||||
|
||||
---
|
||||
-- Returns the read-only @{#PotionRecord} of a potion
|
||||
-- @function [parent=#Potion] record
|
||||
-- @param #any objectOrRecordId
|
||||
-- @return #PotionRecord
|
||||
|
||||
---
|
||||
-- @type PotionRecord
|
||||
-- @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 potion (can be empty)
|
||||
-- @field #string icon VFS path to the icon
|
||||
-- @field #number weight
|
||||
-- @field #number value
|
||||
|
||||
|
||||
|
||||
--- @{#Weapon} functions
|
||||
|
Loading…
x
Reference in New Issue
Block a user