Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/HeadlessWrapper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ end

dofile("Launch.lua")

-- Prevents loading of ModCache
-- Allows running mod parsing related tests without pushing ModCache
-- The CI env var will be true when run from github workflows but should be false for other tools using the headless wrapper
mainObject.headlessMode = os.getenv("CI")

runCallback("OnInit")
runCallback("OnFrame") -- Need at least one frame for everything to initialise

Expand Down
50 changes: 25 additions & 25 deletions src/Modules/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ function main:Init()
self.buildPath = self.defaultBuildPath
MakeDir(self.buildPath)

if launch.devMode and IsKeyDown("CTRL") then
self.rebuildModCache = true
else
if launch.devMode and IsKeyDown("CTRL") then
self:RebuildModCache()
elseif not launch.headlessMode then
-- Load mod cache
LoadModule("Data/ModCache", modLib.parseModCache)
end
Expand Down Expand Up @@ -102,28 +102,6 @@ function main:Init()
end
end

if self.rebuildModCache then
-- Update mod cache
local out = io.open("Data/ModCache.lua", "w")
out:write('local c=...')
for line, dat in pairs(modLib.parseModCache) do
if not dat[1] or not dat[1][1] or dat[1][1].name ~= "JewelFunc" then
out:write('c["', line:gsub("\n","\\n"), '"]={')
if dat[1] then
writeLuaTable(out, dat[1])
else
out:write('nil')
end
if dat[2] then
out:write(',"', dat[2]:gsub("\n","\\n"), '"}\n')
else
out:write(',nil}\n')
end
end
end
out:close()
end

self.sharedItemList = { }
self.sharedItemSetList = { }

Expand Down Expand Up @@ -231,6 +209,28 @@ the "Releases" section of the GitHub page.]])
self.onFrameFuncs = { }
end

function main:RebuildModCache()
-- Update mod cache
local out = io.open("Data/ModCache.lua", "w")
out:write('local c=...')
for line, dat in pairs(modLib.parseModCache) do
if not dat[1] or not dat[1][1] or dat[1][1].name ~= "JewelFunc" then
out:write('c["', line:gsub("\n","\\n"), '"]={')
if dat[1] then
writeLuaTable(out, dat[1])
else
out:write('nil')
end
if dat[2] then
out:write(',"', dat[2]:gsub("\n","\\n"), '"}\n')
else
out:write(',nil}\n')
end
end
end
out:close()
end

function main:LoadTree(treeVersion)
if self.tree[treeVersion] then
data.setJewelRadiiGlobally(treeVersion)
Expand Down