From 5340c2c816377e8e75476b550b31ef9a8d0e8099 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Fri, 10 Feb 2023 02:33:50 +0300 Subject: [PATCH] Fix Lua ingredient bindings --- apps/openmw/mwlua/types/ingredient.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwlua/types/ingredient.cpp b/apps/openmw/mwlua/types/ingredient.cpp index b3b6106545..a3cf1479ab 100644 --- a/apps/openmw/mwlua/types/ingredient.cpp +++ b/apps/openmw/mwlua/types/ingredient.cpp @@ -1,14 +1,14 @@ #include "types.hpp" #include - #include +#include +#include #include #include #include -#include namespace sol { @@ -22,6 +22,8 @@ namespace MWLua { void addIngredientBindings(sol::table ingredient, const Context& context) { + auto vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + const MWWorld::Store* store = &MWBase::Environment::get().getWorld()->getStore().get(); ingredient["record"] = sol::overload( @@ -31,14 +33,18 @@ namespace MWLua }); sol::usertype record = context.mLua->sol().new_usertype(("ESM3_Ingredient")); 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( [](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["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( [](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"] = 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; });