整理代码(主要清除所有redefine-local)

This commit is contained in:
MrZ626
2020-10-30 00:01:51 +08:00
parent 1d34b22456
commit 894c17b4c0
13 changed files with 82 additions and 85 deletions

View File

@@ -52,17 +52,17 @@ local swap={
none={1,0,NULL},--swapTime, changeTime, drawFunction none={1,0,NULL},--swapTime, changeTime, drawFunction
flash={8,1,function()gc.clear(1,1,1)end}, flash={8,1,function()gc.clear(1,1,1)end},
fade={30,15,function(t) fade={30,15,function(t)
local t=t>15 and 2-t/15 or t/15 t=t>15 and 2-t/15 or t/15
gc.setColor(0,0,0,t) gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,SCR.w,SCR.h) gc.rectangle("fill",0,0,SCR.w,SCR.h)
end}, end},
fade_togame={120,20,function(t) fade_togame={120,20,function(t)
local t=t>20 and(120-t)/100 or t/20 t=t>20 and(120-t)/100 or t/20
gc.setColor(0,0,0,t) gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,SCR.w,SCR.h) gc.rectangle("fill",0,0,SCR.w,SCR.h)
end}, end},
slowFade={180,90,function(t) slowFade={180,90,function(t)
local t=t>90 and 2-t/90 or t/90 t=t>90 and 2-t/90 or t/90
gc.setColor(0,0,0,t) gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,SCR.w,SCR.h) gc.rectangle("fill",0,0,SCR.w,SCR.h)
end}, end},

View File

@@ -208,7 +208,7 @@ do--json
-- SOFTWARE. -- SOFTWARE.
-- --
local chr=string.char local char=string.char
json = {} json = {}
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@@ -343,14 +343,14 @@ do--json
-- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
local f = math.floor local f = math.floor
if n <= 0x7f then if n <= 0x7f then
return chr(n) return char(n)
elseif n <= 0x7ff then elseif n <= 0x7ff then
return chr(f(n / 64) + 192, n % 64 + 128) return char(f(n / 64) + 192, n % 64 + 128)
elseif n <= 0xffff then elseif n <= 0xffff then
return chr(f(n / 4096) + 224, f(n % 4096 / 64) + 128, return char(f(n / 4096) + 224, f(n % 4096 / 64) + 128,
n % 64 + 128) n % 64 + 128)
elseif n <= 0x10ffff then elseif n <= 0x10ffff then
return chr(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, return char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
f(n % 4096 / 64) + 128, n % 64 + 128) f(n % 4096 / 64) + 128, n % 64 + 128)
end end
error(string.format("invalid unicode codepoint '%x'", n)) error(string.format("invalid unicode codepoint '%x'", n))

View File

@@ -46,12 +46,12 @@ function VOC.loadAll()
end end
function VOC.getFreeChannel() function VOC.getFreeChannel()
local i=#voiceQueue local l=#voiceQueue
for i=1,i do for i=1,l do
if #voiceQueue[i]==0 then return i end if #voiceQueue[i]==0 then return i end
end end
voiceQueue[i+1]={s=0} voiceQueue[l+1]={s=0}
return i+1 return l+1
end end
function VOC.getCount() function VOC.getCount()
return #voiceQueue return #voiceQueue
@@ -92,8 +92,8 @@ function VOC.update()
end end
elseif Q.s==3 then--Playing 12 same time elseif Q.s==3 then--Playing 12 same time
if not Q[1]:isPlaying()then if not Q[1]:isPlaying()then
for i=1,#Q do for j=1,#Q do
Q[i]=Q[i+1] Q[j]=Q[j+1]
end end
Q.s=Q[2]and 2 or 4 Q.s=Q[2]and 2 or 4
end end

View File

