-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
github-actions
committed
May 26, 2022
1 parent
b5e7cf3
commit 95bf370
Showing
2 changed files
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
local a=require("cc.expect")_G.AM_DATA={}local b={["true"]=true,["yes"]=true,["1"]=true,["y"]=true,["t"]=true,["false"]=false,["no"]=false,["0"]=false,["n"]=false,["f"]=false}local function c(d)a.expect(1,d,"string","boolean")if type(d)=="boolean"then return d end;local e=d:lower()e=b[e]if e==nil then error(string.format("Unexpected string bool value: %s",d))end;return e end;local function f(d,g)a.expect(1,d,"string")a.expect(2,g,"string","nil")if g==nil then g=","end;local h={}for i in string.gmatch(d,"([^"..g.."]+)")do table.insert(h,i)end;return h end;local function j(k,l)for m,e in pairs(l)do k[m]=e end;return k end;local function n(o,p)a.expect(1,o,"table")a.expect(2,p,"table")for q,e in ipairs(p)do table.insert(o,e)end;return o end;local function r(s,t)if t==nil then t=true end;local u=type(s)local v;if u=='table'then v={}for w,x in next,s,nil do v[r(w)]=r(x,t)end;if t then setmetatable(v,r(getmetatable(s)))end else v=s end;return v end;local function y(z)a.expect(1,z,"string")z=z.."?ts="..os.time(os.date("!*t"))local A=http.get(z)if A==nil then error(string.format("Bad HTTP Response: %s",z))return end;local B,q=A.getResponseCode()if B~=200 then error(string.format("Bad HTTP code: %d",B))end;return A end;local function C(z,D)a.expect(1,z,"string")a.expect(2,D,"string")if fs.exists(D)then fs.delete(D)end;local A=y(z)local E=fs.open(D,'w')E.write(A.readAll())E.close()end;local function F(z)a.expect(1,z,"string")local A=y(z)return textutils.unserializeJSON(A.readAll())end;local function G(H,...)local I={...}if type(H)=="table"then I=H;H=I[1]table.remove(I,1)end;return H,I end;local function J(K)for m,L in pairs(K)do L.get=function()return settings.get(L.name)end;L.set=function(e)if e==L.default then e=r(L.default)end;if e==nil then settings.unset(L.name)else settings.set(L.name,e)end;settings.save()end;K[m]=L;settings.define(L.name,L)end;return K end;local function M(N)return string.format("/.%s.data",N)end;local function O(K,N)local P=M(N)if _G.AM_DATA[N]==nil and fs.exists(P)then local E=fs.open(P,"r")_G.AM_DATA[N]=textutils.unserialize(E.readAll())E.close()end;if _G.AM_DATA[N]==nil then _G.AM_DATA[N]={}end;for m,Q in pairs(K)do Q.get=function()if _G.AM_DATA[N][Q.name]~=nil then return _G.AM_DATA[N][Q.name]end;if Q.default~=nil then _G.AM_DATA[N][Q.name]=r(Q.default)return _G.AM_DATA[N][Q.name]end;return nil end;Q.set=function(e)local R=false;if e==Q.default or e==nil then _G.AM_DATA[N][Q.name]=nil;R=true else if Q.type~=nil then a.expect(1,e,Q.type)end;_G.AM_DATA[N][Q.name]=e end;local E=fs.open(P,"w")E.write(textutils.serialize(_G.AM_DATA[N]))E.close()if R then _G.AM_DATA[N][Q.name]=r(Q.default)end end;K[m]=Q end;return K end;local S={}S.strBool=c;S.split=f;S.merge=j;S.concat=n;S.copy=r;S.getAndCheck=y;S.download=C;S.getJSON=F;S.cleanEventArgs=G;S.makeSettingWrapper=J;S.makeDataWrapper=O;return S | ||
local a=require("cc.expect")_G.AM_DATA={}local b={["true"]=true,["yes"]=true,["1"]=true,["y"]=true,["t"]=true,["false"]=false,["no"]=false,["0"]=false,["n"]=false,["f"]=false}local function c(d)a.expect(1,d,"string","boolean")if type(d)=="boolean"then return d end;local e=d:lower()e=b[e]if e==nil then error(string.format("Unexpected string bool value: %s",d))end;return e end;local function f(d,g)a.expect(1,d,"string")a.expect(2,g,"string","nil")if g==nil then g=","end;local h={}for i in string.gmatch(d,"([^"..g.."]+)")do table.insert(h,i)end;return h end;local function j(k,l)for m,e in pairs(l)do k[m]=e end;return k end;local function n(o,p)a.expect(1,o,"table")a.expect(2,p,"table")for q,e in ipairs(p)do table.insert(o,e)end;return o end;local function r(s,t)if t==nil then t=true end;local u=type(s)local v;if u=='table'then v={}for w,x in next,s,nil do v[r(w)]=r(x,t)end;if t then setmetatable(v,r(getmetatable(s)))end else v=s end;return v end;local function y(z)a.expect(1,z,"string")z=z.."?ts="..os.time(os.date("!*t"))local A=http.get(z)if A==nil then error(string.format("Bad HTTP Response: %s",z))return end;local B,q=A.getResponseCode()if B~=200 then error(string.format("Bad HTTP code: %d",B))end;return A end;local function C(z,D)a.expect(1,z,"string")a.expect(2,D,"string")if fs.exists(D)then fs.delete(D)end;local A=y(z)local E=fs.open(D,'w')E.write(A.readAll())E.close()end;local function F(z)a.expect(1,z,"string")local A=y(z)return textutils.unserializeJSON(A.readAll())end;local function G(H,...)local I={...}if type(H)=="table"then I=H;H=I[1]table.remove(I,1)end;return H,I end;local function J(K)for m,L in pairs(K)do L.get=function()return settings.get(L.name)end;L.set=function(e)if e==L.default then e=r(L.default)end;if e==nil then settings.unset(L.name)else settings.set(L.name,e)end;settings.save()end;K[m]=L;settings.define(L.name,L)end;return K end;local function M(N)return string.format("/.%s.data",N)end;local function O(K,N)local P=M(N)if _G.AM_DATA[N]==nil and fs.exists(P)then local E=fs.open(P,"r")_G.AM_DATA[N]=textutils.unserialize(E.readAll())E.close()end;if _G.AM_DATA[N]==nil then _G.AM_DATA[N]={}end;for m,Q in pairs(K)do Q.get=function()if _G.AM_DATA[N][Q.name]~=nil then return _G.AM_DATA[N][Q.name]end;if Q.default~=nil then return r(Q.default)end;return nil end;Q.set=function(e)local R=false;if e==Q.default or e==nil then _G.AM_DATA[N][Q.name]=nil;R=true else if Q.type~=nil then a.expect(1,e,Q.type)end;_G.AM_DATA[N][Q.name]=e end;local E=fs.open(P,"w")E.write(textutils.serialize(_G.AM_DATA[N]))E.close()if R then _G.AM_DATA[N][Q.name]=r(Q.default)end end;K[m]=Q end;return K end;local S={}S.strBool=c;S.split=f;S.merge=j;S.concat=n;S.copy=r;S.getAndCheck=y;S.download=C;S.getJSON=F;S.cleanEventArgs=G;S.makeSettingWrapper=J;S.makeDataWrapper=O;return S |