规范代码,大量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

@@ -7,11 +7,11 @@ local BGlist={
}
local BG={
cur="none",
init=nil,
resize=nil,
init=false,
resize=false,
update=NULL,
draw=BGlist.none.draw,
event=nil,
event=false,
discard=NULL,
}

View File

@@ -31,7 +31,7 @@ local ins,rem=table.insert,table.remove
local SCR=SCR
local mx,my,mouseShow=-20,-20,false
local touching=nil--First touching ID(userdata)
local touching--First touching ID(userdata)
local xOy=SCR.xOy
joysticks={}
@@ -146,7 +146,7 @@ function love.touchmoved(id,x,y,dx,dy)
else
WIDGET.moveCursor(x,y)
if not WIDGET.sel then
touching=nil
touching=false
end
end
end
@@ -156,9 +156,9 @@ function love.touchreleased(id,x,y)
if id==touching then
WIDGET.press(x,y)
WIDGET.release(x,y)
touching=nil
touching=false
if WIDGET.sel and not WIDGET.sel.keepFocus then
WIDGET.sel=nil
WIDGET.sel=false
end
end
if SCN.touchUp then SCN.touchUp(id,x,y)end

View File

@@ -8,33 +8,33 @@ local SCN={
cur="NULL",--Current scene name
swapping=false,--If Swapping
stat={
tar=nil, --Swapping target
style=nil, --Swapping style
mid=nil, --Loading point
time=nil, --Full swap time
draw=nil, --Swap draw func
tar=false, --Swapping target
style=false,--Swapping style
mid=false, --Loading point
time=false, --Full swap time
draw=false, --Swap draw func
},
stack={"quit","slowFade"},--Scene stack
scenes=scenes,
--Events
update=nil,
draw=nil,
mouseClick=nil,
touchClick=nil,
mouseDown=nil,
mouseMove=nil,
mouseUp=nil,
wheelMoved=nil,
touchDown=nil,
touchUp=nil,
touchMove=nil,
keyDown=nil,
keyUp=nil,
gamepadDown=nil,
gamepadUp=nil,
socketRead=nil,
update=false,
draw=false,
mouseClick=false,
touchClick=false,
mouseDown=false,
mouseMove=false,
mouseUp=false,
wheelMoved=false,
touchDown=false,
touchUp=false,
touchMove=false,
keyDown=false,
keyUp=false,
gamepadDown=false,
gamepadUp=false,
socketRead=false,
}--Scene datas, returned
function SCN.add(name,scene)

View File

@@ -499,13 +499,13 @@ function WIDGET.newSlider(D)--name,x,y,w[,unit][,smooth][,font][,change],disp,co
},
unit= D.unit or 1,
smooth=nil,
smooth= false,
font= D.font or 30,
change= D.change,
disp= D.disp,
code= D.code,
hide= D.hide,
show= nil,
show= false,
}
if D.smooth~=nil then
_.smooth=D.smooth
@@ -534,7 +534,7 @@ local selector={
type="selector",
ATV=8,--Activating time(0~4)
select=0,--Selected item ID
selText=nil,--Selected item name
selText=false,--Selected item name
}
function selector:reset()
self.ATV=0
@@ -787,7 +787,7 @@ function WIDGET.newTextBox(D)--name,x,y,w[,h][,font][,secret][,regex],hide
end
WIDGET.active={}--Table contains all active widgets
WIDGET.sel=nil--Selected widget
WIDGET.sel=false--Selected widget
function WIDGET.lnk_BACK() SCN.back()end
function WIDGET.lnk_CUSval(k) return function() return CUSTOMENV[k] end end
@@ -813,7 +813,7 @@ WIDGET.indexMeta={
}
function WIDGET.set(list)
kb.setTextInput(false)
WIDGET.sel=nil
WIDGET.sel=false
WIDGET.active=list or NONE
--Reset all widgets
@@ -841,7 +841,7 @@ function WIDGET.moveCursor(x,y)
end
end
if WIDGET.sel and not WIDGET.sel.keepFocus then
WIDGET.sel=nil
WIDGET.sel=false
end
end
function WIDGET.press(x,y)
@@ -852,7 +852,7 @@ function WIDGET.press(x,y)
elseif W.type=="slider"then
WIDGET.drag(x,y)
end
if W.hide and W.hide()then WIDGET.sel=nil end
if W.hide and W.hide()then WIDGET.sel=false end
end
function WIDGET.drag(x,y)
local W=WIDGET.sel
@@ -860,7 +860,7 @@ function WIDGET.drag(x,y)
if W.type=="slider"then
W:drag(x,y)
elseif not W:isAbove(x,y)then
WIDGET.sel=nil
WIDGET.sel=false
end
end
function WIDGET.release(x,y)

View File

@@ -24,7 +24,7 @@ LOADED=false
NOGAME=false
LOGIN=false
EDITING=""
WSCONN=nil
WSCONN=false
math.randomseed(os.time()*626)
love.keyboard.setKeyRepeat(true)

View File

@@ -51,6 +51,6 @@ function back.draw()
gc.pop()
end
function back.discard()
video=nil
video=false
end
return back