@@ -384,8 +384,8 @@ function slider:draw()
if not self.smooth then if not self.smooth then
gc.setLineWidth(2) gc.setLineWidth(2)
for p=0,self.unit do for p=0,self.unit do
local x=x+(x2-x)*p/self.unit local X=x+(x2-x)*p/self.unit
gc.line(x,y+7,x,y-7) gc.line(X,y+7,X,y-7)
end end
end end
@@ -731,8 +731,8 @@ function WIDGET.press(x,y)
end end
elseif W.type=="textBox"then elseif W.type=="textBox"then
if MOBILE then if MOBILE then
local _,y=xOy:transformPoint(0,W.y+W.h) local _,y1=xOy:transformPoint(0,W.y+W.h)
kb.setTextInput(true,0,y,1,1) kb.setTextInput(true,0,y1,1,1)
end end
end end
if W.hide and W.hide()then WIDGET.sel=nil end if W.hide and W.hide()then WIDGET.sel=nil end

View File

@@ -51,7 +51,7 @@ return{
scoreDisp=function(D)return sectionName[int(D[1]*.1)+1].." "..D[2]end, scoreDisp=function(D)return sectionName[int(D[1]*.1)+1].." "..D[2]end,
comp=function(a,b)return a[1]>b[1]or a[1]==b[1]and a[2]>b[2]end, comp=function(a,b)return a[1]>b[1]or a[1]==b[1]and a[2]>b[2]end,
getRank=function(P) getRank=function(P)
local P=P.modeData.point P=P.modeData.point
return P==80 and 5 or P>=70 and 4 or P>=60 and 3 or P>=40 and 2 or P>=20 and 1 or P>=5 and 0 return P==80 and 5 or P>=70 and 4 or P>=60 and 3 or P>=40 and 2 or P>=20 and 1 or P>=5 and 0
end, end,
} }

View File

@@ -18,7 +18,8 @@ local function score(P)
SFX.play("blip_1") SFX.play("blip_1")
elseif MD.point>=100*(MD.event+1)then elseif MD.point>=100*(MD.event+1)then
--Level up! --Level up!
local s=MD.event+1;MD.event=s s=MD.event+1
MD.event=s
local E=P.gameEnv local E=P.gameEnv
BG.set(s==1 and"rainbow"or s==2 and"rainbow2"or s==3 and"lightning"or s==4 and"lightning2"or"lightning") BG.set(s==1 and"rainbow"or s==2 and"rainbow2"or s==3 and"lightning"or s==4 and"lightning2"or"lightning")
E.lock=death_lock[s] E.lock=death_lock[s]

View File

@@ -17,7 +17,8 @@ local function score(P)
SFX.play("blip_1") SFX.play("blip_1")
elseif MD.point>=100*(MD.event+1)then elseif MD.point>=100*(MD.event+1)then
--Level up! --Level up!
local s=MD.event+1;MD.event=s s=MD.event+1
MD.event=s
local E=P.gameEnv local E=P.gameEnv
BG.set(s==1 and"bg1"or s==2 and"bg2"or s==3 and"rainbow"or "rainbow2") BG.set(s==1 and"bg1"or s==2 and"bg2"or s==3 and"rainbow"or "rainbow2")
E.lock=rush_lock[s] E.lock=rush_lock[s]

View File

@@ -14,7 +14,8 @@ local function score(P)
if MD.point%100==99 then SFX.play("blip_1")end if MD.point%100==99 then SFX.play("blip_1")end
if int(MD.point*.01)>MD.event then if int(MD.point*.01)>MD.event then
--Level up! --Level up!
local s=MD.event+1;MD.event=s s=MD.event+1
MD.event=s
local E=P.gameEnv local E=P.gameEnv
if s<4 then if s<4 then
P:showTextF(text.stage:gsub("$1",s),0,-120,80,"fly") P:showTextF(text.stage:gsub("$1",s),0,-120,80,"fly")

View File

