整理代码,较复杂的单行if-then-end拆成多行

This commit is contained in:
MrZ626
2021-09-03 00:28:08 +08:00
parent 827d0cdf5a
commit 57497dbd74
66 changed files with 703 additions and 261 deletions

View File

@@ -260,7 +260,7 @@ jobs:
# In secrets: # In secrets:
# - MACOS_CERTIFICATE: the *.p12 Developer ID Certificate, encoded in base64 # - MACOS_CERTIFICATE: the *.p12 Developer ID Certificate, encoded in base64
# - MACOS_CERTIFICATE_PWD: The password # - MACOS_CERTIFICATE_PWD: The password
env: env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }} MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
run: | run: |

View File

@@ -388,7 +388,7 @@ jobs:
# In secrets: # In secrets:
# - MACOS_CERTIFICATE: the *.p12 Developer ID Certificate, encoded in base64 # - MACOS_CERTIFICATE: the *.p12 Developer ID Certificate, encoded in base64
# - MACOS_CERTIFICATE_PWD: The password # - MACOS_CERTIFICATE_PWD: The password
env: env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }} MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }} MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
run: | run: |

View File

@@ -30,7 +30,7 @@ function BG.setDefault(bg)
BG.default=bg BG.default=bg
end end
function BG.set(background) function BG.set(background)
if not background then background=BG.default end background=background or BG.default
if not BGs[background]or not SETTING.bg then return end if not BGs[background]or not SETTING.bg then return end
if background~=BG.cur then if background~=BG.cur then
BG.discard() BG.discard()

View File

@@ -72,7 +72,7 @@ function BGM.init(list)
return task.code==code and task.args[1]==src return task.code==code and task.args[1]==src
end end
function BGM.play(name) function BGM.play(name)
if not name then name=BGM.default end name=name or BGM.default
if not _load(name)then return end if not _load(name)then return end
if SETTING.bgm==0 then if SETTING.bgm==0 then
BGM.nowPlay=name BGM.nowPlay=name
@@ -81,7 +81,9 @@ function BGM.init(list)
end end
if name and Sources[name]then if name and Sources[name]then
if BGM.nowPlay~=name then if BGM.nowPlay~=name then
if BGM.nowPlay then TASK.new(task_fadeOut,BGM.playing)end if BGM.nowPlay then
TASK.new(task_fadeOut,BGM.playing)
end
TASK.removeTask_iterate(check_curFadeOut,task_fadeOut,Sources[name]) TASK.removeTask_iterate(check_curFadeOut,task_fadeOut,Sources[name])
TASK.removeTask_code(task_fadeIn) TASK.removeTask_code(task_fadeIn)
@@ -107,7 +109,9 @@ function BGM.init(list)
end end
function BGM.stop() function BGM.stop()
TASK.removeTask_code(task_fadeIn) TASK.removeTask_code(task_fadeIn)
if BGM.nowPlay then TASK.new(task_fadeOut,BGM.playing)end if BGM.nowPlay then
TASK.new(task_fadeOut,BGM.playing)
end
BGM.nowPlay,BGM.playing=nil BGM.nowPlay,BGM.playing=nil
end end
end end

View File

@@ -60,31 +60,33 @@ function FILE.save(data,name,mode)
end end
end end
function FILE.clear(path) function FILE.clear(path)
if fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory'then return end if fs.getRealDirectory(path)==SAVEDIR and fs.getInfo(path).type=='directory'then
for _,name in next,fs.getDirectoryItems(path)do for _,name in next,fs.getDirectoryItems(path)do
name=path..'/'..name name=path..'/'..name
if fs.getRealDirectory(name)==SAVEDIR then if fs.getRealDirectory(name)==SAVEDIR then
local t=fs.getInfo(name).type local t=fs.getInfo(name).type
if t=='file'then if t=='file'then
fs.remove(name) fs.remove(name)
end
end end
end end
end end
end end
function FILE.clear_s(path) function FILE.clear_s(path)
if path~=''and(fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory')then return end if path==''or (fs.getRealDirectory(path)==SAVEDIR and fs.getInfo(path).type=='directory')then
for _,name in next,fs.getDirectoryItems(path)do for _,name in next,fs.getDirectoryItems(path)do
name=path..'/'..name name=path..'/'..name
if fs.getRealDirectory(name)==SAVEDIR then if fs.getRealDirectory(name)==SAVEDIR then
local t=fs.getInfo(name).type local t=fs.getInfo(name).type
if t=='file'then if t=='file'then
fs.remove(name) fs.remove(name)
elseif t=='directory'then elseif t=='directory'then
FILE.clear_s(name) FILE.clear_s(name)
fs.remove(name) fs.remove(name)
end
end end
end end
fs.remove(path)
end end
fs.remove(path)
end end
return FILE return FILE

View File

@@ -145,7 +145,9 @@ do--function GC.DO(L)
end end
if type(cmd)=='string'then if type(cmd)=='string'then
local func=cmds[cmd] local func=cmds[cmd]
if type(func)=='string'then func=gc[func]end if type(func)=='string'then
func=gc[func]
end
if func then if func then
func(unpack(L[i],2)) func(unpack(L[i],2))
else else

View File

@@ -4,7 +4,9 @@ function LANG.init(langList,publicText)--Attention, calling this will destory al
for k,v in next,T0 do for k,v in next,T0 do
if type(v)=='table'and not v.refuseCopy then--refuseCopy: just copy pointer, not contents if type(v)=='table'and not v.refuseCopy then--refuseCopy: just copy pointer, not contents
if not T[k]then T[k]={}end if not T[k]then T[k]={}end
if type(T[k])=='table'then _langFallback(v,T[k])end if type(T[k])=='table'then
_langFallback(v,T[k])
end
elseif not T[k]then elseif not T[k]then
T[k]=v T[k]=v
end end

View File

@@ -86,7 +86,9 @@ function SCN.init(s,org)
SCN.socketRead=S.socketRead SCN.socketRead=S.socketRead
SCN.update=S.update SCN.update=S.update
SCN.draw=S.draw SCN.draw=S.draw
if S.sceneInit then S.sceneInit(org)end if S.sceneInit then
S.sceneInit(org)
end
end end
function SCN.push(tar,style) function SCN.push(tar,style)
if not SCN.swapping then if not SCN.swapping then
@@ -140,7 +142,7 @@ local swap={
function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back
if scenes[tar]then if scenes[tar]then
if not SCN.swapping and tar~=SCN.cur then if not SCN.swapping and tar~=SCN.cur then
if not style then style='fade'end style=style or'fade'
SCN.swapping=true SCN.swapping=true
local S=SCN.stat local S=SCN.stat
S.tar,S.style=tar,style S.tar,S.style=tar,style
@@ -164,7 +166,9 @@ function SCN.back()
if SCN.swapping then return end if SCN.swapping then return end
--Leave scene --Leave scene
if SCN.sceneBack then SCN.sceneBack()end if SCN.sceneBack then
SCN.sceneBack()
end
--Poll&Back to previous Scene --Poll&Back to previous Scene
local m=#SCN.stack local m=#SCN.stack

View File

@@ -22,14 +22,18 @@ end
function textFX.stretch(t) function textFX.stretch(t)
gc_push('transform') gc_push('transform')
gc_translate(t.x,t.y) gc_translate(t.x,t.y)
if t.c<.3 then gc_scale((.3-t.c)*1.6+1,1)end if t.c<.3 then
gc_scale((.3-t.c)*1.6+1,1)
end
mStr(t.text,0,-t.font*.7) mStr(t.text,0,-t.font*.7)
gc_pop() gc_pop()
end end
function textFX.drive(t) function textFX.drive(t)
gc_push('transform') gc_push('transform')
gc_translate(t.x,t.y) gc_translate(t.x,t.y)
if t.c<.3 then gc_shear((.3-t.c)*2,0)end if t.c<.3 then
gc_shear((.3-t.c)*2,0)
end
mStr(t.text,0,-t.font*.7) mStr(t.text,0,-t.font*.7)
gc_pop() gc_pop()
end end
@@ -102,7 +106,9 @@ function TEXT.getText(text,x,y,font,style,spd,stop)--Another version of TEXT.sho
} }
end end
function TEXT.update(list) function TEXT.update(list)
if not list then list=texts end if not list then
list=texts
end
for i=#list,1,-1 do for i=#list,1,-1 do
local t=list[i] local t=list[i]
t.c=t.c+t.spd t.c=t.c+t.spd
@@ -117,7 +123,9 @@ function TEXT.update(list)
end end
end end
function TEXT.draw(list) function TEXT.draw(list)
if not list then list=texts end if not list then
list=texts
end
for i=1,#list do for i=1,#list do
local t=list[i] local t=list[i]
local p=t.c local p=t.c

View File

@@ -7,7 +7,9 @@ local themeColor={
} }
function THEME.calculate(Y,M,D) function THEME.calculate(Y,M,D)
if not Y then Y,M,D=os.date('%Y'),os.date('%m'),os.date('%d')end if not Y then
Y,M,D=os.date('%Y'),os.date('%m'),os.date('%d')
end
--Festival calculate within one statement --Festival calculate within one statement
return return
--Christmas --Christmas
@@ -90,7 +92,9 @@ function THEME.set(theme)
end end
function THEME.getThemeColor(theme) function THEME.getThemeColor(theme)
if not theme then theme=THEME.cur end if not theme then
theme=THEME.cur
end
return themeColor[theme] return themeColor[theme]
end end

View File

@@ -49,7 +49,9 @@ function VOC.init(list)
MES.new('warn',"No VOICE file: "..list[i],.1) MES.new('warn',"No VOICE file: "..list[i],.1)
end end
end end
if not Source[list[i]][1]then Source[list[i]]=nil end if not Source[list[i]][1]then
Source[list[i]]=nil
end
end end
function VOC.getQueueCount() function VOC.getQueueCount()

View File

