mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Merge branch 'ingredientbindings' into 'master'
Fix Lua ingredient bindings Closes #7216 See merge request OpenMW/openmw!2706
This commit is contained in:
commit
78ff1a3fb9
@ -1,14 +1,14 @@
|
|||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
|
|
||||||
#include <components/esm3/loadingr.hpp>
|
#include <components/esm3/loadingr.hpp>
|
||||||
|
|
||||||
#include <components/lua/luastate.hpp>
|
#include <components/lua/luastate.hpp>
|
||||||
|
#include <components/misc/resourcehelpers.hpp>
|
||||||
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
|
||||||
#include <apps/openmw/mwworld/esmstore.hpp>
|
#include <apps/openmw/mwworld/esmstore.hpp>
|
||||||
|
|
||||||
#include <apps/openmw/mwbase/environment.hpp>
|
#include <apps/openmw/mwbase/environment.hpp>
|
||||||
#include <apps/openmw/mwbase/world.hpp>
|
#include <apps/openmw/mwbase/world.hpp>
|
||||||
#include <components/esm3/loadalch.hpp>
|
|
||||||
|
|
||||||
namespace sol
|
namespace sol
|
||||||
{
|
{
|
||||||
@ -22,6 +22,8 @@ namespace MWLua
|
|||||||
{
|
{
|
||||||
void addIngredientBindings(sol::table ingredient, const Context& context)
|
void addIngredientBindings(sol::table ingredient, const Context& context)
|
||||||
{
|
{
|
||||||
|
auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS();
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Ingredient>* store
|
const MWWorld::Store<ESM::Ingredient>* store
|
||||||
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>();
|
= &MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>();
|
||||||
ingredient["record"] = sol::overload(
|
ingredient["record"] = sol::overload(
|
||||||
@ -31,14 +33,18 @@ namespace MWLua
|
|||||||
});
|
});
|
||||||
sol::usertype<ESM::Ingredient> record = context.mLua->sol().new_usertype<ESM::Ingredient>(("ESM3_Ingredient"));
|
sol::usertype<ESM::Ingredient> record = context.mLua->sol().new_usertype<ESM::Ingredient>(("ESM3_Ingredient"));
|
||||||
record[sol::meta_function::to_string]
|
record[sol::meta_function::to_string]
|
||||||
= [](const ESM::Potion& rec) { return "ESM3_Ingredient[" + rec.mId.getRefIdString() + "]"; };
|
= [](const ESM::Ingredient& rec) { return "ESM3_Ingredient[" + rec.mId.getRefIdString() + "]"; };
|
||||||
record["id"] = sol::readonly_property(
|
record["id"] = sol::readonly_property(
|
||||||
[](const ESM::Ingredient& rec) -> std::string { return rec.mId.getRefIdString(); });
|
[](const ESM::Ingredient& rec) -> std::string { return rec.mId.getRefIdString(); });
|
||||||
record["name"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mName; });
|
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["model"] = sol::readonly_property([vfs](const ESM::Ingredient& rec) -> std::string {
|
||||||
|
return Misc::ResourceHelpers::correctMeshPath(rec.mModel, vfs);
|
||||||
|
});
|
||||||
record["mwscript"] = sol::readonly_property(
|
record["mwscript"] = sol::readonly_property(
|
||||||
[](const ESM::Ingredient& rec) -> std::string { return rec.mScript.getRefIdString(); });
|
[](const ESM::Ingredient& rec) -> std::string { return rec.mScript.getRefIdString(); });
|
||||||
record["icon"] = sol::readonly_property([](const ESM::Ingredient& rec) -> std::string { return rec.mIcon; });
|
record["icon"] = sol::readonly_property([vfs](const ESM::Ingredient& rec) -> std::string {
|
||||||
|
return Misc::ResourceHelpers::correctIconPath(rec.mIcon, vfs);
|
||||||
|
});
|
||||||
record["weight"]
|
record["weight"]
|
||||||
= sol::readonly_property([](const ESM::Ingredient& rec) -> float { return rec.mData.mWeight; });
|
= 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; });
|
record["value"] = sol::readonly_property([](const ESM::Ingredient& rec) -> int { return rec.mData.mValue; });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user