全局变量ACCOUNT改名USER

This commit is contained in:
MrZ626
2020-12-14 15:44:40 +08:00
parent a409557019
commit 4d39924059
7 changed files with 31 additions and 31 deletions

View File

@@ -253,16 +253,16 @@ end
--Collect files --Collect files
if fs.getInfo("data.dat")then if fs.getInfo("data.dat")then
fs.createDirectory("conf") fs.createDirectory("conf")
for _,v in next,{ for k,v in next,{
"settings", ["settings.dat"]="conf/settings",
"unlock", ["unlock.dat"]="conf/unlock",
"data", ["data.dat"]="conf/data",
"key", ["key.dat"]="conf/key",
"virtualkey", ["virtualkey.dat"]="conf/virtualkey",
"account", ["account.dat"]="conf/user",
}do }do
fs.write("conf/"..v,fs.read(v..".dat")) fs.write(v,fs.read(k))
fs.remove(v..".dat") fs.remove(k)
end end
fs.createDirectory("record") fs.createDirectory("record")
for _,name in next,fs.getDirectoryItems("")do for _,name in next,fs.getDirectoryItems("")do
@@ -295,7 +295,7 @@ if fs.getInfo("conf/unlock")then RANKS=FILE.load("conf/unlock")end
if fs.getInfo("conf/data")then STAT=FILE.load("conf/data")end if fs.getInfo("conf/data")then STAT=FILE.load("conf/data")end
if fs.getInfo("conf/key")then keyMap=FILE.load("conf/key")end if fs.getInfo("conf/key")then keyMap=FILE.load("conf/key")end
if fs.getInfo("conf/virtualkey")then VK_org=FILE.load("conf/virtualkey")end if fs.getInfo("conf/virtualkey")then VK_org=FILE.load("conf/virtualkey")end
if fs.getInfo("conf/account")then ACCOUNT=FILE.load("conf/account")end if fs.getInfo("conf/user")then USER=FILE.load("conf/user")end
for _,v in next,{ for _,v in next,{
"tech_ultimate.dat", "tech_ultimate.dat",

View File

@@ -302,7 +302,7 @@ for i=1,25 do
STAT.spin[i]={0,0,0,0,0,0,0} STAT.spin[i]={0,0,0,0,0,0,0}
end end
ACCOUNT={ USER={
email=nil, email=nil,
auth_token=nil, auth_token=nil,
access_token=nil, access_token=nil,

View File

@@ -44,7 +44,7 @@ function scene.sceneInit()
BG.set("none") BG.set("none")
wsConnect( wsConnect(
TICK.wsCONN_connect, TICK.wsCONN_connect,
PATH.socket..PATH.chat.."?email="..urlEncode(ACCOUNT.email).."&access_token="..urlEncode(ACCOUNT.access_token) PATH.socket..PATH.chat.."?email="..urlEncode(USER.email).."&access_token="..urlEncode(USER.access_token)
) )
end end
function scene.sceneBack() function scene.sceneBack()

View File

@@ -180,15 +180,15 @@ function scene.update()
SFX.play("welcome_sfx") SFX.play("welcome_sfx")
VOC.play("welcome_voc") VOC.play("welcome_voc")
httpRequest(tick_httpREQ_launch,PATH.api..PATH.appInfo) httpRequest(tick_httpREQ_launch,PATH.api..PATH.appInfo)
if ACCOUNT.auth_token and ACCOUNT.email then if USER.auth_token and USER.email then
httpRequest( httpRequest(
tick_httpREQ_autoLogin, tick_httpREQ_autoLogin,
PATH.api..PATH.auth, PATH.api..PATH.auth,
"GET", "GET",
{["Content-Type"]="application/json"}, {["Content-Type"]="application/json"},
json.encode{ json.encode{
email=ACCOUNT.email, email=USER.email,
auth_token=ACCOUNT.auth_token, auth_token=USER.auth_token,
} }
) )
end end

View File

@@ -9,9 +9,9 @@ local function tick_httpREQ_newLogin(task)
if res then if res then
if LOGIN then if LOGIN then
LOG.print(text.loginSuccessed) LOG.print(text.loginSuccessed)
ACCOUNT.email=res.email USER.email=res.email
ACCOUNT.auth_token=res.auth_token USER.auth_token=res.auth_token
FILE.save(ACCOUNT,"conf/account","q") FILE.save(USER,"conf/account","q")
httpRequest( httpRequest(
TICK.httpREQ_getAccessToken, TICK.httpREQ_getAccessToken,
@@ -19,8 +19,8 @@ local function tick_httpREQ_newLogin(task)
"POST", "POST",
{["Content-Type"]="application/json"}, {["Content-Type"]="application/json"},
json.encode{ json.encode{
email=ACCOUNT.email, email=USER.email,
auth_token=ACCOUNT.auth_token, auth_token=USER.auth_token,
} }
) )
else else

View File

@@ -16,8 +16,8 @@ local function tick_httpREQ_checkAccessToken(task)
"POST", "POST",
{["Content-Type"]="application/json"}, {["Content-Type"]="application/json"},
json.encode{ json.encode{
email=ACCOUNT.email, email=USER.email,
auth_token=ACCOUNT.auth_token, auth_token=USER.auth_token,
} }
) )
else else
@@ -82,15 +82,15 @@ scene.widgetList={
WIDGET.newButton{name="offline",x=150,y=220,w=200,h=140,color="lRed", font=40,code=WIDGET.lnk_goScene("mode")}, WIDGET.newButton{name="offline",x=150,y=220,w=200,h=140,color="lRed", font=40,code=WIDGET.lnk_goScene("mode")},
WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=function() WIDGET.newButton{name="online", x=370,y=220,w=200,h=140,color="lCyan", font=40,code=function()
if LOGIN then if LOGIN then
if ACCOUNT.access_token then if USER.access_token then
httpRequest( httpRequest(
tick_httpREQ_checkAccessToken, tick_httpREQ_checkAccessToken,
PATH.api..PATH.access, PATH.api..PATH.access,
"GET", "GET",
{["Content-Type"]="application/json"}, {["Content-Type"]="application/json"},
json.encode{ json.encode{
email=ACCOUNT.email, email=USER.email,
access_token=ACCOUNT.access_token, access_token=USER.access_token,
} }
) )
else else
@@ -100,8 +100,8 @@ scene.widgetList={
"POST", "POST",
{["Content-Type"]="application/json"}, {["Content-Type"]="application/json"},
json.encode{ json.encode{
email=ACCOUNT.email, email=USER.email,
auth_token=ACCOUNT.auth_token, auth_token=USER.auth_token,
} }
) )
end end

View File

@@ -9,16 +9,16 @@ function Tick.httpREQ_getAccessToken(task)
local res=json.decode(response.body) local res=json.decode(response.body)
if res then if res then
LOG.print(text.accessSuccessed) LOG.print(text.accessSuccessed)
ACCOUNT.access_token=res.access_token USER.access_token=res.access_token
FILE.save(ACCOUNT,"conf/account") FILE.save(USER,"conf/account")
SCN.swapTo("netgame") SCN.swapTo("netgame")
else else
LOG.print(text.netErrorCode..response.code..": "..res.message,"warn") LOG.print(text.netErrorCode..response.code..": "..res.message,"warn")
end end
else else
LOGIN=false LOGIN=false
ACCOUNT.access_token=nil USER.access_token=nil
ACCOUNT.auth_token=nil USER.auth_token=nil
local err=json.decode(response.body) local err=json.decode(response.body)
if err then if err then
LOG.print(text.loginFailed..": "..text.netErrorCode..response.code.."-"..err.message,"warn") LOG.print(text.loginFailed..": "..text.netErrorCode..response.code.."-"..err.message,"warn")