@@ -220,7 +220,9 @@ function button:press(_,_,k)
self.w+2*ATV, self.w+2*ATV,
self.h+2*ATV self.h+2*ATV
) )
if self.sound then SFX.play('button')end if self.sound then
SFX.play('button')
end
end end
function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hideF][,hide] function WIDGET.newButton(D)--name,x,y,w[,h][,fText][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hideF][,hide]
if not D.h then D.h=D.w end if not D.h then D.h=D.w end
@@ -332,7 +334,9 @@ function key:getInfo()
end end
function key:press(_,_,k) function key:press(_,_,k)
self.code(k) self.code(k)
if self.sound then SFX.play('key')end if self.sound then
SFX.play('key')
end
end end
function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,fShade][,noFrame][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hideF][,hide] function WIDGET.newKey(D)--name,x,y,w[,h][,fText][,fShade][,noFrame][,color][,font=30][,sound=true][,align='M'][,edge=0],code[,hideF][,hide]
if not D.h then D.h=D.w end if not D.h then D.h=D.w end
@@ -387,12 +391,16 @@ function switch:getCenter()
end end
function switch:update() function switch:update()
local atv=self.ATV local atv=self.ATV
if WIDGET.sel==self then if atv<8 then self.ATV=atv+1 end if WIDGET.sel==self then
else if atv>0 then self.ATV=atv-.5 end if atv<8 then self.ATV=atv+1 end
else
if atv>0 then self.ATV=atv-.5 end
end end
local chk=self.CHK local chk=self.CHK
if self:disp()then if chk<6 then self.CHK=chk+1 end if self:disp()then
else if chk>0 then self.CHK=chk-1 end if chk<6 then self.CHK=chk+1 end
else
if chk>0 then self.CHK=chk-1 end
end end
end end
function switch:draw() function switch:draw()
@@ -424,7 +432,9 @@ function switch:getInfo()
end end
function switch:press() function switch:press()
self.code() self.code()
if self.sound then SFX.play('move')end if self.sound then
SFX.play('move')
end
end end
function WIDGET.newSwitch(D)--name,x,y[,fText][,color][,font=30][,sound=true][,disp],code[,hideF][,hide] function WIDGET.newSwitch(D)--name,x,y[,fText][,color][,font=30][,sound=true][,disp],code[,hideF][,hide]
local _={ local _={
@@ -736,7 +746,9 @@ function selector:press(x)
self.code(self.list[s]) self.code(self.list[s])
self.select=s self.select=s
self.selText=self.list[s] self.selText=self.list[s]
if self.sound then SFX.play('prerotate')end if self.sound then
SFX.play('prerotate')
end
end end
end end
end end
@@ -754,7 +766,9 @@ function selector:scroll(n)
self.code(self.list[s]) self.code(self.list[s])
self.select=s self.select=s
self.selText=self.list[s] self.selText=self.list[s]
if self.sound then SFX.play('prerotate')end if self.sound then
SFX.play('prerotate')
end
end end
function selector:arrowKey(k) function selector:arrowKey(k)
self:scroll((k=="left"or k=="up")and -1 or 1) self:scroll((k=="left"or k=="up")and -1 or 1)
@@ -1385,13 +1399,13 @@ function WIDGET.keyPressed(k,isRep)
local tar local tar
local minDist=1e99 local minDist=1e99
local swap_xy=k=="up"or k=="down" local swap_xy=k=="up"or k=="down"
if swap_xy then WX,WY=WY,WX end -- note that we do not swap them back later if swap_xy then WX,WY=WY,WX end--note that we do not swap them back later
for _,W1 in ipairs(WIDGET.active)do for _,W1 in ipairs(WIDGET.active)do
if W~=W1 and W1.resCtr and not W1.hide then if W~=W1 and W1.resCtr and not W1.hide then
local L=W1.resCtr local L=W1.resCtr
for j=1,#L,2 do for j=1,#L,2 do
local x,y=L[j],L[j+1] local x,y=L[j],L[j+1]
if swap_xy then x,y=y,x end -- note that we do not swap them back later if swap_xy then x,y=y,x end--note that we do not swap them back later
local dist=(x-WX)*dir local dist=(x-WX)*dir
if dist>10 then if dist>10 then
dist=dist+abs(y-WY)*6.26 dist=dist+abs(y-WY)*6.26

View File

@@ -18,6 +18,6 @@ FILETYPE 0x1
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
{ {
VALUE "Translation", 0x0409 0x04E4 VALUE "Translation", 0x0409 0x04E4
} }
} }

View File

@@ -111,11 +111,17 @@ else
FIELD[1]=DATA.newBoard() FIELD[1]=DATA.newBoard()
end end
local sequenceData=FILE.load('conf/customSequence') local sequenceData=FILE.load('conf/customSequence')
if sequenceData then DATA.pasteSequence(sequenceData)end if sequenceData then
DATA.pasteSequence(sequenceData)
end
local missionData=FILE.load('conf/customMissions') local missionData=FILE.load('conf/customMissions')
if missionData then DATA.pasteMission(missionData)end if missionData then
DATA.pasteMission(missionData)
end
local customData=FILE.load('conf/customEnv') local customData=FILE.load('conf/customEnv')
if customData and customData.version==VERSION.code then TABLE.complete(customData,CUSTOMENV)end if customData and customData.version==VERSION.code then
TABLE.complete(customData,CUSTOMENV)
end
TABLE.complete(require"parts.customEnv0",CUSTOMENV) TABLE.complete(require"parts.customEnv0",CUSTOMENV)
@@ -285,12 +291,22 @@ do
end end
if STAT.version==1506 then if STAT.version==1506 then
local temp1,temp2 local temp1,temp2
if fs.getInfo('record/master_l.rec')then temp1=fs.read('record/master_l.rec')end if fs.getInfo('record/master_l.rec')then
if fs.getInfo('record/master_u.rec')then temp2=fs.read('record/master_u.rec')end temp1=fs.read('record/master_l.rec')
if temp1 then fs.write('record/master_u.rec',temp1)end end
if temp2 then fs.write('record/master_l.rec',temp2)end if fs.getInfo('record/master_u.rec')then
temp2=fs.read('record/master_u.rec')
end
if temp1 then
fs.write('record/master_u.rec',temp1)
end
if temp2 then
fs.write('record/master_l.rec',temp2)
end
RANKS.master_l,RANKS.master_u=RANKS.master_u,RANKS.master_l RANKS.master_l,RANKS.master_u=RANKS.master_u,RANKS.master_l
if RANKS.tsd_u then RANKS.tsd_u=0 end if RANKS.tsd_u then
RANKS.tsd_u=0
end
needSave=true needSave=true
end end
if STAT.version==1601 then if STAT.version==1601 then
@@ -320,22 +336,40 @@ do
end end
SETTING.appLock=nil SETTING.appLock=nil
SETTING.dataSaving=nil SETTING.dataSaving=nil
if not SETTING.VKSkin then SETTING.VKSkin=1 end if not SETTING.VKSkin then
SETTING.VKSkin=1
end
for _,v in next,SETTING.skin do if v<1 or v>17 then v=17 end end for _,v in next,SETTING.skin do if v<1 or v>17 then v=17 end end
if if
SETTING.RS=='ZRS'or SETTING.RS=='BRS'or SETTING.RS=='ZRS'or SETTING.RS=='BRS'or
SETTING.RS=='ASCplus'or SETTING.RS=='C2sym' SETTING.RS=='ASCplus'or SETTING.RS=='C2sym'
then SETTING.RS='TRS'end then SETTING.RS='TRS'end
if SETTING.ghostType=='greyCell'then SETTING.ghostType='grayCell'end if SETTING.ghostType=='greyCell'then
if type(SETTING.skinSet)=='number'then SETTING.skinSet='crystal_scf'end SETTING.ghostType='grayCell'
if not TABLE.find({8,10,13,17,22,29,37,47,62,80,100},SETTING.frameMul)then SETTING.frameMul=100 end end
if type(SETTING.skinSet)=='number'then
SETTING.skinSet='crystal_scf'
end
if not TABLE.find({8,10,13,17,22,29,37,47,62,80,100},SETTING.frameMul)then
SETTING.frameMul=100
end
for _,v in next,VK_org do v.color=nil end for _,v in next,VK_org do v.color=nil end
if RANKS.infinite then RANKS.infinite=0 end if RANKS.infinite then
if RANKS.infinite_dig then RANKS.infinite_dig=0 end RANKS.infinite=0
if not RANKS.sprint_10l then RANKS.sprint_10l=0 end end
if RANKS.master_l then RANKS.master_n,RANKS.master_l=RANKS.master_l needSave=true end if RANKS.infinite_dig then
if RANKS.master_u then RANKS.master_h,RANKS.master_u=RANKS.master_u needSave=true end RANKS.infinite_dig=0
end
if not RANKS.sprint_10l then
RANKS.sprint_10l=0
end
if RANKS.master_l then
RANKS.master_n,RANKS.master_l=RANKS.master_l needSave=true
end
if RANKS.master_u then
RANKS.master_h,RANKS.master_u=RANKS.master_u needSave=true
end
for k in next,RANKS do for k in next,RANKS do
if type(k)=='number'then if type(k)=='number'then
RANKS[k]=nil RANKS[k]=nil

View File

@@ -61,7 +61,9 @@ end
--Use this to copy a symmetry set --Use this to copy a symmetry set
local function _flipList(O) local function _flipList(O)
if not O then return end if not O then
return
end
local L={} local L={}
for i,s in next,O do for i,s in next,O do
L[i]=string.char(88-s:byte())..s:sub(2) L[i]=string.char(88-s:byte())..s:sub(2)
@@ -173,9 +175,12 @@ do
if P.gameEnv.ospin then if P.gameEnv.ospin then
local x,y=P.curX,P.curY local x,y=P.curX,P.curY
if y==P.ghoY and((P:solid(x-1,y)or P:solid(x-1,y+1)))and(P:solid(x+2,y)or P:solid(x+2,y+1))then if y==P.ghoY and((P:solid(x-1,y)or P:solid(x-1,y+1)))and(P:solid(x+2,y)or P:solid(x+2,y+1))then
if P.sound then SFX.play('rotatekick',nil,P:getCenterX()*.15)end if P.sound then
SFX.play('rotatekick',nil,P:getCenterX()*.15)
end
P.spinSeq=P.spinSeq%100*10+d P.spinSeq=P.spinSeq%100*10+d
if P.spinSeq<100 then return end if P.spinSeq<100 then
return end
for i=1,#OspinList do for i=1,#OspinList do
local L=OspinList[i] local L=OspinList[i]
if P.spinSeq==L[1]then if P.spinSeq==L[1]then
@@ -203,11 +208,15 @@ do
end end
end end
else else
if P.sound then SFX.play('rotate',nil,P:getCenterX()*.15)end if P.sound then
SFX.play('rotate',nil,P:getCenterX()*.15)
end
P.spinSeq=0 P.spinSeq=0
end end
else else
if P.sound then SFX.play('rotate',nil,P:getCenterX()*.15)end if P.sound then
SFX.play('rotate',nil,P:getCenterX()*.15)
end
end end
end,--O end,--O
{ {
@@ -318,7 +327,9 @@ do
[31]={'+0+0','+0-1','+1+0'}, [31]={'+0+0','+0-1','+1+0'},
},--W },--W
function(P,d) function(P,d)
if P.type=='human'then SFX.play('rotate',nil,P:getCenterX()*.15)end if P.type=='human'then
SFX.play('rotate',nil,P:getCenterX()*.15)
end
local kickData=XspinList[d] local kickData=XspinList[d]
for test=1,#kickData do for test=1,#kickData do
local x,y=P.curX+kickData[test][1],P.curY+kickData[test][2] local x,y=P.curX+kickData[test][1],P.curY+kickData[test][2]
@@ -612,7 +623,9 @@ do
} }
for i=1,29 do for i=1,29 do
local a,b=R,L local a,b=R,L
if i==6 or i==18 then a,b=b,a end if i==6 or i==18 then
a,b=b,a
end
list[i][01]=a;list[i][10]=b;list[i][03]=b;list[i][30]=a list[i][01]=a;list[i][10]=b;list[i][03]=b;list[i][30]=a
list[i][12]=a;list[i][21]=b;list[i][32]=b;list[i][23]=a list[i][12]=a;list[i][21]=b;list[i][32]=b;list[i][23]=a
end end

View File

@@ -31,7 +31,9 @@ function back.update()
for i=#mino,1,-1 do for i=#mino,1,-1 do
local M=mino[i] local M=mino[i]
M.y=M.y+M.vy M.y=M.y+M.vy
if M.y-M.k*#M.block*30>SCR.h then rem(mino,i)end if M.y-M.k*#M.block*30>SCR.h then
rem(mino,i)
end
end end
end end
function back.draw() function back.draw()

View File

