修改观战状态检测

整理代码
This commit is contained in:
MrZ_26
2022-10-24 15:09:33 +08:00
parent a4db061485
commit b668fa4750
4 changed files with 10 additions and 11 deletions

View File

@@ -12,7 +12,7 @@ local PLY={draw=ply_draw}
local modeDataMeta do local modeDataMeta do
local rawset=rawset local rawset=rawset
modeDataMeta={ modeDataMeta={
__index=function(self,k) rawset(self,k,0)return 0 end, __index=function(self,k) rawset(self,k,0) return 0 end,
__newindex=function(self,k,v) rawset(self,k,v) end, __newindex=function(self,k,v) rawset(self,k,v) end,
} }
end end

View File

@@ -6,9 +6,9 @@ local showEmail=true
local function _login() local function _login()
local email,password=emailBox:getText(),passwordBox:getText() local email,password=emailBox:getText(),passwordBox:getText()
if not STRING.simpEmailCheck(email) then if not STRING.simpEmailCheck(email) then
MES.new('error',text.wrongEmail)return MES.new('error',text.wrongEmail) return
elseif #password==0 then elseif #password==0 then
MES.new('error',text.noPassword)return MES.new('error',text.noPassword) return
end end
NET.pwLogin(email,password) NET.pwLogin(email,password)
end end

View File

@@ -89,8 +89,8 @@ end
scene.mouseDown=NULL scene.mouseDown=NULL
function scene.mouseMove(x,y) NETPLY.mouseMove(x,y) end function scene.mouseMove(x,y) NETPLY.mouseMove(x,y) end
function scene.touchDown(x,y) function scene.touchDown(x,y)
if not playing then NETPLY.mouseMove(x,y)return end if not playing then NETPLY.mouseMove(x,y) return end
if noTouch then return end if NET.spectate or noTouch then return end
local t=VK.on(x,y) local t=VK.on(x,y)
if t then if t then
@@ -99,7 +99,7 @@ function scene.touchDown(x,y)
end end
end end
function scene.touchUp(x,y) function scene.touchUp(x,y)
if not playing or noTouch then return end if not playing or NET.spectate or noTouch then return end
local n=VK.on(x,y) local n=VK.on(x,y)
if n then if n then
PLAYERS[1]:releaseKey(n) PLAYERS[1]:releaseKey(n)
@@ -149,7 +149,7 @@ function scene.keyDown(key,isRep)
WIDGET.focus(inputBox) WIDGET.focus(inputBox)
inputBox:keypress(key) inputBox:keypress(key)
elseif playing then elseif playing then
if noKey or isRep then return end if NET.spectate or noKey or isRep then return end
local k=KEY_MAP.keyboard[key] local k=KEY_MAP.keyboard[key]
if k and k>0 then if k and k>0 then
PLAYERS[1]:pressKey(k) PLAYERS[1]:pressKey(k)
@@ -168,7 +168,7 @@ function scene.keyDown(key,isRep)
end end
end end
function scene.keyUp(key) function scene.keyUp(key)
if not playing or noKey then return end if not playing or NET.spectate or noKey then return end
local k=KEY_MAP.keyboard[key] local k=KEY_MAP.keyboard[key]
if k and k>0 then if k and k>0 then
PLAYERS[1]:releaseKey(k) PLAYERS[1]:releaseKey(k)
@@ -253,8 +253,7 @@ function scene.update(dt)
for i=1,#NETPLY.list do for i=1,#NETPLY.list do
NETPLY.list[i].readyMode='Playing' NETPLY.list[i].readyMode='Playing'
end end
noKey=PLAYERS[1].uid~=USER.uid NET.spectate=PLAYERS[1].uid~=USER.uid
noTouch=noKey
end end
end end
end end

View File

@@ -10,7 +10,7 @@ local function _parseCB()
-- Decode -- Decode
s=STRING.unpackText(s) s=STRING.unpackText(s)
if not s then MES.new('error',text.dataCorrupted)return end if not s then MES.new('error',text.dataCorrupted) return end
s=loadstring(s) s=loadstring(s)
if s then if s then