整理代码(主要清除所有redefine-local)
This commit is contained in:
@@ -52,17 +52,17 @@ local swap={
|
||||
none={1,0,NULL},--swapTime, changeTime, drawFunction
|
||||
flash={8,1,function()gc.clear(1,1,1)end},
|
||||
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.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
end},
|
||||
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.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
end},
|
||||
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.rectangle("fill",0,0,SCR.w,SCR.h)
|
||||
end},
|
||||
|
||||
@@ -208,7 +208,7 @@ do--json
|
||||
-- SOFTWARE.
|
||||
--
|
||||
|
||||
local chr=string.char
|
||||
local char=string.char
|
||||
json = {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -343,14 +343,14 @@ do--json
|
||||
-- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
|
||||
local f = math.floor
|
||||
if n <= 0x7f then
|
||||
return chr(n)
|
||||
return char(n)
|
||||
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
|
||||
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)
|
||||
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)
|
||||
end
|
||||
error(string.format("invalid unicode codepoint '%x'", n))
|
||||
|
||||
@@ -46,12 +46,12 @@ function VOC.loadAll()
|
||||
end
|
||||
|
||||
function VOC.getFreeChannel()
|
||||
local i=#voiceQueue
|
||||
for i=1,i do
|
||||
local l=#voiceQueue
|
||||
for i=1,l do
|
||||
if #voiceQueue[i]==0 then return i end
|
||||
end
|
||||
voiceQueue[i+1]={s=0}
|
||||
return i+1
|
||||
voiceQueue[l+1]={s=0}
|
||||
return l+1
|
||||
end
|
||||
function VOC.getCount()
|
||||
return #voiceQueue
|
||||
@@ -92,8 +92,8 @@ function VOC.update()
|
||||
end
|
||||
elseif Q.s==3 then--Playing 12 same time
|
||||
if not Q[1]:isPlaying()then
|
||||
for i=1,#Q do
|
||||
Q[i]=Q[i+1]
|
||||
for j=1,#Q do
|
||||
Q[j]=Q[j+1]
|
||||
end
|
||||
Q.s=Q[2]and 2 or 4
|
||||
end
|
||||
|
||||
@@ -384,8 +384,8 @@ function slider:draw()
|
||||
if not self.smooth then
|
||||
gc.setLineWidth(2)
|
||||
for p=0,self.unit do
|
||||
local x=x+(x2-x)*p/self.unit
|
||||
gc.line(x,y+7,x,y-7)
|
||||
local X=x+(x2-x)*p/self.unit
|
||||
gc.line(X,y+7,X,y-7)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -731,8 +731,8 @@ function WIDGET.press(x,y)
|
||||
end
|
||||
elseif W.type=="textBox"then
|
||||
if MOBILE then
|
||||
local _,y=xOy:transformPoint(0,W.y+W.h)
|
||||
kb.setTextInput(true,0,y,1,1)
|
||||
local _,y1=xOy:transformPoint(0,W.y+W.h)
|
||||
kb.setTextInput(true,0,y1,1,1)
|
||||
end
|
||||
end
|
||||
if W.hide and W.hide()then WIDGET.sel=nil end
|
||||
|
||||
@@ -51,7 +51,7 @@ return{
|
||||
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,
|
||||
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
|
||||
end,
|
||||
}
|
||||
@@ -18,7 +18,8 @@ local function score(P)
|
||||
SFX.play("blip_1")
|
||||
elseif MD.point>=100*(MD.event+1)then
|
||||
--Level up!
|
||||
local s=MD.event+1;MD.event=s
|
||||
s=MD.event+1
|
||||
MD.event=s
|
||||
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")
|
||||
E.lock=death_lock[s]
|
||||
|
||||
@@ -17,7 +17,8 @@ local function score(P)
|
||||
SFX.play("blip_1")
|
||||
elseif MD.point>=100*(MD.event+1)then
|
||||
--Level up!
|
||||
local s=MD.event+1;MD.event=s
|
||||
s=MD.event+1
|
||||
MD.event=s
|
||||
local E=P.gameEnv
|
||||
BG.set(s==1 and"bg1"or s==2 and"bg2"or s==3 and"rainbow"or "rainbow2")
|
||||
E.lock=rush_lock[s]
|
||||
|
||||
@@ -14,7 +14,8 @@ local function score(P)
|
||||
if MD.point%100==99 then SFX.play("blip_1")end
|
||||
if int(MD.point*.01)>MD.event then
|
||||
--Level up!
|
||||
local s=MD.event+1;MD.event=s
|
||||
s=MD.event+1
|
||||
MD.event=s
|
||||
local E=P.gameEnv
|
||||
if s<4 then
|
||||
P:showTextF(text.stage:gsub("$1",s),0,-120,80,"fly")
|
||||
|
||||
@@ -151,8 +151,8 @@ local function getScore(field,cb,cy)
|
||||
height[x]=h
|
||||
if x>3 and x<8 and h>highest then highest=h end
|
||||
if h>1 then
|
||||
for h=h-1,1,-1 do
|
||||
if field[h][x]==0 then
|
||||
for h1=h-1,1,-1 do
|
||||
if field[h1][x]==0 then
|
||||
hole=hole+1
|
||||
if hole==5 then break end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ SETTING={
|
||||
lang=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},
|
||||
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
|
||||
block=true,ghost=.3,center=1,
|
||||
@@ -56,9 +56,6 @@ SETTING={
|
||||
VKIcon=true,--If disp icon
|
||||
VKAlpha=.3,
|
||||
}
|
||||
for i=1,25 do
|
||||
SETTING.face[i]=0
|
||||
end
|
||||
|
||||
STAT={
|
||||
version=gameVersion,
|
||||
|
||||
@@ -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
|
||||
local function collect(T)--Make all vec point to the same vec
|
||||
if type(T)=="table"then
|
||||
for _,T in next,T do
|
||||
for k,vec in next,T do
|
||||
T[k]=map[vec[1]][vec[2]]
|
||||
for _,t in next,T do
|
||||
for k,vec in next,t do
|
||||
t[k]=map[vec[1]][vec[2]]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -42,8 +42,8 @@ local function reflect(a)
|
||||
b[13]=flipList(a[31])
|
||||
return b
|
||||
end
|
||||
local function pushZero(T)
|
||||
for _,L in next,T do
|
||||
local function pushZero(t)
|
||||
for _,L in next,t do
|
||||
if type(L)=="table"then
|
||||
for _,v in next,L do
|
||||
table.insert(v,1,zero)
|
||||
@@ -55,8 +55,8 @@ end
|
||||
local TRS
|
||||
do
|
||||
local OspinList={
|
||||
{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
|
||||
{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
|
||||
{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
|
||||
{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}},
|
||||
[13]={{ 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)
|
||||
if P.human then SFX.fieldPlay("rotate",nil,P)end
|
||||
if not P.gameEnv.ospin then return end
|
||||
@@ -131,7 +131,7 @@ do
|
||||
if D==L[1]then
|
||||
local id,dir=L[2],L[3]
|
||||
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
|
||||
local C=P.cur
|
||||
C.id=id
|
||||
|
||||
@@ -746,10 +746,10 @@ local Pdraw_norm do
|
||||
mText(drawableText.next,378,-15)
|
||||
N=1
|
||||
while N<=ENV.next and P.next[N]do
|
||||
local b,c=P.next[N].bk,P.next[N].color
|
||||
for i=1,#b do for j=1,#b[1] do
|
||||
if b[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)
|
||||
local bk,clr=P.next[N].bk,P.next[N].color
|
||||
for i=1,#bk do for j=1,#bk[1] do
|
||||
if bk[i][j]then
|
||||
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
|
||||
N=N+1
|
||||
@@ -2182,9 +2182,9 @@ do--player.drop(P)--Place piece
|
||||
::L1::
|
||||
if y then
|
||||
x=CX+x-1
|
||||
for y=y0+y,#P.field do
|
||||
for y1=y0+y,#P.field do
|
||||
--Roof=finesse
|
||||
if P:solid(x,y)then
|
||||
if P:solid(x,y1)then
|
||||
finesse=true
|
||||
goto L2
|
||||
end
|
||||
@@ -2727,9 +2727,9 @@ function player.lose(P)
|
||||
P.killMark=A.id==1
|
||||
end
|
||||
A.modeData.point,A.badge=A.modeData.point+1,A.badge+P.badge+1
|
||||
for i=A.strength+1,4 do
|
||||
if A.badge>=royaleData.powerUp[i]then
|
||||
A.strength=i
|
||||
for j=A.strength+1,4 do
|
||||
if A.badge>=royaleData.powerUp[j]then
|
||||
A.strength=j
|
||||
A.frameColor=frameColor[A.strength]
|
||||
end
|
||||
end
|
||||
@@ -3143,7 +3143,6 @@ function PLY.newAIPlayer(id,x,y,size,AIdata)
|
||||
loadGameEnv(P)
|
||||
applyGameEnv(P)
|
||||
|
||||
local ENV=P.gameEnv
|
||||
ENV.face={0,0,0,0,0,0,0}
|
||||
ENV.skin={1,5,8,2,10,3,7}
|
||||
prepareSequence(P)
|
||||
|
||||
@@ -426,8 +426,7 @@ do--intro
|
||||
}
|
||||
function Pnt.intro()
|
||||
local S=sceneTemp
|
||||
local t=S.t1
|
||||
local T=(t+110)%300
|
||||
local T=(S.t1+110)%300
|
||||
if T<30 then
|
||||
gc.setLineWidth(4+(30-T)^1.626/62)
|
||||
else
|
||||
@@ -437,12 +436,12 @@ do--intro
|
||||
gc.push("transform")
|
||||
gc.translate(126,226)
|
||||
for i=1,8 do
|
||||
local T=t-i*15
|
||||
if T>0 then
|
||||
local t=S.t1-i*15
|
||||
if t>0 then
|
||||
gc.push("transform")
|
||||
gc.setColor(1,1,1,min(T*.025,1))
|
||||
titleTransform[S.r[i]](T,i)
|
||||
local dt=(t+62-5*i)%300
|
||||
gc.setColor(1,1,1,min(t*.025,1))
|
||||
titleTransform[S.r[i]](t,i)
|
||||
local dt=(S.t1+62-5*i)%300
|
||||
if dt<20 then
|
||||
gc.translate(0,abs(10-dt)-10)
|
||||
end
|
||||
@@ -451,9 +450,8 @@ do--intro
|
||||
end
|
||||
end
|
||||
gc.pop()
|
||||
t=S.t2
|
||||
if t>=80 then
|
||||
gc.setColor(1,1,1,.6+sin((t-80)*.0626)*.3)
|
||||
if S.t2>=80 then
|
||||
gc.setColor(1,1,1,.6+sin((S.t2-80)*.0626)*.3)
|
||||
mText(drawableText.anykey,640,615+sin(Timer()*3)*5)
|
||||
end
|
||||
end
|
||||
@@ -635,12 +633,12 @@ do--mode
|
||||
if kb.isDown("right","d")then x=x+10*k F=true end
|
||||
local js1=joysticks[1]
|
||||
if js1 then
|
||||
local k=js1:getAxis(1)
|
||||
if k~="c"then
|
||||
if k=="u"or k=="ul"or k=="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 k=="l"or k=="ul"or k=="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
|
||||
local dir=js1:getAxis(1)
|
||||
if dir~="c"then
|
||||
if dir=="u"or dir=="ul"or dir=="ur"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 dir=="l"or dir=="ul"or dir=="dl"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
|
||||
@@ -648,17 +646,17 @@ do--mode
|
||||
if F then
|
||||
cam.keyCtrl=true
|
||||
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
|
||||
if modeRanks[name]then
|
||||
local SEL
|
||||
local s=M.size
|
||||
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
|
||||
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
|
||||
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
|
||||
if SEL and cam.sel~=SEL then
|
||||
cam.sel=SEL
|
||||
@@ -1217,7 +1215,7 @@ do--pause
|
||||
val={1/80,1/80,1/80,1/60,1/100,1/40},
|
||||
timing=org=="play",
|
||||
}
|
||||
local S=sceneTemp
|
||||
S=sceneTemp
|
||||
local A,B=S.radar,S.val
|
||||
|
||||
--Normalize Values
|
||||
@@ -2659,14 +2657,14 @@ do--dict
|
||||
for i=1,min(#list,15)do
|
||||
local y=142+35*i
|
||||
i=i+S.scroll
|
||||
local S=list[i]
|
||||
local item=list[i]
|
||||
gc.setColor(0,0,0)
|
||||
gc.print(S[1],29,y-1)
|
||||
gc.print(S[1],29,y+1)
|
||||
gc.print(S[1],31,y-1)
|
||||
gc.print(S[1],31,y+1)
|
||||
gc.setColor(typeColor[S[3]])
|
||||
gc.print(S[1],30,y)
|
||||
gc.print(item[1],29,y-1)
|
||||
gc.print(item[1],29,y+1)
|
||||
gc.print(item[1],31,y-1)
|
||||
gc.print(item[1],31,y+1)
|
||||
gc.setColor(typeColor[item[3]])
|
||||
gc.print(item[1],30,y)
|
||||
end
|
||||
|
||||
gc.setColor(1,1,1)
|
||||
@@ -2757,12 +2755,12 @@ do--stat
|
||||
local S=STAT
|
||||
local X1,X2,Y1,Y2={0,0,0,0},{0,0,0,0},{},{}
|
||||
for i=1,7 do
|
||||
local S,C=S.spin[i],S.clear[i]
|
||||
Y1[i]=S[1]+S[2]+S[3]+S[4]
|
||||
Y2[i]=C[1]+C[2]+C[3]+C[4]
|
||||
local s,c=S.spin[i],S.clear[i]
|
||||
Y1[i]=s[1]+s[2]+s[3]+s[4]
|
||||
Y2[i]=c[1]+c[2]+c[3]+c[4]
|
||||
for j=1,4 do
|
||||
X1[j]=X1[j]+S[j]
|
||||
X2[j]=X2[j]+C[j]
|
||||
X1[j]=X1[j]+s[j]
|
||||
X2[j]=X2[j]+c[j]
|
||||
end
|
||||
end
|
||||
sceneTemp={
|
||||
@@ -3278,12 +3276,12 @@ do--p15
|
||||
local N=S.board[i][j]
|
||||
|
||||
local C=blind and 1 or S.color
|
||||
local backColor=backColor[C]
|
||||
local frontColor=frontColor[C]
|
||||
local back=backColor[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.setColor(frontColor[N])
|
||||
gc.setColor(front[N])
|
||||
gc.rectangle("line",j*160+163,i*160-117,154,154,8)
|
||||
if not blind then
|
||||
gc.setColor(.1,.1,.1)
|
||||
@@ -3573,7 +3571,7 @@ do--pong
|
||||
end
|
||||
if S.state==1 then--Playing
|
||||
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
|
||||
if abs(d)<60 then
|
||||
vx=-vx-(vx>0 and .05 or -.5)
|
||||
|
||||
Reference in New Issue
Block a user