@@ -4,10 +4,10 @@ local sin=math.sin
local back={} local back={}
local t local t
local txt local textObj
function back.init() function back.init()
t=math.random()*2600 t=math.random()*2600
txt=gc.newText(getFont(80),"Welcome To Techmino") textObj=gc.newText(getFont(80),"Welcome To Techmino")
end end
function back.update(dt) function back.update(dt)
t=t+dt t=t+dt
@@ -21,7 +21,7 @@ function back.draw()
gc.push('transform') gc.push('transform')
gc.translate(SCR.cx,SCR.cy+20*sin(t*.02)) gc.translate(SCR.cx,SCR.cy+20*sin(t*.02))
gc.scale(SCR.k) gc.scale(SCR.k)
gc.scale(1.1626,1.26) gc.scale(1.26,1.36)
if -t%6.26<.1355 then if -t%6.26<.1355 then
gc.translate(60*sin(t*.26),100*sin(t*.626)) gc.translate(60*sin(t*.26),100*sin(t*.626))
end end
@@ -29,11 +29,11 @@ function back.draw()
gc.rotate(t+5*sin(.26*t)+5*sin(.626*t)) gc.rotate(t+5*sin(.26*t)+5*sin(.626*t))
end end
gc.setColor(.4,.6,1,.3) gc.setColor(.4,.6,1,.3)
gc.draw(txt,-883*.5+4*sin(t*.7942),-110*.5+4*sin(t*.7355)) mDraw(textObj,4*sin(t*.7942),4*sin(t*.7355))
gc.setColor(.5,.7,1,.4) gc.setColor(.5,.7,1,.4)
gc.draw(txt,-883*.5+2*sin(t*.77023),-110*.5+2*sin(t*.7026)) mDraw(textObj,2*sin(t*.77023),2*sin(t*.7026))
gc.setColor(1,1,1,.5) gc.setColor(1,1,1,.5)
gc.draw(txt,-883*.5+3*sin(t*.7283),-110*.5+3*sin(t*.7626)) mDraw(textObj,3*sin(t*.7283),3*sin(t*.7626))
gc.pop() gc.pop()
end end
return back return back

View File

@@ -39,7 +39,9 @@ local LclearScore={[0]=0,-200,-150,-100,200}
local HclearScore={[0]=0,100,140,200,500} local HclearScore={[0]=0,100,140,200,500}
local function _ifoverlapAI(f,bk,x,y) local function _ifoverlapAI(f,bk,x,y)
for i=1,#bk do for j=1,#bk[1]do for i=1,#bk do for j=1,#bk[1]do
if f[y+i-1]and bk[i][j]and f[y+i-1][x+j-1]>0 then return true end if f[y+i-1]and bk[i][j]and f[y+i-1][x+j-1]>0 then
return true
end
end end end end
end end
local discardRow=FREEROW.discard local discardRow=FREEROW.discard
@@ -65,25 +67,33 @@ local function _getScore(field,cb,cy)
for i=cy+#cb-1,cy,-1 do for i=cy+#cb-1,cy,-1 do
for j=1,10 do for j=1,10 do
if field[i][j]==0 then goto CONTINUE_notFull end if field[i][j]==0 then
goto CONTINUE_notFull
end
end end
discardRow(rem(field,i)) discardRow(rem(field,i))
clear=clear+1 clear=clear+1
::CONTINUE_notFull:: ::CONTINUE_notFull::
end end
if #field==0 then return 1e99 end--PC if #field==0 then--PC
return 1e99
end
for x=1,10 do for x=1,10 do
local h=#field local h=#field
while field[h][x]==0 and h>1 do while field[h][x]==0 and h>1 do
h=h-1 h=h-1
end end
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 h1=h-1,1,-1 do for h1=h-1,1,-1 do
if field[h1][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
end end
end end
@@ -94,7 +104,9 @@ local function _getScore(field,cb,cy)
local dh=abs(height[x]-height[x+1]) local dh=abs(height[x]-height[x+1])
if dh==1 then if dh==1 then
h1=h1+1 h1=h1+1
if h1>mh1 then mh1=h1 end if h1>mh1 then
mh1=h1
end
else else
h1=0 h1=0
end end
@@ -115,8 +127,12 @@ local function _getScore(field,cb,cy)
-cy*40 -cy*40
-sdh*3 -sdh*3
) )
if #field>6 then score=score-highest*5+20 end if #field>6 then
if mh1>3 then score=score-20-mh1*30 end score=score-highest*5+20
end
if mh1>3 then
score=score-20-mh1*30
end
return score return score
end end
@@ -158,7 +174,9 @@ function bot_9s.thread(bot)
--Simulate lock --Simulate lock
for i=1,#cb do for i=1,#cb do
local y=cy+i-1 local y=cy+i-1
if not Tfield[y]then Tfield[y]=getRow(0)end if not Tfield[y]then
Tfield[y]=getRow(0)
end
local L=Tfield[y] local L=Tfield[y]
for j=1,#cb[1]do for j=1,#cb[1]do
if cb[i][j]then if cb[i][j]then

View File

@@ -51,7 +51,9 @@ function bot_cc:thread()
dest[1],dest[2]=dest[3][1],dest[3][2] dest[1],dest[2]=dest[3][1],dest[3][2]
dest[3],dest[4]=dest[4][1],dest[4][2] dest[3],dest[4]=dest[4][1],dest[4][2]
P.destFX=dest P.destFX=dest
if hold then keys[1]=8 end--Hold if hold then--Hold
keys[1]=8
end
while move[1]do while move[1]do
local m=rem(move,1) local m=rem(move,1)
if m<4 then if m<4 then

View File

@@ -91,7 +91,9 @@ function BOT.new(P,data)
bot.nexts={} bot.nexts={}
bot.delay=data.delay bot.delay=data.delay
bot.delay0=data.delay bot.delay0=data.delay
if P.gameEnv.holdCount>1 then P:setHold(1)end if P.gameEnv.holdCount>1 then
P:setHold(1)
end
local cc=REQUIRE"CCloader" local cc=REQUIRE"CCloader"
if not cc then if not cc then

View File

@@ -54,7 +54,9 @@ function DATA.pasteSequence(str)
end end
end end
end end
if reg then ins(BAG,reg)end if reg then
ins(BAG,reg)
end
return true return true
end end
@@ -101,8 +103,12 @@ function DATA.copyBoards()
return table.concat(out,"!") return table.concat(out,"!")
end end
function DATA.pasteBoard(str,page)--Paste [str] data to [page] board function DATA.pasteBoard(str,page)--Paste [str] data to [page] board
if not page then page=1 end if not page then
if not FIELD[page]then FIELD[page]=DATA.newBoard()end page=1
end
if not FIELD[page]then
FIELD[page]=DATA.newBoard()
end
local F=FIELD[page] local F=FIELD[page]
--Decode --Decode
@@ -212,7 +218,9 @@ function DATA.pasteMission(str)
end end
end end
end end
if reg then ins(MISSION,reg)end if reg then
ins(MISSION,reg)
end
return true return true
end end

View File

@@ -28,7 +28,9 @@ return
P.modeData.target=26 P.modeData.target=26
SFX.play('reach') SFX.play('reach')
elseif T==26 then--Stage 3: dig to bottom elseif T==26 then--Stage 3: dig to bottom
if not P.holdQueue[1]then P.life=P.life+1 end--1 up if ban hold if not P.holdQueue[1]then--1 up if ban hold
P.life=P.life+1
end
P.waiting=45 P.waiting=45
ENV.skin[1],ENV.skin[2]=ENV.skin[2],ENV.skin[1] ENV.skin[1],ENV.skin[2]=ENV.skin[2],ENV.skin[1]
ENV.skin[3],ENV.skin[4]=ENV.skin[4],ENV.skin[3] ENV.skin[3],ENV.skin[4]=ENV.skin[4],ENV.skin[3]

View File

