diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-08 18:10:09 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-08 18:10:09 +1000 |
commit | b89b8d585e3da04e45e8e6fe04b1728100e9071c (patch) | |
tree | adfc04f39d180856586252c50340c12cfb19b555 /source/base/StarAssets.cpp | |
parent | 4a3ffadecba57e64ebd8f6f6c4d15744c38e52b9 (diff) |
oops - restore assets modification to load scripts
Diffstat (limited to 'source/base/StarAssets.cpp')
-rw-r--r-- | source/base/StarAssets.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/source/base/StarAssets.cpp b/source/base/StarAssets.cpp index b334b31..357fca0 100644 --- a/source/base/StarAssets.cpp +++ b/source/base/StarAssets.cpp @@ -147,8 +147,10 @@ Assets::Assets(Settings settings, StringList assetSources) { pushGlobalContext("assets", makeBaseAssetCallbacks()); auto decorateLuaContext = [&](LuaContext& context, MemoryAssetSourcePtr newFiles) { - auto callbacks = makeBaseAssetCallbacks(); if (newFiles) { + // re-add the assets callbacks with more functions + context.remove("assets"); + auto callbacks = makeBaseAssetCallbacks(); callbacks.registerCallback("add", [&newFiles](LuaEngine& engine, String const& path, LuaValue const& data) { ByteArray bytes; if (auto str = engine.luaMaybeTo<String>(data)) @@ -184,9 +186,9 @@ Assets::Assets(Settings settings, StringList assetSources) { m_filesByExtension[AssetPath::extension(path).toLower()].erase(path); return erased; }); - } - context.setCallbacks("assets", callbacks); + context.setCallbacks("assets", callbacks); + } }; auto addSource = [&](String const& sourcePath, AssetSourcePtr source) { |