mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-22 18:09:41 +00:00
Use lua table, getESMStore
This commit is contained in:
parent
ecc69b5479
commit
208cd14cfe
1 changed files with 5 additions and 8 deletions
|
@ -20,8 +20,9 @@ namespace MWLua
|
||||||
template <class T>
|
template <class T>
|
||||||
void addActorServicesBindings(sol::usertype<T>& record, const Context& context)
|
void addActorServicesBindings(sol::usertype<T>& record, const Context& context)
|
||||||
{
|
{
|
||||||
record["servicesOffered"] = sol::readonly_property([](const T& rec) -> std::map<std::string_view, bool> {
|
record["servicesOffered"] = sol::readonly_property([context](const T& rec) -> sol::table {
|
||||||
std::map<std::string_view, bool> providedServices;
|
sol::state_view& lua = context.mLua->sol();
|
||||||
|
sol::table providedServices(lua, sol::create);
|
||||||
constexpr std::array<std::pair<int, std::string_view>, 19> serviceNames = { { { ESM::NPC::Spells,
|
constexpr std::array<std::pair<int, std::string_view>, 19> serviceNames = { { { ESM::NPC::Spells,
|
||||||
"Spells" },
|
"Spells" },
|
||||||
{ ESM::NPC::Spellmaking, "Spellmaking" }, { ESM::NPC::Enchanting, "Enchanting" },
|
{ ESM::NPC::Spellmaking, "Spellmaking" }, { ESM::NPC::Enchanting, "Enchanting" },
|
||||||
|
@ -36,12 +37,8 @@ namespace MWLua
|
||||||
if constexpr (std::is_same_v<T, ESM::NPC>)
|
if constexpr (std::is_same_v<T, ESM::NPC>)
|
||||||
{
|
{
|
||||||
if (rec.mFlags & ESM::NPC::Autocalc)
|
if (rec.mFlags & ESM::NPC::Autocalc)
|
||||||
services = MWBase::Environment::get()
|
services
|
||||||
.getWorld()
|
= MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(rec.mClass)->mData.mServices;
|
||||||
->getStore()
|
|
||||||
.get<ESM::Class>()
|
|
||||||
.find(rec.mClass)
|
|
||||||
->mData.mServices;
|
|
||||||
}
|
}
|
||||||
for (const auto& [flag, name] : serviceNames)
|
for (const auto& [flag, name] : serviceNames)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue