1
0
mirror of https://github.com/AR2000AR/openComputers_codes.git synced 2025-09-09 07:01:14 +02:00

lua diagnostic fix

fixed issue raise by lua diagnostic in vscode
This commit is contained in:
2023-01-31 16:26:17 +01:00
parent 06729c7a0b
commit 3020a68281
2 changed files with 14 additions and 9 deletions

View File

@@ -164,13 +164,15 @@ local function buttonEventHandler(buttonName)
end end
end end
local function diskEventHandler(eName, eAddr, ...) local function diskEventHandler(eName, cAddr, cType)
if (mode == MODE_VIEW_ACCOUNT) then if (cType == "drive") then
printStatus("Card inserted") if (mode == MODE_VIEW_ACCOUNT) then
voirCompte(nil, component.proxy(eAddr)) printStatus("Card inserted")
elseif (mode == MODE_CREATE_ACCOUNT_2) then voirCompte(nil, component.proxy(cAddr))
closePopup(diskWaitPopup) elseif (mode == MODE_CREATE_ACCOUNT_2) then
creerCompte(component.drive) closePopup(diskWaitPopup)
creerCompte(component.proxy(cAddr))
end
end end
end end
@@ -297,7 +299,7 @@ local function init()
intListenerId = event.listen("interrupted", closeClient) intListenerId = event.listen("interrupted", closeClient)
touchListenerId = event.listen("touch", function(...) screen:trigger(...) end) touchListenerId = event.listen("touch", function(...) screen:trigger(...) end)
driveListenerId = event.listen("component_added", diskEventHandler, nil, "drive") driveListenerId = event.listen("component_added", diskEventHandler)
magDataListenerId = event.listen("magData", magDataEventHandler) magDataListenerId = event.listen("magData", magDataEventHandler)
end end

View File

@@ -55,6 +55,7 @@ local function parseFolders(pack, repo, info)
error(reason, 2) error(reason, 2)
end end
repeat repeat
---@diagnostic disable-next-line: undefined-field
os.sleep(0) os.sleep(0)
local s, c, reason = pcall(result.finishConnect) local s, c, reason = pcall(result.finishConnect)
if (not s) then if (not s) then
@@ -76,6 +77,7 @@ local function parseFolders(pack, repo, info)
elseif (#data > 0) then elseif (#data > 0) then
sContent = sContent .. data sContent = sContent .. data
end end
---@diagnostic disable-next-line: undefined-field
os.sleep(0) os.sleep(0)
until data == nil --eof until data == nil --eof
return sContent, status, headers return sContent, status, headers
@@ -91,6 +93,7 @@ local function parseFolders(pack, repo, info)
if (tonumber(headers["X-RateLimit-Remaining"][1]) == 0) then if (tonumber(headers["X-RateLimit-Remaining"][1]) == 0) then
print(string.format("No more API request available. More call will be possible at %s", os.date("%H:%M:%S", headers["X-RateLimit-Reset"]))) print(string.format("No more API request available. More call will be possible at %s", os.date("%H:%M:%S", headers["X-RateLimit-Reset"])))
print("Waiting 1 minute") print("Waiting 1 minute")
---@diagnostic disable-next-line: undefined-field
os.sleep(60) os.sleep(60)
end end
until tonumber(headers["X-RateLimit-Remaining"][1]) > 0 until tonumber(headers["X-RateLimit-Remaining"][1]) > 0
@@ -111,7 +114,7 @@ local function parseFolders(pack, repo, info)
return nil return nil
end end
assert(filestring) assert(filestring)
return serial.unserialize(filestring:gsub("%[", "{"):gsub("%]", "}"):gsub("(\"[^%s,]-\")%s?:", "[%1] = "), nil) return serial.unserialize(filestring:gsub("%[", "{"):gsub("%]", "}"):gsub("(\"[^%s,]-\")%s?:", "[%1] = "))
end end
local function nonSpecial(text) local function nonSpecial(text)