mirror of
https://github.com/OpenMW/openmw.git
synced 2026-05-06 07:56:40 -04:00
Move effect name init to Lua
This commit is contained in:
@@ -303,6 +303,18 @@ namespace MWLua
|
||||
addMutableMagicEffectType(lua);
|
||||
sol::table api(lua, sol::create);
|
||||
api["records"] = MutableStore<ESM::MagicEffect>{ store };
|
||||
// We can't get rid of the GMST table engine side because mwscript needs it, so intead of copying it into a
|
||||
// Lua file we've got this hidden function to generate it
|
||||
api["_getGMSTs"] = [](sol::this_state state) {
|
||||
sol::table gmsts(state, sol::create);
|
||||
for (int i = 0; i < ESM::MagicEffect::Length; ++i)
|
||||
{
|
||||
const ESM::RefId effect = ESM::MagicEffect::indexToRefId(i);
|
||||
const std::string_view gmst = ESM::MagicEffect::refIdToGmstString(effect);
|
||||
gmsts[effect] = gmst;
|
||||
}
|
||||
return gmsts;
|
||||
};
|
||||
return LuaUtil::makeReadOnly(api);
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +525,6 @@ namespace MWWorld
|
||||
store->setUp();
|
||||
|
||||
getWritable<ESM::Skill>().setUp(get<ESM::GameSetting>());
|
||||
getWritable<ESM::MagicEffect>().setUp(get<ESM::GameSetting>());
|
||||
getWritable<ESM::Attribute>().setUp(get<ESM::GameSetting>());
|
||||
getWritable<ESM4::Land>().updateLandPositions(get<ESM4::Cell>());
|
||||
getWritable<ESM4::Reference>().preprocessReferences(get<ESM4::Cell>());
|
||||
|
||||
@@ -999,19 +999,6 @@ namespace MWWorld
|
||||
.mWerewolfValue = getGMSTFloat(settings, "fWerewolfLuck") });
|
||||
}
|
||||
|
||||
// Magic Effect
|
||||
//=========================================================================
|
||||
|
||||
void Store<ESM::MagicEffect>::setUp(const MWWorld::Store<ESM::GameSetting>& settings)
|
||||
{
|
||||
for (ESM::MagicEffect* mgef : mShared)
|
||||
{
|
||||
std::string_view gmst = ESM::MagicEffect::refIdToGmstString(mgef->mId);
|
||||
if (!gmst.empty())
|
||||
mgef->mName = getGMSTString(settings, gmst);
|
||||
}
|
||||
}
|
||||
|
||||
// Dialogue
|
||||
//=========================================================================
|
||||
|
||||
|
||||
@@ -466,8 +466,6 @@ namespace MWWorld
|
||||
|
||||
public:
|
||||
Store() = default;
|
||||
|
||||
void setUp(const MWWorld::Store<ESM::GameSetting>& settings);
|
||||
};
|
||||
|
||||
template <>
|
||||
|
||||
@@ -82,12 +82,28 @@ local function generateDefaultDoors()
|
||||
end
|
||||
end
|
||||
|
||||
local function setMagicEffectNames()
|
||||
local gmsts = content.gameSettings.records
|
||||
local effects = content.magicEffects.records
|
||||
for id, gmst in pairs(content.magicEffects._getGMSTs()) do
|
||||
local effect = effects[id]
|
||||
if effect ~= nil then
|
||||
local name = gmsts[gmst]
|
||||
if type(name) ~= 'string' or name == '' then
|
||||
name = gmst
|
||||
end
|
||||
effect.name = name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
engineHandlers = {
|
||||
onContentFilesLoaded = function()
|
||||
generateDefaultDoors()
|
||||
generateDefaultGMSTs()
|
||||
generateDefaultStatics()
|
||||
setMagicEffectNames()
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user