Add whitelist capabilities

This commit is contained in:
Max
2026-06-01 13:43:18 +02:00
parent 14961629f2
commit 8d9abc8cb2
3 changed files with 62 additions and 27718 deletions
+35
View File
@@ -32,6 +32,7 @@ local chainItemsByBaseId
local baseItemIds
local itemById
local defaultBaseId
local whitelistLookup
local fallbackIcon = false
local backButton = false
local scrollUpButton = false
@@ -40,8 +41,40 @@ local overviewScrollCurrentRow = 0
local overviewScrollTargetRow = 0
local drawOverview
local function ensureWhitelistLoaded()
if whitelistLookup ~= nil then
return
end
if not fs.exists("whitelist.json") then
whitelistLookup = false
return
end
local file = assert(fs.open("whitelist.json", "r"))
local data = textutils.unserializeJSON(file.readAll())
file.close()
assert(type(data) == "table", "Invalid whitelist.json data")
if #data == 0 then
whitelistLookup = false
return
end
whitelistLookup = {}
for i = 1, #data do
local baseId = data[i]
assert(type(baseId) == "string", "Invalid whitelist.json entry")
whitelistLookup[baseId] = true
end
end
local function ensureChainsLoaded()
if not chainItemsByBaseId then
ensureWhitelistLoaded()
local file = assert(fs.open("atc_chains.json", "r"))
local data = textutils.unserializeJSON(file.readAll())
file.close()
@@ -53,6 +86,7 @@ local function ensureChainsLoaded()
itemById = {}
for _, chain in ipairs(data.chains) do
if not whitelistLookup or whitelistLookup[chain.base_id] then
if not defaultBaseId then
defaultBaseId = chain.base_id
end
@@ -82,6 +116,7 @@ local function ensureChainsLoaded()
end
end
end
end
local function getPageItems(base_id)
ensureChainsLoaded()
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
[
]