View File

@@ -70,6 +70,6 @@ function back.draw()
gc.pop()
end
function back.discard()
petal=nil
petal=false
end
return back

View File

@@ -43,6 +43,6 @@ function back.draw()
gc.translate(10,10)
end
function back.discard()
stars=nil
stars=false
end
return back

View File

@@ -38,6 +38,6 @@ function back.draw()
end
end
function back.discard()
ring=nil
ring=false
end
return back

View File

@@ -68,6 +68,6 @@ function back.event(level)
end
end
function back.discard()
bar,crystal=nil
bar,crystal=false,false
end
return back

View File

@@ -44,7 +44,7 @@ function destroyPlayers()
CC.free(P.bot_opt)
CC.free(P.bot_wei)
CC.destroy(P.AI_bot)
P.AI_mode=nil
P.AI_mode=false
end
PLAYERS[i]=nil
end
@@ -137,7 +137,7 @@ function pasteSequence(str)
for _=1,b-32 do
ins(bag,reg)
end
reg=nil
reg=false
end
end
end
@@ -293,7 +293,7 @@ function pasteMission(str)
for _=1,b-113 do
ins(mission,reg)
end
reg=nil
reg=false
end
end
end
@@ -356,7 +356,7 @@ function randomTarget(P)--Return a random opponent for P
end
end
function freshMostDangerous()
GAME.mostDangerous,GAME.secDangerous=nil
GAME.mostDangerous,GAME.secDangerous=false,false
local m,m2=0,0
for i=1,#PLAYERS.alive do
local h=#PLAYERS.alive[i].field
@@ -376,7 +376,7 @@ function freshMostDangerous()
end
end
function freshMostBadge()
GAME.mostBadge,GAME.secBadge=nil
GAME.mostBadge,GAME.secBadge=false,false
local m,m2=0,0
for i=1,#PLAYERS.alive do
local P=PLAYERS.alive[i]
@@ -463,12 +463,12 @@ function applyCustomGame()
if BAG[1]then
GAME.modeEnv.bag=BAG
else
GAME.modeEnv.bag=nil
GAME.modeEnv.bag=false
end
if MISSION[1]then
GAME.modeEnv.mission=MISSION
else
GAME.modeEnv.mission=nil
GAME.modeEnv.mission=false
end
end
function loadGame(M,ifQuickPlay)--Load a mode and go to game scene
@@ -582,11 +582,11 @@ function resetGameData(args)
for i=1,#PLAYERS do
PLAYERS[i]:changeAtk(randomTarget(PLAYERS[i]))
end
GAME.stage=nil
GAME.mostBadge=nil
GAME.secBadge=nil
GAME.mostDangerous=nil
GAME.secDangerous=nil
GAME.stage=false
GAME.mostBadge=false
GAME.secBadge=false
GAME.mostDangerous=false
GAME.secDangerous=false
GAME.stage=1
end
STAT.game=STAT.game+1

View File

@@ -206,42 +206,42 @@ GAME={--Global game data
frame=0, --Frame count
result=false, --Game result (string)
rank=nil, --Rank reached
rank=false, --Rank reached
pauseTime=0, --Time paused
pauseCount=0, --Pausing count
warnLVL0=0, --Warning level
warnLVL=0, --Warning level (show)
seed=1046101471, --Game seed
curMode=nil, --Current gamemode object
curMode=false, --Current gamemode object
mod={}, --List of loaded mods
modeEnv=nil, --Current gamemode environment
modeEnv=false, --Current gamemode environment
setting={}, --Game settings
rep={}, --Recording list, key,time,key,time...
recording=false, --If recording
replaying=false, --If replaying
saved=false, --If recording saved
prevBG=nil, --Previous background, for restore BG when quit setting page
prevBG=false, --Previous background, for restore BG when quit setting page
--Data for royale mode
stage=nil, --Game stage
mostBadge=nil, --Most badge owner
secBadge=nil, --Second badge owner
mostDangerous=nil, --Most dangerous player
secDangerous=nil, --Second dangerous player
stage=false, --Game stage
mostBadge=false, --Most badge owner
secBadge=false, --Second badge owner
mostDangerous=false,--Most dangerous player
secDangerous=false, --Second dangerous player
}
--Userdata tables
RANKS=FILE.load("conf/unlock")or{sprint_10=0}--Ranks of modes
USER=FILE.load("conf/user")or{--User infomation
email=nil,
auth_token=nil,
access_token=nil,
email=false,
auth_token=false,
access_token=false,
username=nil,
motto=nil,
avatar=nil,
username=false,
motto=false,
avatar=false,
xp=0,lv=1,
}
SETTING={--Settings
@@ -319,7 +319,7 @@ else
clear={},spin={},
pc=0,hpc=0,b2b=0,b3b=0,score=0,
lastPlay="sprint_10",--Last played mode ID
date=nil,
date=false,
todayTime=0,
}for i=1,29 do STAT.clear[i]={0,0,0,0,0,0}STAT.spin[i]={0,0,0,0,0,0,0}end
end

View File

