mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
Merge branch 'luaIngredient' into 'master'
Lua Bindings for Ingredient Records See merge request OpenMW/openmw!2205
This commit is contained in:
commit
9a4df75f3c
@ -62,7 +62,7 @@ add_openmw_dir (mwlua
|
||||
luamanagerimp object worldview userdataserializer eventqueue
|
||||
luabindings localscripts playerscripts objectbindings cellbindings asyncbindings
|
||||
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/potion types/misc types/repair
|
||||
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/ingredient types/misc types/repair
|
||||
)
|
||||
|
||||
add_openmw_dir (mwsound
|
||||
|
@ -54,7 +54,7 @@ namespace MWLua
|
||||
{
|
||||
auto* lua = context.mLua;
|
||||
sol::table api(lua->sol(), sol::create);
|
||||
api["API_REVISION"] = 28;
|
||||
api["API_REVISION"] = 29;
|
||||
api["quit"] = [lua]()
|
||||
{
|
||||
Log(Debug::Warning) << "Quit requested by a Lua script.\n" << lua->debugTraceback();
|
||||
|
33
apps/openmw/mwlua/types/ingredient.cpp
Normal file
33
apps/openmw/mwlua/types/ingredient.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "types.hpp"
|
||||
|
||||
#include <components/esm3/loadingr.hpp>
|
||||
|
||||
#include <apps/openmw/mwworld/esmstore.hpp>
|
||||
|
||||
#include "../luabindings.hpp"
|
||||
|
||||
namespace sol
|
||||
{
|
||||
template <>
|
||||
struct is_automagical<ESM::Ingredient> : std::false_type {};
|
||||
}
|
||||
|
||||
namespace MWLua
|
||||
{
|
||||
void addIngredientBindings(sol::table ingredient, const Context& context)
|
||||
{
|
||||
const MWWorld::Store<ESM::Ingredient>* store = &MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>();
|
||||
ingredient["record"] = sol::overload(
|
||||
[](const Object& obj)-> const ESM::Ingredient* { return obj.ptr().get<ESM::Ingredient>()->mBase; },
|
||||
[store](const std::string& recordID)-> const ESM::Ingredient* {return store->find(recordID); });
|
||||
sol::usertype<ESM::Ingredient> record = context.mLua->sol().new_usertype<ESM::Ingredient>(("ESM3_Ingredient"));
|
||||
record[sol::meta_function::to_string] = [](const ESM::Potion& rec) {return "ESM3_Ingredient[" + rec.mId + "]"; };
|
||||
record["id"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string {return rec.mId; });
|
||||
record["name"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string {return rec.mName; });
|
||||
record["model"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string {return rec.mModel; });
|
||||
record["mwscript"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string {return rec.mScript; });
|
||||
record["icon"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string {return rec.mIcon; });
|
||||
record["weight"] = sol::readonly_property([](const ESM::Ingredient& rec) -> float {return rec.mData.mWeight; });
|
||||
record["value"] = sol::readonly_property([](const ESM::Ingredient& rec) -> int{return rec.mData.mValue; });
|
||||
}
|
||||
}
|
@ -159,7 +159,7 @@ namespace MWLua
|
||||
|
||||
addType(ObjectTypeName::Armor, {ESM::REC_ARMO}, ObjectTypeName::Item);
|
||||
addType(ObjectTypeName::Clothing, {ESM::REC_CLOT}, ObjectTypeName::Item);
|
||||
addType(ObjectTypeName::Ingredient, {ESM::REC_INGR}, ObjectTypeName::Item);
|
||||
addIngredientBindings(addType(ObjectTypeName::Ingredient, { ESM::REC_INGR }, ObjectTypeName::Item), context);
|
||||
addType(ObjectTypeName::Light, {ESM::REC_LIGH}, ObjectTypeName::Item);
|
||||
addMiscellaneousBindings(addType(ObjectTypeName::MiscItem, {ESM::REC_MISC}, ObjectTypeName::Item), context);
|
||||
addPotionBindings(addType(ObjectTypeName::Potion, {ESM::REC_ALCH}, ObjectTypeName::Item), context);
|
||||
|
@ -41,6 +41,7 @@ namespace MWLua
|
||||
void addRepairBindings(sol::table repair, const Context& context);
|
||||
void addMiscellaneousBindings(sol::table miscellaneous, const Context& context);
|
||||
void addPotionBindings(sol::table potion, const Context& context);
|
||||
void addIngredientBindings(sol::table Ingredient, const Context& context);
|
||||
}
|
||||
|
||||
#endif // MWLUA_TYPES_H
|
||||
|
@ -624,6 +624,22 @@
|
||||
-- @param openmw.core#GameObject object
|
||||
-- @return #boolean
|
||||
|
||||
---
|
||||
-- Returns the read-only @{#IngredientRecord} of a Ingredient
|
||||
-- @function [parent=#Ingredient] record
|
||||
-- @param #any objectOrRecordId
|
||||
-- @return #IngredientRecord
|
||||
|
||||
---
|
||||
-- @type IngredientRecord
|
||||
-- @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
|
||||
|
||||
|
||||
|
||||
--- @{#Light} functions
|
||||
|
Loading…
x
Reference in New Issue
Block a user