@@ -151,8 +151,8 @@ local function getScore(field,cb,cy)
height[x]=h height[x]=h
if x>3 and x<8 and h>highest then highest=h end if x>3 and x<8 and h>highest then highest=h end
if h>1 then if h>1 then
for h=h-1,1,-1 do for h1=h-1,1,-1 do
if field[h][x]==0 then if field[h1][x]==0 then
hole=hole+1 hole=hole+1
if hole==5 then break end if hole==5 then break end
end end

View File

@@ -14,7 +14,7 @@ SETTING={
lang=1, lang=1,
skinSet=1, skinSet=1,
skin={1,7,11,3,14,4,9,1,7,1,7,11,3,14,4,9,14,9,11,3,11,3,1,7,4}, skin={1,7,11,3,14,4,9,1,7,1,7,11,3,14,4,9,14,9,11,3,11,3,1,7,4},
face={}, face={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
--Graphic --Graphic
block=true,ghost=.3,center=1, block=true,ghost=.3,center=1,
@@ -56,9 +56,6 @@ SETTING={
VKIcon=true,--If disp icon VKIcon=true,--If disp icon
VKAlpha=.3, VKAlpha=.3,
} }
for i=1,25 do
SETTING.face[i]=0
end
STAT={ STAT={
version=gameVersion, version=gameVersion,

View File

@@ -6,9 +6,9 @@ local map={}
for x=-3,3 do map[x]={}for y=-3,3 do map[x][y]={x,y}end end for x=-3,3 do map[x]={}for y=-3,3 do map[x][y]={x,y}end end
local function collect(T)--Make all vec point to the same vec local function collect(T)--Make all vec point to the same vec
if type(T)=="table"then if type(T)=="table"then
for _,T in next,T do for _,t in next,T do
for k,vec in next,T do for k,vec in next,t do
T[k]=map[vec[1]][vec[2]] t[k]=map[vec[1]][vec[2]]
end end
end end
end end
@@ -42,8 +42,8 @@ local function reflect(a)
b[13]=flipList(a[31]) b[13]=flipList(a[31])
return b return b
end end
local function pushZero(T) local function pushZero(t)
for _,L in next,T do for _,L in next,t do
if type(L)=="table"then if type(L)=="table"then
for _,v in next,L do for _,v in next,L do
table.insert(v,1,zero) table.insert(v,1,zero)
@@ -55,8 +55,8 @@ end
local TRS local TRS
do do
local OspinList={ local OspinList={
{111,5,2, 0,-1,0},{111,5,2,-1,-1,0},{111,5,0,-1, 0,0},--T {111,5,2, 0,-1,0},{111,5,2,-1,-1,0},{111,5,0,-1, 0,0},--t
{333,5,2,-1,-1,0},{333,5,2, 0,-1,0},{333,5,0, 0, 0,0},--T {333,5,2,-1,-1,0},{333,5,2, 0,-1,0},{333,5,0, 0, 0,0},--t
{313,1,2,-1, 0,0},{313,1,2, 0,-1,0},{313,1,2, 0, 0,0},--Z {313,1,2,-1, 0,0},{313,1,2, 0,-1,0},{313,1,2, 0, 0,0},--Z
{131,2,2, 0, 0,0},{131,2,2,-1,-1,0},{131,2,2,-1, 0,0},--S {131,2,2, 0, 0,0},{131,2,2,-1,-1,0},{131,2,2,-1, 0,0},--S
{331,3,2, 0,-1,0},{113,3,0, 0, 0,0},{113,3,2,-1, 0,0},--J {331,3,2, 0,-1,0},{113,3,0, 0, 0,0},{113,3,2,-1, 0,0},--J
@@ -114,7 +114,7 @@ do
[20]={{ 1, 0},{-1, 0},{ 0,-1}}, [20]={{ 1, 0},{-1, 0},{ 0,-1}},
[13]={{ 0,-1},{ 0, 1},{ 1, 0},{ 0,-2},{ 0, 2}}, [13]={{ 0,-1},{ 0, 1},{ 1, 0},{ 0,-2},{ 0, 2}},
[31]={{ 0,-1},{ 0, 1},{-1, 0},{ 0,-2},{ 0, 2}}, [31]={{ 0,-1},{ 0, 1},{-1, 0},{ 0,-2},{ 0, 2}},
},--T },--t
function(P,d) function(P,d)
if P.human then SFX.fieldPlay("rotate",nil,P)end if P.human then SFX.fieldPlay("rotate",nil,P)end
if not P.gameEnv.ospin then return end if not P.gameEnv.ospin then return end
@@ -131,7 +131,7 @@ do
if D==L[1]then if D==L[1]then
local id,dir=L[2],L[3] local id,dir=L[2],L[3]
local bk=blocks[id][dir] local bk=blocks[id][dir]
local x,y=P.curX+L[4],P.curY+L[5] x,y=P.curX+L[4],P.curY+L[5]
if not P:ifoverlap(bk,x,y)and(L[6]>0 or P:ifoverlap(bk,x-1,y)and P:ifoverlap(bk,x+1,y))and(L[6]==2 or P:ifoverlap(bk,x,y-1))and P:ifoverlap(bk,x,y+1)then if not P:ifoverlap(bk,x,y)and(L[6]>0 or P:ifoverlap(bk,x-1,y)and P:ifoverlap(bk,x+1,y))and(L[6]==2 or P:ifoverlap(bk,x,y-1))and P:ifoverlap(bk,x,y+1)then
local C=P.cur local C=P.cur
C.id=id C.id=id

View File

@@ -746,10 +746,10 @@ local Pdraw_norm do
mText(drawableText.next,378,-15) mText(drawableText.next,378,-15)
N=1 N=1
while N<=ENV.next and P.next[N]do while N<=ENV.next and P.next[N]do
local b,c=P.next[N].bk,P.next[N].color local bk,clr=P.next[N].bk,P.next[N].color
for i=1,#b do for j=1,#b[1] do for i=1,#bk do for j=1,#bk[1] do
if b[i][j]then if bk[i][j]then
gc.draw(blockSkin[c],30*(j+12.6-#b[1]*.5)-30,-30*(i-2.4*N-#b*.5))-- drawCell(i-2.4*N-#b*.5,j+12.6-#b[1]*.5,c) gc.draw(blockSkin[clr],30*(j+12.6-#bk[1]*.5)-30,-30*(i-2.4*N-#bk*.5))-- drawCell(i-2.4*N-#bk*.5,j+12.6-#bk[1]*.5,clr)
end end
end end end end
N=N+1 N=N+1
@@ -2182,9 +2182,9 @@ do--player.drop(P)--Place piece
::L1:: ::L1::
if y then if y then
x=CX+x-1 x=CX+x-1
for y=y0+y,#P.field do for y1=y0+y,#P.field do
--Roof=finesse --Roof=finesse
if P:solid(x,y)then if P:solid(x,y1)then
finesse=true finesse=true
goto L2 goto L2
end end
@@ -2727,9 +2727,9 @@ function player.lose(P)
P.killMark=A.id==1 P.killMark=A.id==1
end end
A.modeData.point,A.badge=A.modeData.point+1,A.badge+P.badge+1 A.modeData.point,A.badge=A.modeData.point+1,A.badge+P.badge+1
for i=A.strength+1,4 do for j=A.strength+1,4 do
if A.badge>=royaleData.powerUp[i]then if A.badge>=royaleData.powerUp[j]then
A.strength=i A.strength=j
A.frameColor=frameColor[A.strength] A.frameColor=frameColor[A.strength]
end end
end end
@@ -3143,7 +3143,6 @@ function PLY.newAIPlayer(id,x,y,size,AIdata)
loadGameEnv(P) loadGameEnv(P)
applyGameEnv(P) applyGameEnv(P)
local ENV=P.gameEnv
ENV.face={0,0,0,0,0,0,0} ENV.face={0,0,0,0,0,0,0}
ENV.skin={1,5,8,2,10,3,7} ENV.skin={1,5,8,2,10,3,7}
prepareSequence(P) prepareSequence(P)

View File

@@ -426,8 +426,7 @@ do--intro
} }
function Pnt.intro() function Pnt.intro()
local S=sceneTemp local S=sceneTemp
local t=S.t1 local T=(S.t1+110)%300
local T=(t+110)%300
if T<30 then if T<30 then
gc.setLineWidth(4+(30-T)^1.626/62) gc.setLineWidth(4+(30-T)^1.626/62)
else else
@@ -437,12 +436,12 @@ do--intro
gc.push("transform") gc.push("transform")
gc.translate(126,226) gc.translate(126,226)
for i=1,8 do for i=1,8 do
local T=t-i*15 local t=S.t1-i*15
if T>0 then if t>0 then
gc.push("transform") gc.push("transform")
gc.setColor(1,1,1,min(T*.025,1)) gc.setColor(1,1,1,min(t*.025,1))
titleTransform[S.r[i]](T,i) titleTransform[S.r[i]](t,i)
local dt=(t+62-5*i)%300 local dt=(S.t1+62-5*i)%300
if dt<20 then if dt<20 then
gc.translate(0,abs(10-dt)-10) gc.translate(0,abs(10-dt)-10)
end end
@@ -451,9 +450,8 @@ do--intro
end end
end end
gc.pop() gc.pop()
t=S.t2 if S.t2>=80 then
if t>=80 then gc.setColor(1,1,1,.6+sin((S.t2-80)*.0626)*.3)
gc.setColor(1,1,1,.6+sin((t-80)*.0626)*.3)
mText(drawableText.anykey,640,615+sin(Timer()*3)*5) mText(drawableText.anykey,640,615+sin(Timer()*3)*5)
end end
end end
@@ -635,12 +633,12 @@ do--mode
if kb.isDown("right","d")then x=x+10*k F=true end if kb.isDown("right","d")then x=x+10*k F=true end
local js1=joysticks[1] local js1=joysticks[1]
if js1 then if js1 then
local k=js1:getAxis(1) local dir=js1:getAxis(1)
if k~="c"then if dir~="c"then
if k=="u"or k=="ul"or k=="ur"then y=y-10*k F=true end if dir=="u"or dir=="ul"or dir=="ur"then y=y-10*k F=true end
if k=="d"or k=="dl"or k=="dl"then y=y+10*k F=true end if dir=="d"or dir=="dl"or dir=="dl"then y=y+10*k F=true end
if k=="l"or k=="ul"or k=="dl"then x=x-10*k F=true end if dir=="l"or dir=="ul"or dir=="dl"then x=x-10*k F=true end
if k=="r"or k=="ur"or k=="dr"then x=x+10*k F=true end if dir=="r"or dir=="ur"or dir=="dr"then x=x+10*k F=true end
end end
end end
end end
@@ -648,17 +646,17 @@ do--mode
if F then if F then
cam.keyCtrl=true cam.keyCtrl=true
end end
local x,y=(cam.x1-180)/cam.k1,cam.y1/cam.k1 local x1,y1=(cam.x1-180)/cam.k1,cam.y1/cam.k1
for name,M in next,Modes do for name,M in next,Modes do
if modeRanks[name]then if modeRanks[name]then
local SEL local SEL
local s=M.size local s=M.size
if M.shape==1 then if M.shape==1 then
if x>M.x-s and x<M.x+s and y>M.y-s and y<M.y+s then SEL=name end if x1>M.x-s and x1<M.x+s and y1>M.y-s and y1<M.y+s then SEL=name end
elseif M.shape==2 then elseif M.shape==2 then
if abs(x-M.x)+abs(y-M.y)<s then SEL=name end if abs(x1-M.x)+abs(y1-M.y)<s then SEL=name end
elseif M.shape==3 then elseif M.shape==3 then
if(x-M.x)^2+(y-M.y)^2<s^2 then SEL=name end if(x1-M.x)^2+(y1-M.y)^2<s^2 then SEL=name end
end end
if SEL and cam.sel~=SEL then if SEL and cam.sel~=SEL then
cam.sel=SEL cam.sel=SEL
@@ -1217,7 +1215,7 @@ do--pause
val={1/80,1/80,1/80,1/60,1/100,1/40}, val={1/80,1/80,1/80,1/60,1/100,1/40},
timing=org=="play", timing=org=="play",
} }
local S=sceneTemp S=sceneTemp
local A,B=S.radar,S.val local A,B=S.radar,S.val
--Normalize Values --Normalize Values
@@ -2659,14 +2657,14 @@ do--dict
for i=1,min(#list,15)do for i=1,min(#list,15)do
local y=142+35*i local y=142+35*i
i=i+S.scroll i=i+S.scroll
local S=list[i] local item=list[i]
gc.setColor(0,0,0) gc.setColor(0,0,0)
gc.print(S[1],29,y-1) gc.print(item[1],29,y-1)
gc.print(S[1],29,y+1) gc.print(item[1],29,y+1)
gc.print(S[1],31,y-1) gc.print(item[1],31,y-1)
gc.print(S[1],31,y+1) gc.print(item[1],31,y+1)
gc.setColor(typeColor[S[3]]) gc.setColor(typeColor[item[3]])
gc.print(S[1],30,y) gc.print(item[1],30,y)
end end
gc.setColor(1,1,1) gc.setColor(1,1,1)
@@ -2757,12 +2755,12 @@ do--stat
local S=STAT local S=STAT
local X1,X2,Y1,Y2={0,0,0,0},{0,0,0,0},{},{} local X1,X2,Y1,Y2={0,0,0,0},{0,0,0,0},{},{}
for i=1,7 do for i=1,7 do
local S,C=S.spin[i],S.clear[i] local s,c=S.spin[i],S.clear[i]
Y1[i]=S[1]+S[2]+S[3]+S[4] Y1[i]=s[1]+s[2]+s[3]+s[4]
Y2[i]=C[1]+C[2]+C[3]+C[4] Y2[i]=c[1]+c[2]+c[3]+c[4]
for j=1,4 do for j=1,4 do
X1[j]=X1[j]+S[j] X1[j]=X1[j]+s[j]
X2[j]=X2[j]+C[j] X2[j]=X2[j]+c[j]
end end
end end
sceneTemp={ sceneTemp={
@@ -3278,12 +3276,12 @@ do--p15
local N=S.board[i][j] local N=S.board[i][j]
local C=blind and 1 or S.color local C=blind and 1 or S.color
local backColor=backColor[C] local back=backColor[C]
local frontColor=frontColor[C] local front=frontColor[C]
gc.setColor(backColor[N]) gc.setColor(back[N])
gc.rectangle("fill",j*160+163,i*160-117,154,154,8) gc.rectangle("fill",j*160+163,i*160-117,154,154,8)
gc.setColor(frontColor[N]) gc.setColor(front[N])
gc.rectangle("line",j*160+163,i*160-117,154,154,8) gc.rectangle("line",j*160+163,i*160-117,154,154,8)
if not blind then if not blind then
gc.setColor(.1,.1,.1) gc.setColor(.1,.1,.1)
@@ -3573,7 +3571,7 @@ do--pong
end end
if S.state==1 then--Playing if S.state==1 then--Playing
if x<160 or x>1120 then if x<160 or x>1120 then
local P=x<160 and S.p1 or S.p2 P=x<160 and S.p1 or S.p2
local d=y-P.y local d=y-P.y
if abs(d)<60 then if abs(d)<60 then
vx=-vx-(vx>0 and .05 or -.5) vx=-vx-(vx>0 and .05 or -.5)