@@ -5,7 +5,6 @@ return{
drop=1e99,lock=1e99,
holdCount=0,
dropPiece=function(P)P:lose()end,
task=nil,
bg="bg1",bgm="new era",
},
pauseLimit=true,

View File

@@ -61,7 +61,7 @@ return{
PLY.newPlayer(1)
local L=GAME.modeEnv.opponent
if L~=0 then
GAME.modeEnv.target=nil
GAME.modeEnv.target=false
if L<6 then
PLY.newAIPlayer(2,AIBUILDER("9S",2*L))
else

View File

@@ -42,7 +42,7 @@ return{
PLY.newPlayer(1)
local L=GAME.modeEnv.opponent
if L~=0 then
GAME.modeEnv.target=nil
GAME.modeEnv.target=false
if L<6 then
PLY.newAIPlayer(2,AIBUILDER("9S",2*L))
else

View File

@@ -7,7 +7,7 @@ local function check_LVup(P)
--Stage 1: clear 3 techrash
if T==12 then--Stage 2: swap color of S/Z & J/L
P.waiting=30
P.curMission=nil
P.curMission=false
ENV.skin[1],ENV.skin[2]=ENV.skin[2],ENV.skin[1]
ENV.skin[3],ENV.skin[4]=ENV.skin[4],ENV.skin[3]

View File

@@ -130,7 +130,7 @@ local function newEmptyPlayer(id,mini)
P.atker,P.atking,P.lastRecv={}
P.dropDelay,P.lockDelay=0,0
P.showTime=nil
P.showTime=false
P.keepVisible=true
--P.cur={bk=matrix[2], id=shapeID, color=colorID, name=nameID}
@@ -165,7 +165,7 @@ local function newEmptyPlayer(id,mini)
P.type="none"
P.sound=false
-- P.newNext=nil--Call prepareSequence()to get a function to get new next
-- P.newNext=false--Call prepareSequence()to get a function to get new next
P.keyPressing={}for i=1,12 do P.keyPressing[i]=false end
P.movDir,P.moving,P.downing=0,0,0--Last move key,DAS charging,downDAS charging
@@ -184,7 +184,7 @@ local function newEmptyPlayer(id,mini)
P.bonus={}--Text objects
P.endCounter=0--Used after gameover
P.result=nil--String:"WIN"/"K.O."
P.result=false--String:"WIN"/"K.O."
return P
end
@@ -272,23 +272,23 @@ local function applyGameEnv(P)--Finish gameEnv processing
if ENV.nextCount==0 then ENV.nextPos=false end
if P.mini then
ENV.lockFX=nil
ENV.dropFX=nil
ENV.moveFX=nil
ENV.clearFX=nil
ENV.splashFX=nil
ENV.shakeFX=nil
ENV.text=nil
ENV.lockFX=false
ENV.dropFX=false
ENV.moveFX=false
ENV.clearFX=false
ENV.splashFX=false
ENV.shakeFX=false
ENV.text=false
else
if ENV.lockFX==0 then ENV.lockFX=nil end
if ENV.dropFX==0 then ENV.dropFX=nil end
if ENV.moveFX==0 then ENV.moveFX=nil end
if ENV.clearFX==0 then ENV.clearFX=nil end
if ENV.splashFX==0 then ENV.splashFX=nil end
if ENV.shakeFX==0 then ENV.shakeFX=nil end
if ENV.lockFX==0 then ENV.lockFX=false end
if ENV.dropFX==0 then ENV.dropFX=false end
if ENV.moveFX==0 then ENV.moveFX=false end
if ENV.clearFX==0 then ENV.clearFX=false end
if ENV.splashFX==0 then ENV.splashFX=false end
if ENV.shakeFX==0 then ENV.shakeFX=false end
end
if ENV.ghost==0 then ENV.ghost=nil end
if ENV.center==0 then ENV.center=nil end
if ENV.ghost==0 then ENV.ghost=false end
if ENV.center==0 then ENV.center=false end
end
--------------------------</Lib Func>--------------------------

View File

@@ -400,7 +400,7 @@ function Player.changeAtk(P,R)
P.atking=R
ins(R.atker,P)
else
P.atking=nil
P.atking=false
end
end
function Player.freshBlock(P,mode)--string mode: push/move/fresh/newBlock
@@ -1332,7 +1332,7 @@ do--Player.drop(P)--Place piece
P.curMission=P.curMission+1
SFX.play("reach")
if P.curMission>#ENV.mission then
P.curMission=nil
P.curMission=false
if not finish then finish="finish"end
end
elseif ENV.missionKill then

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},
}

View File

@@ -17,8 +17,8 @@ function Tick.httpREQ_getAccessToken(task)
end
else
LOGIN=false
USER.access_token=nil
USER.auth_token=nil
USER.access_token=false
USER.auth_token=false
local err=json.decode(response.body)
if err then
LOG.print(text.loginFailed..": "..text.netErrorCode..response.code.."-"..err.message,"warn")
@@ -54,7 +54,7 @@ local function tick_wsCONN_read()
end
elseif readErr then
wsWrite("/quit")
WSCONN=nil
WSCONN=false
LOG.print(text.wsDisconnected,"warn")
return
end