@@ -14,7 +14,9 @@ return{
table.insert(P.atkBuffer,{line=generateLine(P.holeRND:random(10)),amount=1,countdown=30,cd0=30,time=0,sent=false,lv=1}) table.insert(P.atkBuffer,{line=generateLine(P.holeRND:random(10)),amount=1,countdown=30,cd0=30,time=0,sent=false,lv=1})
P.atkBufferSum=P.atkBufferSum+1 P.atkBufferSum=P.atkBufferSum+1
P.stat.recv=P.stat.recv+1 P.stat.recv=P.stat.recv+1
if D.wave==45 then P:_showText(text.maxspeed,0,-140,100,'appear',.6)end if D.wave==45 then
P:_showText(text.maxspeed,0,-140,100,'appear',.6)
end
D.timer=0 D.timer=0
D.wave=D.wave+1 D.wave=D.wave+1
end end

View File

@@ -21,7 +21,9 @@ return{
end end
P.atkBufferSum=P.atkBufferSum+s P.atkBufferSum=P.atkBufferSum+s
P.stat.recv=P.stat.recv+s P.stat.recv=P.stat.recv+s
if D.wave==60 then P:_showText(text.maxspeed,0,-140,100,'appear',.6)end if D.wave==60 then
P:_showText(text.maxspeed,0,-140,100,'appear',.6)
end
D.timer=0 D.timer=0
D.wave=D.wave+1 D.wave=D.wave+1
end end

View File

@@ -15,7 +15,9 @@ return{
table.insert(P.atkBuffer,{line=generateLine(P.holeRND:random(10)),amount=4,countdown=t,cd0=t,time=0,sent=false,lv=3}) table.insert(P.atkBuffer,{line=generateLine(P.holeRND:random(10)),amount=4,countdown=t,cd0=t,time=0,sent=false,lv=3})
P.atkBufferSum=P.atkBufferSum+4 P.atkBufferSum=P.atkBufferSum+4
P.stat.recv=P.stat.recv+4 P.stat.recv=P.stat.recv+4
if D.wave==60 then P:_showText(text.maxspeed,0,-140,100,'appear',.6)end if D.wave==60 then
P:_showText(text.maxspeed,0,-140,100,'appear',.6)
end
D.timer=0 D.timer=0
D.wave=D.wave+1 D.wave=D.wave+1
end end

View File

@@ -20,7 +20,9 @@ return{
) )
P.atkBufferSum=P.atkBufferSum+d%4+1 P.atkBufferSum=P.atkBufferSum+d%4+1
P.stat.recv=P.stat.recv+d%4+1 P.stat.recv=P.stat.recv+d%4+1
if D.wave==45 then P:_showText(text.maxspeed,0,-140,100,'appear',.6)end if D.wave==45 then
P:_showText(text.maxspeed,0,-140,100,'appear',.6)
end
D.timer=0 D.timer=0
D.wave=d D.wave=d
end end

View File

@@ -18,7 +18,9 @@ return{
table.insert(P.atkBuffer,{line=generateLine(P.holeRND:random(10)),amount=6,countdown=1.5*t,cd0=1.5*t,time=0,sent=false,lv=5}) table.insert(P.atkBuffer,{line=generateLine(P.holeRND:random(10)),amount=6,countdown=1.5*t,cd0=1.5*t,time=0,sent=false,lv=5})
P.atkBufferSum=P.atkBufferSum+20 P.atkBufferSum=P.atkBufferSum+20
P.stat.recv=P.stat.recv+20 P.stat.recv=P.stat.recv+20
if D.wave==31 then P:_showText(text.maxspeed,0,-140,100,'appear',.6)end if D.wave==31 then
P:_showText(text.maxspeed,0,-140,100,'appear',.6)
end
D.timer=0 D.timer=0
D.wave=D.wave+1 D.wave=D.wave+1
end end

View File

@@ -116,7 +116,9 @@ function royaleLevelup()
for _,P in next,PLY_ALIVE do for _,P in next,PLY_ALIVE do
P.gameEnv.garbageSpeed=.6 P.gameEnv.garbageSpeed=.6
end end
if PLAYERS[1].alive then BGM.play('cruelty')end if PLAYERS[1].alive then
BGM.play('cruelty')
end
elseif GAME.stage==4 then elseif GAME.stage==4 then
spd=10 spd=10
for _,P in next,PLY_ALIVE do for _,P in next,PLY_ALIVE do
@@ -129,7 +131,9 @@ function royaleLevelup()
end end
elseif GAME.stage==6 then elseif GAME.stage==6 then
spd=3 spd=3
if PLAYERS[1].alive then BGM.play('final')end if PLAYERS[1].alive then
BGM.play('final')
end
end end
for _,P in next,PLY_ALIVE do for _,P in next,PLY_ALIVE do
P.gameEnv.drop=spd P.gameEnv.drop=spd
@@ -155,7 +159,9 @@ function generateLine(hole)
end end
function solidLine(L) function solidLine(L)
for i=1,10 do for i=1,10 do
if L[i]>0 then return true end if L[i]>0 then
return true
end
end end
end end
function setField(P,page) function setField(P,page)
@@ -181,7 +187,9 @@ function setField(P,page)
end end
end end
function freshDate(mode) function freshDate(mode)
if not mode then mode=""end if not mode then
mode=""
end
local date=os.date("%Y/%m/%d") local date=os.date("%Y/%m/%d")
if STAT.date~=date then if STAT.date~=date then
STAT.date=date STAT.date=date
@@ -238,7 +246,9 @@ end
function destroyPlayers()--Destroy all player objects, restore freerows and free CCs function destroyPlayers()--Destroy all player objects, restore freerows and free CCs
for i=#PLAYERS,1,-1 do for i=#PLAYERS,1,-1 do
local P=PLAYERS[i] local P=PLAYERS[i]
if P.canvas then P.canvas:release()end if P.canvas then
P.canvas:release()
end
while P.field[1]do while P.field[1]do
FREEROW.discard(rem(P.field)) FREEROW.discard(rem(P.field))
FREEROW.discard(rem(P.visTime)) FREEROW.discard(rem(P.visTime))
@@ -283,7 +293,9 @@ end
function loadGame(mode,ifQuickPlay,ifNet)--Load a mode and go to game scene function loadGame(mode,ifQuickPlay,ifNet)--Load a mode and go to game scene
freshDate() freshDate()
if legalGameTime()then if legalGameTime()then
if MODES[mode].score then STAT.lastPlay=mode end if MODES[mode].score then
STAT.lastPlay=mode
end
GAME.playing=true GAME.playing=true
GAME.init=true GAME.init=true
GAME.fromRepMenu=false GAME.fromRepMenu=false
@@ -306,7 +318,9 @@ function gameOver()--Save record
local R=GAME.curMode.getRank local R=GAME.curMode.getRank
if R then if R then
R=R(PLAYERS[1]) R=R(PLAYERS[1])
if R and R>0 then GAME.rank=R end if R and R>0 then
GAME.rank=R
end
end end
end end
trySave() trySave()
@@ -333,7 +347,9 @@ function gameOver()--Save record
local m=M.unlock[i] local m=M.unlock[i]
local n=MODES[m].name local n=MODES[m].name
if not RANKS[n]then if not RANKS[n]then
if MODES[m].x then RANKS[n]=0 end if MODES[m].x then
RANKS[n]=0
end
needSave=true needSave=true
end end
end end

View File

@@ -33,7 +33,10 @@ return{
local t=2 local t=2
while t>0 do while t>0 do
local r=math.random(2,49) local r=math.random(2,49)
if L[r]then L[r],t=false,t-1 end if L[r]then
L[r]=false
t=t-1
end
end end
local n=2 local n=2
for _=1,4 do for _=1,6 do for _=1,4 do for _=1,6 do

View File

@@ -33,7 +33,10 @@ return{
local t=4 local t=4
while t>0 do while t>0 do
local r=math.random(2,49) local r=math.random(2,49)
if L[r]then L[r],t=false,t-1 end if L[r]then
L[r]=false
t=t-1
end
end end
local n=2 local n=2
for _=1,4 do for _=1,6 do for _=1,4 do for _=1,6 do

View File

@@ -33,7 +33,10 @@ return{
local t=6 local t=6
while t>0 do while t>0 do
local r=math.random(2,49) local r=math.random(2,49)
if L[r]then L[r],t=false,t-1 end if L[r]then
L[r]=false
t=t-1
end
end end
local n=2 local n=2
for _=1,4 do for _=1,6 do for _=1,4 do for _=1,6 do

View File

@@ -33,7 +33,10 @@ return{
local t=4 local t=4
while t>0 do while t>0 do
local r=math.random(2,99) local r=math.random(2,99)
if L[r]then L[r],t=false,t-1 end if L[r]then
L[r]=false
t=t-1
end
end end
local n=2 local n=2
for _=1,7 do for _=1,7 do for _=1,7 do for _=1,7 do

View File

@@ -33,7 +33,10 @@ return{
local t=4 local t=4
while t>0 do while t>0 do
local r=math.random(2,99) local r=math.random(2,99)
if L[r]then L[r],t=false,t-1 end if L[r]then
L[r]=false
t=t-1
end
end end
local n=2 local n=2
for _=1,7 do for _=1,7 do for _=1,7 do for _=1,7 do

View File

@@ -33,7 +33,10 @@ return{
local t=4 local t=4
while t>0 do while t>0 do
local r=math.random(2,99) local r=math.random(2,99)
if L[r]then L[r],t=false,t-1 end if L[r]then
L[r]=false
t=t-1
end
end end
local n=2 local n=2
for _=1,7 do for _=1,7 do for _=1,7 do for _=1,7 do

View File

@@ -454,7 +454,9 @@ function NET.updateWS_user()
USER.uid=res.uid USER.uid=res.uid
USER.authToken=res.authToken USER.authToken=res.authToken
FILE.save(USER,'conf/user') FILE.save(USER,'conf/user')
if SCN.cur=='login'then SCN.back()end if SCN.cur=='login'then
SCN.back()
end
end end
MES.new('check',text.loginSuccessed) MES.new('check',text.loginSuccessed)
@@ -549,7 +551,9 @@ function NET.updateWS_play()
mode=d.mode, mode=d.mode,
config=d.config, config=d.config,
} }
if SCN.cur=='net_game'then SCN.socketRead('join',d)end if SCN.cur=='net_game'then
SCN.socketRead('join',d)
end
if NET.roomReadyState=='allReady'then if NET.roomReadyState=='allReady'then
NET.roomReadyState=false NET.roomReadyState=false
end end
@@ -558,16 +562,22 @@ function NET.updateWS_play()
if not d.uid then if not d.uid then
NET.wsclose_stream() NET.wsclose_stream()
NET.unlock('quit') NET.unlock('quit')
if SCN.stack[#SCN.stack-1]=='net_newRoom'then SCN.pop()end if SCN.stack[#SCN.stack-1]=='net_newRoom'then
SCN.pop()
end
SCN.back() SCN.back()
else else
netPLY.remove(d.sid) netPLY.remove(d.sid)
_removePlayer(PLAYERS,d.sid) _removePlayer(PLAYERS,d.sid)
_removePlayer(PLY_ALIVE,d.sid) _removePlayer(PLY_ALIVE,d.sid)
if SCN.cur=='net_game'then SCN.socketRead('leave',d)end if SCN.cur=='net_game'then
SCN.socketRead('leave',d)
end
end end
elseif res.action==4 then--Player talk elseif res.action==4 then--Player talk
if SCN.cur=='net_game'then SCN.socketRead('talk',d)end if SCN.cur=='net_game'then
SCN.socketRead('talk',d)
end
elseif res.action==5 then--Player change settings elseif res.action==5 then--Player change settings
netPLY.setConf(d.uid,d.config) netPLY.setConf(d.uid,d.config)
elseif res.action==6 then--Player change join mode elseif res.action==6 then--Player change join mode
@@ -579,7 +589,9 @@ function NET.updateWS_play()
NET.roomReadyState='connecting' NET.roomReadyState='connecting'
NET.wsconn_stream(d.srid) NET.wsconn_stream(d.srid)
elseif res.action==9 then--Game finished elseif res.action==9 then--Game finished
if SCN.cur=='net_game'then SCN.socketRead('finish',d)end if SCN.cur=='net_game'then
SCN.socketRead('finish',d)
end
--d.result: list of {place,survivalTime,uid,score} --d.result: list of {place,survivalTime,uid,score}
for _,p in next,d.result do for _,p in next,d.result do
@@ -595,7 +607,9 @@ function NET.updateWS_play()
netPLY.resetState() netPLY.resetState()
netPLY.freshPos() netPLY.freshPos()
NET.roomState.start=false NET.roomState.start=false
if NET.spectate then NET.signal_setMode(2)end if NET.spectate then
NET.signal_setMode(2)
end
NET.spectate=false NET.spectate=false
NET.wsclose_stream() NET.wsclose_stream()
end end

View File

@@ -655,7 +655,9 @@ function draw.drawTargetLine(P,r)
gc_setColor(1,r>10 and 0 or .2+.8*rnd(),.5) gc_setColor(1,r>10 and 0 or .2+.8*rnd(),.5)
_applyField(P) _applyField(P)
r=600-30*r r=600-30*r
if P.falling~=-1 then r=r-#P.clearingRow*(P.gameEnv.smooth and(P.falling/(P.gameEnv.fall+1))^1.6*30 or 30)end if P.falling~=-1 then
r=r-#P.clearingRow*(P.gameEnv.smooth and(P.falling/(P.gameEnv.fall+1))^1.6*30 or 30)
end
gc_line(0,r,300,r) gc_line(0,r,300,r)
_cancelField() _cancelField()
end end
@@ -896,7 +898,9 @@ function draw.norm(P,repMode)
ENV.mesDisp[i](P,repMode) ENV.mesDisp[i](P,repMode)
end end
if P.frameRun<180 then _drawStartCounter(P.frameRun)end if P.frameRun<180 then
_drawStartCounter(P.frameRun)
end
gc_pop() gc_pop()
end end
function draw.small(P) function draw.small(P)
@@ -972,7 +976,9 @@ function draw.demo(P)
_drawField(P) _drawField(P)
_drawFXs(P) _drawFXs(P)
if P.cur and P.waiting==-1 then if P.cur and P.waiting==-1 then
if ENV.ghost then drawGhost[ENV.ghostType](P.cur.bk,P.curX,P.ghoY,ENV.ghost,P.skinLib,curColor)end if ENV.ghost then
drawGhost[ENV.ghostType](P.cur.bk,P.curX,P.ghoY,ENV.ghost,P.skinLib,curColor)
end
if ENV.block then if ENV.block then
local dy=ENV.smooth and P.ghoY~=P.curY and(P.dropDelay/ENV.drop-1)*30 or 0 local dy=ENV.smooth and P.ghoY~=P.curY and(P.dropDelay/ENV.drop-1)*30 or 0
gc_translate(0,-dy) gc_translate(0,-dy)

View File

@@ -355,7 +355,9 @@ local function _applyGameEnv(P)--Finish gameEnv processing
ENV.bagLine=ENV.bagLine and(ENV.sequence=='bag'or ENV.sequence=='loop')and #ENV.seqData ENV.bagLine=ENV.bagLine and(ENV.sequence=='bag'or ENV.sequence=='loop')and #ENV.seqData
if ENV.nextCount==0 then ENV.nextPos=false end if ENV.nextCount==0 then
ENV.nextPos=false
end
P.newNext=coroutine.wrap(getSeqGen(P)) P.newNext=coroutine.wrap(getSeqGen(P))
P:newNext(P.gameEnv.seqData) P:newNext(P.gameEnv.seqData)

View File

@@ -248,7 +248,9 @@ function Player:set20G(if20g)
self:switchKey(14,not if20g) self:switchKey(14,not if20g)
self:switchKey(15,f) self:switchKey(15,f)
self:switchKey(16,f) self:switchKey(16,f)
if if20g and self.bot then self.bot:switch20G()end if if20g and self.bot then
self.bot:switch20G()
end
end end
function Player:setHold(count)--Set hold count (false/true as 0/1) function Player:setHold(count)--Set hold count (false/true as 0/1)
if not count then if not count then
@@ -287,7 +289,9 @@ function Player:setRS(RSname)
--Reset all player's blocks' RSs --Reset all player's blocks' RSs
for i=1,#self.nextQueue do self.nextQueue[i].RS=rs end for i=1,#self.nextQueue do self.nextQueue[i].RS=rs end
for i=1,#self.holdQueue do self.holdQueue[i].RS=rs end for i=1,#self.holdQueue do self.holdQueue[i].RS=rs end
if self.cur then self.cur.RS=rs end if self.cur then
self.cur.RS=rs
end
end end
function Player:triggerDropEvents() function Player:triggerDropEvents()
@@ -323,7 +327,9 @@ function Player:garbageRelease()--Check garbage buffer and try to release them
break break
end end
end end
if flag and self.bot then self.bot:updateField()end if flag and self.bot then
self.bot:updateField()
end
end end
function Player:garbageRise(color,amount,line)--Release n-lines garbage to field function Player:garbageRise(color,amount,line)--Release n-lines garbage to field
local _ local _
@@ -353,7 +359,9 @@ function Player:garbageRise(color,amount,line)--Release n-lines garbage to field
_=self.dropFX[i] _=self.dropFX[i]
_[3],_[5]=_[3]+amount,_[5]+amount _[3],_[5]=_[3]+amount,_[5]+amount
end end
if #self.field>self.gameEnv.heightLimit then self:lose()end if #self.field>self.gameEnv.heightLimit then
self:lose()
end
end end
local invList={2,1,4,3,5,6,7} local invList={2,1,4,3,5,6,7}
@@ -394,19 +402,29 @@ function Player:getCenterY()
return self.curY-C.RS.centerPos[C.id][C.dir][1] return self.curY-C.RS.centerPos[C.id][C.dir][1]
end end
function Player:solid(x,y) function Player:solid(x,y)
if x<1 or x>10 or y<1 then return true end if x<1 or x>10 or y<1 then
if y>#self.field then return false end return true
end
if y>#self.field then
return false
end
return self.field[y] return self.field[y]
[x]>0--to catch bug (nil[*]) [x]>0--to catch bug (nil[*])
end end
function Player:ifoverlap(bk,x,y) function Player:ifoverlap(bk,x,y)
local C=#bk[1] local C=#bk[1]
if x<1 or x+C>11 or y<1 then return true end if x<1 or x+C>11 or y<1 then
if y>#self.field then return end return true
end
if y>#self.field then
return
end
for i=1,#bk do for i=1,#bk do
if self.field[y+i-1]then if self.field[y+i-1]then
for j=1,C do for j=1,C do
if bk[i][j]and self.field[y+i-1][x+j-1]>0 then return true end if bk[i][j]and self.field[y+i-1][x+j-1]>0 then
return true
end
end end
end end
end end
@@ -443,7 +461,9 @@ end
function Player:receive(A,send,time,line) function Player:receive(A,send,time,line)
self.lastRecv=A self.lastRecv=A
local B=self.atkBuffer local B=self.atkBuffer
if send+self.atkBufferSum>self.gameEnv.bufferLimit then send=self.gameEnv.bufferLimit-self.atkBufferSum end if send+self.atkBufferSum>self.gameEnv.bufferLimit then
send=self.gameEnv.bufferLimit-self.atkBufferSum
end
if send>0 then if send>0 then
local m,k=#B,1 local m,k=#B,1
while k<=m and time>B[k].countdown do k=k+1 end while k<=m and time>B[k].countdown do k=k+1 end
@@ -492,7 +512,9 @@ function Player:freshTarget()
end end
end end
function Player:changeAtkMode(m) function Player:changeAtkMode(m)
if self.atkMode==m then return end if self.atkMode==m then
return
end
self.atkMode=m self.atkMode=m
if m==1 then if m==1 then
self:changeAtk(randomTarget(self)) self:changeAtk(randomTarget(self))
@@ -507,7 +529,9 @@ function Player:changeAtk(R)
if self.atking then if self.atking then
local K=self.atking.atker local K=self.atking.atker
local i=TABLE.find(K,self) local i=TABLE.find(K,self)
if i then rem(K,i)end if i then
rem(K,i)
end
end end
if R then if R then
self.atking=R self.atking=R
@@ -584,7 +608,10 @@ function Player:lock()
local CB=self.cur.bk local CB=self.cur.bk
for i=1,#CB do for i=1,#CB do
local y=self.curY+i-1 local y=self.curY+i-1
if not self.field[y]then self.field[y],self.visTime[y]=FREEROW.get(0),FREEROW.get(0)end if not self.field[y]then
self.field[y]=FREEROW.get(0)
self.visTime[y]=FREEROW.get(0)
end
for j=1,#CB[1]do for j=1,#CB[1]do
if CB[i][j]then if CB[i][j]then
self.field[y][self.curX+j-1]=self.cur.color self.field[y][self.curX+j-1]=self.cur.color
@@ -742,7 +769,9 @@ function Player:spin(d,ifpre)
--Fresh ghost and freshTime --Fresh ghost and freshTime
local t=self.freshTime local t=self.freshTime
if not ifpre then self:freshBlock('move')end if not ifpre then
self:freshBlock('move')
end
if kickData[test][2]>0 and self.freshTime==t and self.curY~=self.imgY then if kickData[test][2]>0 and self.freshTime==t and self.curY~=self.imgY then
self.freshTime=self.freshTime-1 self.freshTime=self.freshTime-1
end end
@@ -880,7 +909,9 @@ function Player:getBlock(id,name,color)--Get a block object
end end
function Player:getNext(id)--Push a block to nextQueue function Player:getNext(id)--Push a block to nextQueue
ins(self.nextQueue,self:getBlock(id)) ins(self.nextQueue,self:getBlock(id))
if self.bot then self.bot:pushNewNext(id)end if self.bot then
self.bot:pushNewNext(id)
end
end end
function Player:popNext(ifhold)--Pop nextQueue to hand function Player:popNext(ifhold)--Pop nextQueue to hand
local ENV=self.gameEnv local ENV=self.gameEnv
@@ -932,7 +963,9 @@ function Player:cancel(N)--Cancel Garbage
local off=0--Lines offseted local off=0--Lines offseted
local bf=self.atkBuffer local bf=self.atkBuffer
for i=1,#bf do for i=1,#bf do
if self.atkBufferSum==0 or N==0 then break end if self.atkBufferSum==0 or N==0 then
break
end
local A=bf[i] local A=bf[i]
if not A.sent then if not A.sent then
local O=min(A.amount,N)--Cur Offset local O=min(A.amount,N)--Cur Offset
@@ -1107,7 +1140,9 @@ do--Player.drop(self)--Place piece
if c~=0 then if c~=0 then
if self:solid(x-1,y-1)then c=c+1 end if self:solid(x-1,y-1)then c=c+1 end
if self:solid(x+1,y-1)then c=c+1 end if self:solid(x+1,y-1)then c=c+1 end
if c>2 then dospin=dospin+2 end if c>2 then
dospin=dospin+2
end
end end
end end
end end
@@ -1119,7 +1154,9 @@ do--Player.drop(self)--Place piece
self:lock() self:lock()
--Clear list of cleared-rows --Clear list of cleared-rows
if self.clearedRow[1]then TABLE.cut(self.clearedRow)end if self.clearedRow[1]then
TABLE.cut(self.clearedRow)
end
--Check line clear --Check line clear
cc=cc+self:checkClear(self.field,CY,#CB,CB,CX) cc=cc+self:checkClear(self.field,CY,#CB,CB,CX)
@@ -1177,7 +1214,9 @@ do--Player.drop(self)--Place piece
--Finesse check (control) --Finesse check (control)
local finePts local finePts
if not finesse then if not finesse then
if dospin then self.ctrlCount=self.ctrlCount-2 end--Allow 2 more step for roof-less spin if dospin then--Allow 2 more step for roof-less spin
self.ctrlCount=self.ctrlCount-2
end
local id=C.id local id=C.id
local d=self.ctrlCount-finesseList[id][C.dir+1][CX] local d=self.ctrlCount-finesseList[id][C.dir+1][CX]
finePts=d<=0 and 5 or max(3-d,0) finePts=d<=0 and 5 or max(3-d,0)
@@ -1404,14 +1443,18 @@ do--Player.drop(self)--Place piece
self:attack(T,send,sendTime,generateLine(self.atkRND:random(10))) self:attack(T,send,sendTime,generateLine(self.atkRND:random(10)))
end end
end end
if self.sound and send>3 then SFX.play('emit',min(send,7)*.1)end if self.sound and send>3 then
SFX.play('emit',min(send,7)*.1)
end
end end
--SFX & Vibrate --SFX & Vibrate
if self.sound then if self.sound then
SFX.play(clearSFX[cc]or'clear_4') SFX.play(clearSFX[cc]or'clear_4')
SFX.play(renSFX[min(cmb,11)]) SFX.play(renSFX[min(cmb,11)])
if cmb>14 then SFX.play('ren_mega',(cmb-10)*.1)end if cmb>14 then
SFX.play('ren_mega',(cmb-10)*.1)
end
VIB(cc+1) VIB(cc+1)
end end
else--No lines clear else--No lines clear
@@ -1453,7 +1496,9 @@ do--Player.drop(self)--Place piece
end end
--Speed bonus --Speed bonus
if self.dropSpeed>60 then cscore=cscore*(.9+self.dropSpeed/600)end if self.dropSpeed>60 then
cscore=cscore*(.9+self.dropSpeed/600)
end
cscore=int(cscore) cscore=int(cscore)
self:popScore(cscore) self:popScore(cscore)
@@ -1470,7 +1515,9 @@ do--Player.drop(self)--Place piece
SFX.play('reach') SFX.play('reach')
if self.curMission>#ENV.mission then if self.curMission>#ENV.mission then
self.curMission=false self.curMission=false
if not finish then finish='finish'end if not finish then
finish='finish'
end
end end
elseif ENV.missionKill then elseif ENV.missionKill then
self:_showText(text.missionFailed,0,140,40,'flicker',.5) self:_showText(text.missionFailed,0,140,40,'flicker',.5)
@@ -1487,7 +1534,9 @@ do--Player.drop(self)--Place piece
end end
--Check height limit --Check height limit
if cc==0 and #self.field>ENV.heightLimit then self:lose()end if cc==0 and #self.field>ENV.heightLimit then
self:lose()
end
--Update stat --Update stat
Stat.piece=Stat.piece+1 Stat.piece=Stat.piece+1
@@ -1524,7 +1573,9 @@ do--Player.drop(self)--Place piece
self:lose() self:lose()
else else
self:triggerDropEvents() self:triggerDropEvents()
if finish then self:win(finish)end if finish then
self:win(finish)
end
end end
else else
self:triggerDropEvents() self:triggerDropEvents()
@@ -1563,7 +1614,9 @@ local function task_throwBadge(ifAI,sender,time)
SFX.play('collect') SFX.play('collect')
end end
end end
if time<=0 then return end if time<=0 then
return
end
end end
end end
local function task_finish(self) local function task_finish(self)
@@ -1573,7 +1626,9 @@ local function task_finish(self)
if self.endCounter<40 then if self.endCounter<40 then
--Make field visible --Make field visible
for j=1,#self.field do for i=1,10 do for j=1,#self.field do for i=1,10 do
if self.visTime[j][i]<20 then self.visTime[j][i]=self.visTime[j][i]+.5 end if self.visTime[j][i]<20 then
self.visTime[j][i]=self.visTime[j][i]+.5
end
end end end end
elseif self.endCounter==60 then elseif self.endCounter==60 then
return return
@@ -1587,7 +1642,9 @@ local function task_lose(self)
if self.endCounter<40 then if self.endCounter<40 then
--Make field visible --Make field visible
for j=1,#self.field do for i=1,10 do for j=1,#self.field do for i=1,10 do
if self.visTime[j][i]<20 then self.visTime[j][i]=self.visTime[j][i]+.5 end if self.visTime[j][i]<20 then
self.visTime[j][i]=self.visTime[j][i]+.5
end
end end end end
elseif self.endCounter>80 then elseif self.endCounter>80 then
for i=1,#self.field do for i=1,#self.field do
@@ -1662,7 +1719,9 @@ function Player:revive()
self.field[_],self.visTime[_]=nil self.field[_],self.visTime[_]=nil
end end
self.garbageBeneath=0 self.garbageBeneath=0
if self.bot then self.bot:revive()end if self.bot then
self.bot:revive()
end
self:clearAttackBuffer() self:clearAttackBuffer()
@@ -1707,13 +1766,24 @@ function Player:win(result)
self:newTask(task_finish) self:newTask(task_finish)
end end
function Player:lose(force) function Player:lose(force)
if self.result then return end if self.result then
return
end
if not force then if not force then
if self.life>0 then self:revive()return end if self.life>0 then
if self.type=='remote'then self.waiting=1e99 return end self:revive()
return
end
if self.type=='remote'then
self.waiting=1e99
return
end
end end
self:die() self:die()
local p=TABLE.find(PLY_ALIVE,self)if p then rem(PLY_ALIVE,p)end do
local p=TABLE.find(PLY_ALIVE,self)
if p then rem(PLY_ALIVE,p)end
end
self.result='lose' self.result='lose'
if GAME.modeEnv.royaleMode then if GAME.modeEnv.royaleMode then
self:changeAtk() self:changeAtk()
@@ -1792,8 +1862,12 @@ function Player:act_moveLeft(auto)
self:createMoveFX('left') self:createMoveFX('left')
self.curX=self.curX-1 self.curX=self.curX-1
self:freshBlock('move') self:freshBlock('move')
if self.sound and self.curY==self.ghoY then SFX.play('move')end if self.sound and self.curY==self.ghoY then
if not auto then self.moving=0 end SFX.play('move')
end
if not auto then
self.moving=0
end
self.spinLast=false self.spinLast=false
else else
self.moving=self.gameEnv.das self.moving=self.gameEnv.das
@@ -1817,8 +1891,12 @@ function Player:act_moveRight(auto)
self:createMoveFX('right') self:createMoveFX('right')
self.curX=self.curX+1 self.curX=self.curX+1
self:freshBlock('move') self:freshBlock('move')
if self.sound and self.curY==self.ghoY then SFX.play('move')end if self.sound and self.curY==self.ghoY then
if not auto then self.moving=0 end SFX.play('move')
end
if not auto then
self.moving=0
end
self.spinLast=false self.spinLast=false
else else
self.moving=self.gameEnv.das self.moving=self.gameEnv.das
@@ -1924,7 +2002,9 @@ function Player:act_func2()
end end
function Player:act_insLeft(auto) function Player:act_insLeft(auto)
if not self.cur then return end if not self.cur then
return
end
local x0=self.curX local x0=self.curX
while not self:ifoverlap(self.cur.bk,self.curX-1,self.curY)do while not self:ifoverlap(self.cur.bk,self.curX-1,self.curY)do
self:createMoveFX('left') self:createMoveFX('left')
@@ -1938,13 +2018,17 @@ function Player:act_insLeft(auto)
self.fieldOff.vx=-.5 self.fieldOff.vx=-.5
end end
if auto then if auto then
if self.ctrlCount==0 then self.ctrlCount=1 end if self.ctrlCount==0 then
self.ctrlCount=1
end
else else
self.ctrlCount=self.ctrlCount+1 self.ctrlCount=self.ctrlCount+1
end end
end end
function Player:act_insRight(auto) function Player:act_insRight(auto)
if not self.cur then return end if not self.cur then
return
end
local x0=self.curX local x0=self.curX
while not self:ifoverlap(self.cur.bk,self.curX+1,self.curY)do while not self:ifoverlap(self.cur.bk,self.curX+1,self.curY)do
self:createMoveFX('right') self:createMoveFX('right')
@@ -1958,7 +2042,9 @@ function Player:act_insRight(auto)
self.fieldOff.vx=.5 self.fieldOff.vx=.5
end end
if auto then if auto then
if self.ctrlCount==0 then self.ctrlCount=1 end if self.ctrlCount==0 then
self.ctrlCount=1
end
else else
self.ctrlCount=self.ctrlCount+1 self.ctrlCount=self.ctrlCount+1
end end
@@ -2005,28 +2091,32 @@ function Player:act_down10()
end end
end end
function Player:act_dropLeft() function Player:act_dropLeft()
if not self.cur then return end if self.cur then
self:act_insLeft() self:act_insLeft()
self:act_hardDrop() self:act_hardDrop()
end
end end
function Player:act_dropRight() function Player:act_dropRight()
if not self.cur then return end if self.cur then
self:act_insRight() self:act_insRight()
self:act_hardDrop() self:act_hardDrop()
end
end end
function Player:act_zangiLeft() function Player:act_zangiLeft()
if not self.cur then return end if self.cur then
self:act_insLeft() self:act_insLeft()
self:act_insDown() self:act_insDown()
self:act_insRight() self:act_insRight()
self:act_hardDrop() self:act_hardDrop()
end
end end
function Player:act_zangiRight() function Player:act_zangiRight()
if not self.cur then return end if self.cur then
self:act_insRight() self:act_insRight()
self:act_insDown() self:act_insDown()
self:act_insLeft() self:act_insLeft()
self:act_hardDrop() self:act_hardDrop()
end
end end
Player.actList={ Player.actList={
Player.act_moveLeft, --1 Player.act_moveLeft, --1

View File

@@ -38,8 +38,11 @@ local seqGenerators={
do break end do break end
::CONTINUE_rollAgain:: ::CONTINUE_rollAgain::
end end
if history[1]~=0 then P:getNext(seq0[r])end if history[1]~=0 then
rem(history,1)ins(history,r) P:getNext(seq0[r])
end
rem(history,1)
ins(history,r)
end end
yield() yield()
end end
@@ -63,7 +66,11 @@ local seqGenerators={
for i=2,len do for i=2,len do
if droughtTimes[i]>maxTime then if droughtTimes[i]>maxTime then
maxTime=droughtTimes[i] maxTime=droughtTimes[i]
if #droughtList==1 then droughtList[1]=i else droughtList={i}end if #droughtList==1 then
droughtList[1]=i
else
droughtList={i}
end
elseif droughtTimes[i]==maxTime then elseif droughtTimes[i]==maxTime then
ins(droughtList,i) ins(droughtList,i)
end end
@@ -91,13 +98,18 @@ local seqGenerators={
for i=1,len do for i=1,len do
if r==history[i]then if r==history[i]then
tryTime=tryTime+1 tryTime=tryTime+1
if tryTime<hisLen then goto REPEAT_pickAgain end if tryTime<hisLen then
goto REPEAT_pickAgain
end
end end
end end
--Give mino to player & update history --Give mino to player & update history
if history[1]~=0 then P:getNext(seq0[r])end if history[1]~=0 then
rem(history,1)ins(history,r) P:getNext(seq0[r])
end
rem(history,1)
ins(history,r)
-- print("Player GET: "..r) -- print("Player GET: "..r)
-- print("History: "..table.concat(history,",")) -- print("History: "..table.concat(history,","))
-- local L=TABLE.new("",len) -- local L=TABLE.new("",len)
@@ -142,7 +154,9 @@ local seqGenerators={
while true do while true do
while #P.nextQueue<12 do while #P.nextQueue<12 do
local r=rndGen:random(len-1) local r=rndGen:random(len-1)
if r>=last then r=r+1 end if r>=last then
r=r+1
end
P:getNext(seq0[r]) P:getNext(seq0[r])
last=r last=r
end end

View File

@@ -13,7 +13,9 @@ local function _updateMisc(P,dt)
end end
--Update spike counter --Update spike counter
if P.spikeTime>0 then P.spikeTime=P.spikeTime-1 end if P.spikeTime>0 then
P.spikeTime=P.spikeTime-1
end
--Update atkBuffer alert --Update atkBuffer alert
local t=P.atkBufferSum1 local t=P.atkBufferSum1
@@ -114,7 +116,9 @@ local function _updateMisc(P,dt)
O.va=O.va*.7-abs(O.a)^1.4*(O.a>0 and .08 or -.08) O.va=O.va*.7-abs(O.a)^1.4*(O.a>0 and .08 or -.08)
O.a=O.a+O.va O.a=O.a+O.va
if abs(O.a)<.0006 then O.a,O.va=0,0 end if abs(O.a)<.0006 then
O.a,O.va=0,0
end
end end
--Update texts --Update texts
@@ -142,12 +146,16 @@ function update.alive(P,dt)
P.frameRun=P.frameRun+1 P.frameRun=P.frameRun+1
if P.frameRun<=180 then if P.frameRun<=180 then
if P.frameRun==180 then if P.frameRun==180 then
if P.id==1 then SFX.play('start')end if P.id==1 then
SFX.play('start')
end
P.control=true P.control=true
P.timing=true P.timing=true
P:popNext() P:popNext()
elseif P.frameRun==60 or P.frameRun==120 then elseif P.frameRun==60 or P.frameRun==120 then
if P.id==1 then SFX.play('ready')end if P.id==1 then
SFX.play('ready')
end
end end
if P.movDir~=0 then if P.movDir~=0 then
if P.moving<P.gameEnv.das then if P.moving<P.gameEnv.das then
@@ -193,7 +201,9 @@ function update.alive(P,dt)
for j=1,#P.field do for j=1,#P.field do
local L=V[j] local L=V[j]
for i=1,10 do for i=1,10 do
if L[i]>0 then L[i]=L[i]-1 end if L[i]>0 then
L[i]=L[i]-1
end
end end
end end
end end
@@ -293,7 +303,9 @@ function update.alive(P,dt)
goto THROW_stop goto THROW_stop
else else
local L=#P.clearingRow local L=#P.clearingRow
if P.sound and ENV.fall>0 and #P.field+L>P.clearingRow[L]then SFX.play('fall')end if P.sound and ENV.fall>0 and #P.field+L>P.clearingRow[L]then
SFX.play('fall')
end
P.clearingRow={} P.clearingRow={}
end end
end end
@@ -380,7 +392,9 @@ function update.dead(P,dt)
P.falling=P.falling-1 P.falling=P.falling-1
if P.falling<0 then if P.falling<0 then
local L=#P.clearingRow local L=#P.clearingRow
if P.sound and P.gameEnv.fall>0 and #P.field+L>P.clearingRow[L]then SFX.play('fall')end if P.sound and P.gameEnv.fall>0 and #P.field+L>P.clearingRow[L]then
SFX.play('fall')
end
P.clearingRow={} P.clearingRow={}
end end
end end

View File

@@ -69,7 +69,9 @@ end
local function checkBoard(b) local function checkBoard(b)
for i=4,1,-1 do for i=4,1,-1 do
for j=1,4 do for j=1,4 do
if b[i][j]~=4*i+j-4 then return false end if b[i][j]~=4*i+j-4 then
return false
end
end end
end end
return true return true

View File

@@ -119,7 +119,9 @@ local function newTile()
end end
local function freshMaxTile() local function freshMaxTile()
maxTile=maxTile+1 maxTile=maxTile+1
if maxTile==12 then skipper.cd=0 end if maxTile==12 then
skipper.cd=0
end
SFX.play('reach') SFX.play('reach')
ins(progress,("%s - %.3fs"):format(tileName[maxTile],TIME()-startTime)) ins(progress,("%s - %.3fs"):format(tileName[maxTile],TIME()-startTime))
end end

View File

@@ -233,7 +233,9 @@ end
function scene.mouseDown(x,y) function scene.mouseDown(x,y)
scene.mouseMove(x,y) scene.mouseMove(x,y)
if curX then place(curX,curx)end if curX then
place(curX,curx)
end
end end
scene.widgetList={ scene.widgetList={

View File

@@ -7,6 +7,14 @@ local reg--register
local val--result value local val--result value
local sym--symbol local sym--symbol
local function _autoReturn()
if reg and sym then
scene.keyDown("return")
else
reg=false
end
end
function scene.sceneInit() function scene.sceneInit()
BG.set('none') BG.set('none')
BGM.stop() BGM.stop()
@@ -27,7 +35,9 @@ function scene.keyDown(key)
val=key val=key
else else
if #val<14 then if #val<14 then
if val=="0"then val=""end if val=="0"then
val=""
end
val=val..key val=val..key
end end
end end
@@ -60,19 +70,25 @@ function scene.keyDown(key)
else else
val=val:sub(1,-2) val=val:sub(1,-2)
end end
if val==""then val="0"end if val==""then
val="0"
end
elseif key=="+"or key=="="and kb.isDown("lshift","rshift")then elseif key=="+"or key=="="and kb.isDown("lshift","rshift")then
if reg and sym then scene.keyDown("return")else reg=false end sym="+" _autoReturn()
sym="+"
elseif key=="*"or key=="8"and kb.isDown("lshift","rshift")then elseif key=="*"or key=="8"and kb.isDown("lshift","rshift")then
if reg and sym then scene.keyDown("return")else reg=false end sym="*" _autoReturn()
sym="*"
elseif key=="-"then elseif key=="-"then
if reg and sym then scene.keyDown("return")else reg=false end sym="-" _autoReturn()
sym="-"
elseif key=="/"then elseif key=="/"then
if reg and sym then scene.keyDown("return")else reg=false end sym="/" _autoReturn()
sym="/"
elseif key=="return"then elseif key=="return"then
if val:sub(-1)=="e"then val=val:sub(1,-2)end val=val:gsub("e","")
if sym and reg then if sym and reg then
if reg:sub(-1)=="e"then reg=reg:sub(1,-2)end reg=reg:gsub("e","")
val= val=
sym=="+"and tostring((tonumber(reg)or 0)+tonumber(val))or sym=="+"and tostring((tonumber(reg)or 0)+tonumber(val))or
sym=="-"and tostring((tonumber(reg)or 0)-tonumber(val))or sym=="-"and tostring((tonumber(reg)or 0)-tonumber(val))or

View File

@@ -189,7 +189,9 @@ local commands={}do
commands.del={ commands.del={
code=function(name) code=function(name)
local recursive=name:sub(1,3)=="-s " local recursive=name:sub(1,3)=="-s "
if recursive then name=name:sub(4)end if recursive then
name=name:sub(4)
end
if name~=""then if name~=""then
local info=love.filesystem.getInfo(name) local info=love.filesystem.getInfo(name)
@@ -240,20 +242,35 @@ local commands={}do
--Check file exist --Check file exist
local info local info
info=love.filesystem.getInfo(arg[1]) info=love.filesystem.getInfo(arg[1])
if not(info and info.type=='file')then log{C.R,("'%s' is not a file!"):format(arg[1])}return end if not(info and info.type=='file')then
log{C.R,("'%s' is not a file!"):format(arg[1])}
return
end
info=love.filesystem.getInfo(arg[2]) info=love.filesystem.getInfo(arg[2])
if info then log{C.R,("'%s' already exists!"):format(arg[2])}return end if info then
log{C.R,("'%s' already exists!"):format(arg[2])}
return
end
--Read file --Read file
local data,err1=love.filesystem.read('data',arg[1]) local data,err1=love.filesystem.read('data',arg[1])
if not data then log{C.R,("Failed to read file '%s': "):format(arg[1],err1 or"Unknown error")}return end if not data then
log{C.R,("Failed to read file '%s': "):format(arg[1],err1 or"Unknown error")}
return
end
--Write file --Write file
local res,err2=love.filesystem.write(arg[2],data) local res,err2=love.filesystem.write(arg[2],data)
if not res then log{C.R,("Failed to write file: "):format(err2 or"Unknown error")}return end if not res then
log{C.R,("Failed to write file: "):format(err2 or"Unknown error")}
return
end
--Delete file --Delete file
if not love.filesystem.remove(arg[1])then log{C.R,("Failed to delete old file ''"):format(arg[1])}return end if not love.filesystem.remove(arg[1])then
log{C.R,("Failed to delete old file ''"):format(arg[1])}
return
end
log{C.Y,("Succesfully renamed file '%s' to '%s'"):format(arg[1],arg[2])} log{C.Y,("Succesfully renamed file '%s' to '%s'"):format(arg[1],arg[2])}
end, end,
@@ -701,7 +718,9 @@ local commands={}do
if bool=="sure"then if bool=="sure"then
for name,M in next,MODES do for name,M in next,MODES do
if type(name)=='string'and not RANKS[name]and M.x then if type(name)=='string'and not RANKS[name]and M.x then
if M.x then RANKS[name]=0 end if M.x then
RANKS[name]=0
end
end end
end end
saveProgress() saveProgress()
@@ -896,7 +915,10 @@ local fleg={
second_box="Coming soon", second_box="Coming soon",
}setmetatable(fleg,{__tostring=function()return"The fl\97g."end}) }setmetatable(fleg,{__tostring=function()return"The fl\97g."end})
function userG.the_box(k) function userG.the_box(k)
if k~=first_key then log"Usage:"log"*The box is locked*"return end if k~=first_key then
log"Usage:"log"*The box is locked*"
return
end
log"*Breaking sound*" log"*Breaking sound*"
userG.the_box,userG.the_key=nil,nil userG.the_box,userG.the_key=nil,nil
return fleg return fleg
@@ -923,7 +945,9 @@ function scene.keyDown(key)
--Write History --Write History
ins(history,input) ins(history,input)
if history[27]then rem(history,1)end if history[27]then
rem(history,1)
end
hisPtr=nil hisPtr=nil
--Execute --Execute
@@ -1026,7 +1050,9 @@ function scene.keyDown(key)
SCN.back() SCN.back()
end end
else else
if not WIDGET.isFocus(inputBox)then WIDGET.focus(inputBox)end if not WIDGET.isFocus(inputBox)then
WIDGET.focus(inputBox)
end
WIDGET.keyPressed(key) WIDGET.keyPressed(key)
end end
end end

View File

@@ -179,22 +179,30 @@ function scene.update(dt)
life1=life1*.7+life*.3 life1=life1*.7+life*.3
if play then if play then
if inv>0 then inv=inv-1 end if inv>0 then
inv=inv-1
end
score=score+dt*.04+life*.0004 score=score+dt*.04+life*.0004
life=min(life+dt*.04,1000) life=min(life+dt*.04,1000)
if score>1000*level then if score>1000*level then
if speed<3 then speed=speed+.2 end if speed<3 then
speed=speed+.2
end
level=level+1 level=level+1
SFX.play('blip_1') SFX.play('blip_1')
end end
sunH=sunH+.01 sunH=sunH+.01
elseif menu==1 then elseif menu==1 then
ct=ct+1 ct=ct+1
if ct==60 then menu=false end if ct==60 then
menu=false
end
elseif menu==-1 then elseif menu==-1 then
for i=1,3 do color[i]=near(color[i],cubeColor[1][i])end for i=1,3 do color[i]=near(color[i],cubeColor[1][i])end
for i=1,40 do cubesY[i]=cubesY[i]-(70-ct)*.003 end for i=1,40 do cubesY[i]=cubesY[i]-(70-ct)*.003 end
if sunH>0 then sunH=max(sunH*.85-1,0)end if sunH>0 then
sunH=max(sunH*.85-1,0)
end
ct=ct-1 ct=ct-1
if ct==0 then if ct==0 then
score=0 score=0

View File

@@ -86,8 +86,12 @@ function scene.update()
P.vy=P.vy*.5 P.vy=P.vy*.5
end end
else else
if kb.isDown(P==p1 and"w"or"up")then P.vy=max(P.vy-1,-8)end if kb.isDown(P==p1 and"w"or"up")then
if kb.isDown(P==p1 and"s"or"down")then P.vy=min(P.vy+1,8)end P.vy=max(P.vy-1,-8)
end
if kb.isDown(P==p1 and"s"or"down")then
P.vy=min(P.vy+1,8)
end
P.y=P.y+P.vy P.y=P.y+P.vy
P.vy=P.vy*.9 P.vy=P.vy*.9
if P.y>650 then if P.y>650 then

View File

@@ -36,7 +36,9 @@ function scene.update()
local v=0 local v=0
for i=2,40 do v=v+i*(i-1)*.075/(t-keyTime[i])end for i=2,40 do v=v+i*(i-1)*.075/(t-keyTime[i])end
speed=speed*.99+v*.01 speed=speed*.99+v*.01
if speed>maxSpeed then maxSpeed=speed end if speed>maxSpeed then
maxSpeed=speed
end
end end
function scene.draw() function scene.draw()

View File

@@ -161,7 +161,9 @@ function scene.keyDown(key,isRep)
end end
function scene.mouseMove(x,y) function scene.mouseMove(x,y)
cx,cy=int((x-192)/128),int((y+88)/128) cx,cy=int((x-192)/128),int((y+88)/128)
if cx<1 or cx>5 or cy<1 or cy>5 then cx,cy=false end if cx<1 or cx>5 or cy<1 or cy>5 then
cx,cy=false
end
end end
function scene.mouseDown(x,y) function scene.mouseDown(x,y)
scene.mouseMove(x,y) scene.mouseMove(x,y)

View File

@@ -125,7 +125,9 @@ function scene.mouseMove(x,y)
local sx,sy=int((x-200)/30)+1,20-int((y-60)/30) local sx,sy=int((x-200)/30)+1,20-int((y-60)/30)
if sx>=1 and sx<=10 and sy>=1 and sy<=20 then if sx>=1 and sx<=10 and sy>=1 and sy<=20 then
penX,penY=sx,sy penX,penY=sx,sy
if curPen then _pTouch(sx,sy)end if curPen then
_pTouch(sx,sy)
end
else else
penX,penY=nil penX,penY=nil
end end
@@ -256,7 +258,9 @@ function scene.keyUp(key)
end end
function scene.update(dt) function scene.update(dt)
if sure>0 then sure=sure-dt end if sure>0 then
sure=sure-dt
end
end end
function scene.draw() function scene.draw()

View File

@@ -117,7 +117,9 @@ function scene.keyDown(key)
end end
function scene.update(dt) function scene.update(dt)
if sure>0 then sure=sure-dt end if sure>0 then
sure=sure-dt
end
end end
function scene.draw() function scene.draw()

View File

@@ -120,7 +120,9 @@ function scene.keyDown(key)
end end
function scene.update(dt) function scene.update(dt)
if sure>0 then sure=sure-dt end if sure>0 then
sure=sure-dt
end
end end
function scene.draw() function scene.draw()

View File

@@ -16,7 +16,9 @@ function scene.sceneInit()
NET.wsclose_user() NET.wsclose_user()
NET.wsclose_play() NET.wsclose_play()
NET.wsclose_stream() NET.wsclose_stream()
if SETTING then SFX.fplay('error',SETTING.voc*.8 or 0)end if SETTING then
SFX.fplay('error',SETTING.voc*.8 or 0)
end
end end
function scene.draw() function scene.draw()

View File

@@ -194,7 +194,9 @@ end
function scene.keyDown(key,isRep) function scene.keyDown(key,isRep)
if replaying then if replaying then
if key=="space"then if key=="space"then
if not isRep then gameRate=gameRate==0 and 1 or 0 end if not isRep then
gameRate=gameRate==0 and 1 or 0
end
_updateRepButtons() _updateRepButtons()
elseif key=="left"then elseif key=="left"then
if not isRep then if not isRep then
@@ -215,7 +217,9 @@ function scene.keyDown(key,isRep)
elseif _checkGameKeyDown(key)then elseif _checkGameKeyDown(key)then
if GAME.tasUsed then if GAME.tasUsed then
if key=="f1"then if key=="f1"then
if not isRep then gameRate=gameRate==0 and .125 or 0 end if not isRep then
gameRate=gameRate==0 and .125 or 0
end
_updateRepButtons() _updateRepButtons()
elseif key=='f2'then elseif key=='f2'then
if not isRep then if not isRep then
@@ -307,7 +311,9 @@ function scene.update(dt)
floatGameRate=floatGameRate+gameRate floatGameRate=floatGameRate+gameRate
while floatGameRate>=1 do while floatGameRate>=1 do
floatGameRate=floatGameRate-1 floatGameRate=floatGameRate-1
if GAME.replaying then _update_replay(GAME.replaying)end if GAME.replaying then
_update_replay(GAME.replaying)
end
_update_common(dt) _update_common(dt)
end end
end end

View File

@@ -7,7 +7,9 @@ local function _modComp(a,b)
end end
local function _remMod(M) local function _remMod(M)
local i=TABLE.find(GAME.mod,M) local i=TABLE.find(GAME.mod,M)
if i then rem(GAME.mod,i)end if i then
rem(GAME.mod,i)
end
end end
local function _toggleMod(M,back) local function _toggleMod(M,back)
if M.sel==0 then if M.sel==0 then

View File

@@ -48,7 +48,9 @@ function scene.keyDown(key,isRep)
if key=="return"or key=="space"then if key=="return"or key=="space"then
if BGM.nowPlay~=bgmList[S]then if BGM.nowPlay~=bgmList[S]then
BGM.play(bgmList[S]) BGM.play(bgmList[S])
if SETTING.bgm>0 then SFX.play('click')end if SETTING.bgm>0 then
SFX.play('click')
end
else else
BGM.stop() BGM.stop()
end end
@@ -66,11 +68,19 @@ function scene.draw()
setFont(50) setFont(50)
gc.print(bgmList[selected],320,355) gc.print(bgmList[selected],320,355)
setFont(35) setFont(35)
if selected>1 then gc.print(bgmList[selected-1],320,350-30)end if selected>1 then
if selected<#bgmList then gc.print(bgmList[selected+1],320,350+65)end gc.print(bgmList[selected-1],320,350-30)
end
if selected<#bgmList then
gc.print(bgmList[selected+1],320,350+65)
end
setFont(20) setFont(20)
if selected>2 then gc.print(bgmList[selected-2],320,350-50)end if selected>2 then
if selected<#bgmList-1 then gc.print(bgmList[selected+2],320,350+110)end gc.print(bgmList[selected-2],320,350-50)
end
if selected<#bgmList-1 then
gc.print(bgmList[selected+2],320,350+110)
end
gc.draw(TEXTURE.title,840,220,nil,.5,nil,580,118) gc.draw(TEXTURE.title,840,220,nil,.5,nil,580,118)
if BGM.nowPlay then if BGM.nowPlay then

View File

@@ -68,7 +68,9 @@ function scene.sceneInit(org)
upstreamProgress=1 upstreamProgress=1
newMessageTimer=0 newMessageTimer=0
if org=='setting_game'then NET.changeConfig()end if org=='setting_game'then
NET.changeConfig()
end
if GAME.prevBG then if GAME.prevBG then
BG.set(GAME.prevBG) BG.set(GAME.prevBG)
GAME.prevBG=false GAME.prevBG=false
@@ -311,8 +313,12 @@ function scene.draw()
gc_printf(NET.roomState.roomInfo.name,0,685,1270,'right') gc_printf(NET.roomState.roomInfo.name,0,685,1270,'right')
setFont(40) setFont(40)
gc_print(netPLY.getCount().."/"..NET.roomState.capacity,70,655) gc_print(netPLY.getCount().."/"..NET.roomState.capacity,70,655)
if NET.roomState.private then gc_draw(IMG.lock,30,668)end if NET.roomState.private then
if NET.roomState.start then gc_setColor(0,1,0)gc_print(text.started,230,655)end gc_draw(IMG.lock,30,668)
end
if NET.roomState.start then
gc_setColor(0,1,0)gc_print(text.started,230,655)
end
--Profile --Profile
drawSelfProfile() drawSelfProfile()

View File

@@ -29,7 +29,9 @@ local function _createRoom()
local pw=passwordBox.value local pw=passwordBox.value
if pw==""then pw=nil end if pw==""then pw=nil end
local roomname=STRING.trim(roomNameBox.value) local roomname=STRING.trim(roomNameBox.value)
if #roomname==0 then roomname=(USERS.getUsername(USER.uid)or"Anonymous").."'s room"end if #roomname==0 then
roomname=(USERS.getUsername(USER.uid)or"Anonymous").."'s room"
end
NET.createRoom( NET.createRoom(
roomname, roomname,
descriptionBox.value, descriptionBox.value,

View File

@@ -16,7 +16,9 @@ local roomList=WIDGET.newListBox{name="roomList",x=50,y=50,w=800,h=440,lineH=40,
gc_rectangle('fill',0,0,800,40) gc_rectangle('fill',0,0,800,40)
end end
gc_setColor(1,1,1) gc_setColor(1,1,1)
if item.private then gc_draw(IMG.lock,10,5)end if item.private then
gc_draw(IMG.lock,10,5)
end
gc_print(item.count.."/"..item.capacity,670,-4) gc_print(item.count.."/"..item.capacity,670,-4)
gc_setColor(.9,.9,1) gc_setColor(.9,.9,1)

View File

@@ -73,8 +73,13 @@ function scene.sceneInit(org)
end end
local f=1 local f=1
for i=1,6 do for i=1,6 do
if val[i]>.5 then f=2 end if val[i]>.5 then
if val[i]>1 then f=3 break end f=2
end
if val[i]>1 then
f=3
break
end
end end
if f==1 then chartColor,f={.4,.9,.5},1.25--Vegetable if f==1 then chartColor,f={.4,.9,.5},1.25--Vegetable
elseif f==2 then chartColor,f={.4,.7,.9},1 --Normal elseif f==2 then chartColor,f={.4,.7,.9},1 --Normal
@@ -177,8 +182,12 @@ function scene.update(dt)
if not(GAME.result or GAME.replaying)then if not(GAME.result or GAME.replaying)then
GAME.pauseTime=GAME.pauseTime+dt GAME.pauseTime=GAME.pauseTime+dt
end end
if timer1<50 then timer1=timer1+1 end if timer1<50 then
if timer2<25 then timer2=timer2+1 end timer1=timer1+1
end
if timer2<25 then
timer2=timer2+1
end
end end
local hexList={1,0,.5,1.732*.5,-.5,1.732*.5} local hexList={1,0,.5,1.732*.5,-.5,1.732*.5}
@@ -189,7 +198,9 @@ local tasText=gc.newText(getFont(100),"TAS")
function scene.draw() function scene.draw()
local T=timer1*.02 local T=timer1*.02
local T2=timer2*.04 local T2=timer2*.04
if T<1 or GAME.result then SCN.scenes.game.draw()end if T<1 or GAME.result then
SCN.scenes.game.draw()
end
--Dark BG --Dark BG
local _=T local _=T

View File

@@ -142,7 +142,9 @@ function scene.keyDown(key)
end end
function scene.update(dt) function scene.update(dt)
if sure>0 then sure=sure-dt end if sure>0 then
sure=sure-dt
end
end end
function scene.draw() function scene.draw()

View File

@@ -43,7 +43,9 @@ function scene.touchDown(x,y)
end end
function scene.update() function scene.update()
if jump>0 then jump=jump-1 end if jump>0 then
jump=jump-1
end
end end
function scene.draw() function scene.draw()
@@ -83,7 +85,9 @@ scene.widgetList={
WIDGET.newKey{name="mute", x=1160,y=180,w=80,color='lR',fText=TEXTURE.mute, WIDGET.newKey{name="mute", x=1160,y=180,w=80,color='lR',fText=TEXTURE.mute,
code=function() code=function()
if SETTING.sfx+SETTING.sfx_spawn+SETTING.sfx_warn+SETTING.bgm+SETTING.vib+SETTING.voc==0 then if SETTING.sfx+SETTING.sfx_spawn+SETTING.sfx_warn+SETTING.bgm+SETTING.vib+SETTING.voc==0 then
if not soundBeforeMute then soundBeforeMute={1,0,.4,.7,0,0}end if not soundBeforeMute then
soundBeforeMute={1,0,.4,.7,0,0}
end
SETTING.sfx,SETTING.sfx_spawn,SETTING.sfx_warn,SETTING.bgm,SETTING.vib,SETTING.voc=unpack(soundBeforeMute) SETTING.sfx,SETTING.sfx_spawn,SETTING.sfx_warn,SETTING.bgm,SETTING.vib,SETTING.voc=unpack(soundBeforeMute)
soundBeforeMute=false soundBeforeMute=false
else else

View File

@@ -56,7 +56,9 @@ local function _onVK_org(x,y)
return nearest return nearest
end end
function scene.mouseDown(x,y,k) function scene.mouseDown(x,y,k)
if k==1 then scene.touchDown(x,y)end if k==1 then
scene.touchDown(x,y)
end
end end
function scene.mouseUp() function scene.mouseUp()
scene.touchUp() scene.touchUp()

View File

@@ -22,15 +22,23 @@ function scene.keyDown(key,isRep)
pc=not pc pc=not pc
elseif type(key)=='number'then elseif type(key)=='number'then
local CHN=VOC.getFreeChannel() local CHN=VOC.getFreeChannel()
if mini then VOC.play('mini',CHN)end if mini then
if b2b then VOC.play('b2b',CHN) VOC.play('mini',CHN)
elseif b3b then VOC.play('b3b',CHN) end
if b2b then
VOC.play('b2b',CHN)
elseif b3b then
VOC.play('b3b',CHN)
end end
if key>=10 then if key>=10 then
VOC.play(blockName[math.floor(key/10)].."spin",CHN) VOC.play(blockName[math.floor(key/10)].."spin",CHN)
end end
if lineCount[key%10]then VOC.play(lineCount[key%10],CHN)end if lineCount[key%10]then
if pc then VOC.play('perfect_clear',CHN)end VOC.play(lineCount[key%10],CHN)
end
if pc then
VOC.play('perfect_clear',CHN)
end
elseif key=="tab"then elseif key=="tab"then
SCN.swapTo('music','none') SCN.swapTo('music','none')
elseif key=="escape"then elseif key=="escape"then

View File

@@ -96,7 +96,9 @@ function scene.draw()
end end
mDraw(TEXTURE.title_color,640,800-T,nil,.6) mDraw(TEXTURE.title_color,640,800-T,nil,.6)
mDraw(TEXTURE.title_color,640,2160-T,nil,.6) mDraw(TEXTURE.title_color,640,2160-T,nil,.6)
if time>50 then gc.print("CLICK ME →",50,550,-.5)end if time>50 then
gc.print("CLICK ME →",50,550,-.5)
end
end end
scene.widgetList={ scene.widgetList={

View File

@@ -36,10 +36,14 @@ function SKIN.init(list)
for y=0,2 do for y=0,2 do
for x=1,8 do for x=1,8 do
SKIN.lib[name][8*y+x]=C(30,30) SKIN.lib[name][8*y+x]=C(30,30)
if I then gc.draw(I,30-30*x,-30*y)end if I then
gc.draw(I,30-30*x,-30*y)
end
SKIN.libMini[name][8*y+x]=C(6,6) SKIN.libMini[name][8*y+x]=C(6,6)
if I then gc.draw(I,6-6*x,-6*y,nil,.2)end if I then
gc.draw(I,6-6*x,-6*y,nil,.2)
end
end end
end end
gc.setCanvas() gc.setCanvas()