规范代码,大量xxx=nil换成xxx=false

This commit is contained in:
MrZ626
2020-12-22 14:54:01 +08:00
parent f611199fab
commit fe2abf6903
25 changed files with 127 additions and 128 deletions

View File

@@ -31,7 +31,7 @@ local scene={}
function scene.sceneInit()
heartBeatTimer=0
remain=nil
remain=false
if #texts==0 then
ins(texts,{COLOR.dG,text.chatStart})
@@ -48,7 +48,7 @@ function scene.sceneInit()
end
function scene.sceneBack()
wsWrite("/quit")
WSCONN=nil
WSCONN=false
LOG.print(text.wsDisconnected,"warn")
end

View File

@@ -11,7 +11,7 @@ function scene.sceneInit()
texts=require"parts/updateLog"
scrollPos=1
if newVersionLaunch then
newVersionLaunch=nil
newVersionLaunch=false
scrollPos=3
end
end

View File

@@ -44,12 +44,12 @@ local scene={}
local selected--Mod selected
function scene.sceneInit()
selected=nil
selected=false
BG.set("tunnel")
end
function scene.mouseMove(x,y)
selected=nil
selected=false
for _,M in next,MODOPT do
if(x-M.x)^2+(y-M.y)^2<2000 then
selected=M

View File

@@ -7,15 +7,15 @@ local int,abs=math.floor,math.abs
local sin=math.sin
local mapCam={
sel=nil,--Selected mode ID
sel=false,--Selected mode ID
xOy=mt.newTransform(0,0,0,1),--Transformation for map display
keyCtrl=false,--If controlling with key
--For auto zooming when enter/leave scene
zoomMethod=nil,
zoomK=nil,
zoomMethod=false,
zoomK=false,
}
local touchDist=nil
local touchDist
local scene={}
@@ -82,7 +82,7 @@ function scene.mouseClick(x,y)
mapCam.sel=SEL
SFX.play("click")
else
mapCam.sel=nil
mapCam.sel=false
end
elseif _ then
scene.keyDown("return")
@@ -91,7 +91,7 @@ function scene.mouseClick(x,y)
mapCam.keyCtrl=false
end
function scene.touchDown()
touchDist=nil
touchDist=false
end
function scene.touchMove(_,x,y,dx,dy)
local L=tc.getTouches()
@@ -124,7 +124,7 @@ function scene.keyDown(key)
SCN.go("mod")
elseif key=="escape"then
if mapCam.sel then
mapCam.sel=nil
mapCam.sel=false
else
SCN.back()
end

View File

@@ -31,7 +31,7 @@ function scene.sceneInit()
GAME.restartCount=0
if GAME.init then
resetGameData()
GAME.init=nil
GAME.init=false
end
noKey=GAME.replaying
noTouch=not SETTING.VKSwitch or noKey

View File

@@ -7,13 +7,13 @@ local scene={}
local defaultSetSelect
local snapUnit
local select--Button selected
local selected--Button selected
function scene.sceneInit()
BG.set("rainbow")
defaultSetSelect=1
snapUnit=1
select=nil
selected=false
end
function scene.sceneBack()
FILE.save(VK_org,"conf/virtualkey")
@@ -36,34 +36,34 @@ local function onVK_org(x,y)
end
function scene.mouseDown(x,y,k)
if k==2 then SCN.back()end
select=onVK_org(x,y)or select
selected=onVK_org(x,y)or selected
end
function scene.mouseMove(_,_,dx,dy)
if select and ms.isDown(1)and not WIDGET.sel then
local B=VK_org[select]
if selected and ms.isDown(1)and not WIDGET.sel then
local B=VK_org[selected]
B.x,B.y=B.x+dx,B.y+dy
end
end
function scene.mouseUp()
if select then
local B=VK_org[select]
if selected then
local B=VK_org[selected]
local k=snapUnit
B.x,B.y=int(B.x/k+.5)*k,int(B.y/k+.5)*k
end
end
function scene.touchDown(_,x,y)
select=onVK_org(x,y)or select
selected=onVK_org(x,y)or selected
end
function scene.touchUp()
if select then
local B=VK_org[select]
if selected then
local B=VK_org[selected]
local k=snapUnit
B.x,B.y=int(B.x/k+.5)*k,int(B.y/k+.5)*k
end
end
function scene.touchMove(_,_,_,dx,dy)
if select and not WIDGET.sel then
local B=VK_org[select]
if selected and not WIDGET.sel then
local B=VK_org[selected]
B.x,B.y=B.x+dx,B.y+dy
end
end
@@ -73,7 +73,7 @@ local function VirtualkeyPreview()
for i=1,#VK_org do
local B=VK_org[i]
if B.ava then
local c=select==i and .6 or 1
local c=selected==i and .6 or 1
gc.setColor(c,1,c,SETTING.VKAlpha)
gc.setLineWidth(B.r*.07)
gc.circle("line",B.x,B.y,B.r,10)
@@ -190,7 +190,7 @@ scene.widgetList={
end
end
defaultSetSelect=defaultSetSelect%5+1
select=nil
selected=false
LOG.print("[ "..defaultSetSelect.." ]")
end},
WIDGET.newSelector{name="snap", x=760,y=90,w=200,h=80,color="yellow",list={1,10,20,40,60,80},disp=function()return snapUnit end,code=function(i)snapUnit=i end},
@@ -201,15 +201,15 @@ scene.widgetList={
WIDGET.newButton{name="back", x=760,y=190,w=200,h=80,font=35,code=WIDGET.lnk_BACK},
WIDGET.newSlider{name="size", x=450,y=270,w=460,unit=19,font=40,show="vkSize",
disp=function()
return VK_org[select].r/10-1
return VK_org[selected].r/10-1
end,
code=function(v)
if select then
VK_org[select].r=(v+1)*10
if selected then
VK_org[selected].r=(v+1)*10
end
end,
hide=function()
return not select
return not selected
end},
}