整理代码,只在代码中使用的字符串由双引号改为单引号

This commit is contained in:
MrZ626
2021-06-29 04:09:06 +08:00
parent 1c553df53a
commit 706fa901e2
17 changed files with 221 additions and 221 deletions

View File

@@ -2,10 +2,10 @@ local gc_clear=love.graphics.clear
local BGs={ local BGs={
none={draw=function()gc_clear(.15,.15,.15)end} none={draw=function()gc_clear(.15,.15,.15)end}
} }
local BGlist={"none"} local BGlist={'none'}
local BG={ local BG={
cur="none", cur='none',
default="none", default='none',
init=false, init=false,
resize=false, resize=false,
update=NULL, update=NULL,

View File

@@ -44,7 +44,7 @@ function BGM.init(list)
end end
local function load(skip) local function load(skip)
for i=1,count do for i=1,count do
local file="media/BGM/"..list[i]..".ogg" local file='media/BGM/'..list[i]..'.ogg'
if love.filesystem.getInfo(file)then if love.filesystem.getInfo(file)then
Sources[list[i]]=love.audio.newSource(file,'stream') Sources[list[i]]=love.audio.newSource(file,'stream')
Sources[list[i]]:setLooping(true) Sources[list[i]]:setLooping(true)

View File

@@ -57,7 +57,7 @@ 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 or fs.getInfo(path).type~='directory'then return end
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
@@ -67,9 +67,9 @@ function FILE.clear(path)
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~=''and(fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory')then return end
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

View File

@@ -13,10 +13,10 @@ function IMG.init(list)
local loaded=0 local loaded=0
for k,v in next,list do for k,v in next,list do
if type(v)=='string'then if type(v)=='string'then
IMG[k]=love.graphics.newImage("media/image/"..v) IMG[k]=love.graphics.newImage('media/image/'..v)
else else
for i=1,#v do for i=1,#v do
v[i]=love.graphics.newImage("media/image/"..v[i]) v[i]=love.graphics.newImage('media/image/'..v[i])
end end
IMG[k]=v IMG[k]=v
end end

View File

@@ -3,44 +3,44 @@ EDITING=""
LOADED=false LOADED=false
ERRDATA={} ERRDATA={}
require"Zframework.setFont" require'Zframework.setFont'
ADRAW=require"Zframework.aDraw" ADRAW=require'Zframework.aDraw'
mStr=ADRAW.str mStr=ADRAW.str
mText=ADRAW.simpX mText=ADRAW.simpX
mDraw=ADRAW.draw mDraw=ADRAW.draw
SCR= require"Zframework.screen" SCR= require'Zframework.screen'
COLOR= require"Zframework.color" COLOR= require'Zframework.color'
SCN= require"Zframework.scene" SCN= require'Zframework.scene'
WS= require"Zframework.websocket" WS= require'Zframework.websocket'
LOADLIB=require"Zframework.loadLib" LOADLIB=require'Zframework.loadLib'
WHEELMOV=require"Zframework.wheelScroll" WHEELMOV=require'Zframework.wheelScroll'
JSON= require"Zframework.json" JSON= require'Zframework.json'
TABLE= require"Zframework.tableExtend" TABLE= require'Zframework.tableExtend'
STRING= require"Zframework.stringExtend" STRING= require'Zframework.stringExtend'
VIB= require"Zframework.vibrate" VIB= require'Zframework.vibrate'
SFX= require"Zframework.sfx" SFX= require'Zframework.sfx'
LIGHT= require"Zframework.light" LIGHT= require'Zframework.light'
DOGC= require"Zframework.doGC" DOGC= require'Zframework.doGC'
BG= require"Zframework.background" BG= require'Zframework.background'
WIDGET= require"Zframework.widget" WIDGET= require'Zframework.widget'
TEXT= require"Zframework.text" TEXT= require'Zframework.text'
SYSFX= require"Zframework.sysFX" SYSFX= require'Zframework.sysFX'
MES= require"Zframework.message" MES= require'Zframework.message'
IMG= require"Zframework.image" IMG= require'Zframework.image'
BGM= require"Zframework.bgm" BGM= require'Zframework.bgm'
VOC= require"Zframework.voice" VOC= require'Zframework.voice'
LANG= require"Zframework.languages" LANG= require'Zframework.languages'
TASK= require"Zframework.task" TASK= require'Zframework.task'
FILE= require"Zframework.file" FILE= require'Zframework.file'
PROFILE=require"Zframework.profile" PROFILE=require'Zframework.profile'
THEME= require"Zframework.theme" THEME= require'Zframework.theme'
local ms,kb=love.mouse,love.keyboard local ms,kb=love.mouse,love.keyboard
@@ -267,7 +267,7 @@ function love.keypressed(key,_,isRep)
MES.new('info',"DEBUG ON",.2) MES.new('info',"DEBUG ON",.2)
elseif key=="f11"then elseif key=="f11"then
if kb.isDown("lctrl","rctrl")then if kb.isDown("lctrl","rctrl")then
_G["\100\114\97\119\70\87\77"]=NULL _G['\100\114\97\119\70\87\77']=NULL
else else
switchFullscreen() switchFullscreen()
end end
@@ -371,7 +371,7 @@ function love.resize(w,h)
if SCN.resize then SCN.resize(w,h)end if SCN.resize then SCN.resize(w,h)end
WIDGET.resize(w,h) WIDGET.resize(w,h)
SHADER.warning:send("w",w*SCR.dpi) SHADER.warning:send('w',w*SCR.dpi)
end end
function love.focus(f) function love.focus(f)
if f then if f then

View File

@@ -26,7 +26,7 @@ function LANG.init(langList,publicText)--Attention, calling this will destory al
end end
--Metatable:__call for table:getTip --Metatable:__call for table:getTip
if type(rawget(L,"getTip"))=='table'then if type(rawget(L,'getTip'))=='table'then
setmetatable(L.getTip,tipMeta) setmetatable(L.getTip,tipMeta)
end end
end end

View File

@@ -6,8 +6,8 @@ local clear,gc_translate=gc.clear,gc.translate
local gc_setCanvas,gc_setShader=gc.setCanvas,gc.setShader local gc_setCanvas,gc_setShader=gc.setCanvas,gc.setShader
local gc_setColor,gc_draw=gc.setColor,gc.draw local gc_setColor,gc_draw=gc.setColor,gc.draw
local shadowMapShader=gc.newShader("Zframework/light/shadowMap.glsl")--Shader for caculating the 1D shadow map. local shadowMapShader=gc.newShader('Zframework/light/shadowMap.glsl')--Shader for caculating the 1D shadow map.
local lightRenderShader=gc.newShader("Zframework/light/lightRender.glsl")--Shader for rendering blurred lights and shadows. local lightRenderShader=gc.newShader('Zframework/light/lightRender.glsl')--Shader for rendering blurred lights and shadows.
local Lights={}--Lightsource objects local Lights={}--Lightsource objects
local function move(L,x,y) local function move(L,x,y)
L.x,L.y=x,y L.x,L.y=x,y
@@ -22,8 +22,8 @@ local function drawLight(L)
gc_setCanvas(L.blackCanvas)clear() gc_setCanvas(L.blackCanvas)clear()
gc_setCanvas(L.shadowCanvas)clear() gc_setCanvas(L.shadowCanvas)clear()
gc_setCanvas(L.renderCanvas)clear() gc_setCanvas(L.renderCanvas)clear()
lightRenderShader:send("xresolution",s) lightRenderShader:send('xresolution',s)
shadowMapShader:send("yresolution",s) shadowMapShader:send('yresolution',s)
--Get up-left of light --Get up-left of light
local X=L.x-s*.5 local X=L.x-s*.5

View File

@@ -1,21 +1,21 @@
return function(name,libName) return function(name,libName)
if SYSTEM=="Windows"or SYSTEM=="Linux"then if SYSTEM=='Windows'or SYSTEM=='Linux'then
local r1,r2,r3=pcall(require,libName[SYSTEM]) local r1,r2,r3=pcall(require,libName[SYSTEM])
if r1 and r2 then if r1 and r2 then
return r2 return r2
else else
MES.new('error',"Cannot load "..name..": "..(r2 or r3)) MES.new('error',"Cannot load "..name..": "..(r2 or r3))
end end
elseif SYSTEM=="Android"then elseif SYSTEM=='Android'then
local fs=love.filesystem local fs=love.filesystem
local platform={'arm64-v8a','armeabi-v7a'} local platform={'arm64-v8a','armeabi-v7a'}
for i=1,#platform do for i=1,#platform do
local soFile,_,_,mes1=fs.read('data',"libAndroid/"..platform[i].."/"..libName.Android) local soFile,_,_,mes1=fs.read('data','libAndroid/'..platform[i]..'/'..libName.Android)
if soFile then if soFile then
local success,mes2=fs.write("lib/"..libName.Android,soFile) local success,mes2=fs.write('lib/'..libName.Android,soFile)
if success then if success then
libFunc,mes2=package.loadlib(SAVEDIR.."/lib/"..libName.Android,libName.libFunc) libFunc,mes2=package.loadlib(SAVEDIR..'/lib/'..libName.Android,libName.libFunc)
if libFunc then if libFunc then
MES.new('check',name.." lib loaded") MES.new('check',name.." lib loaded")
break break

View File

@@ -129,10 +129,10 @@ end
function MES.traceback() function MES.traceback()
local mes= local mes=
debug.traceback("",1) debug.traceback('',1)
:gsub(": in function",", in") :gsub(': in function',', in')
:gsub(":"," ") :gsub(':',' ')
:gsub("\t","") :gsub('\t','')
MES.new('error',mes:sub( MES.new('error',mes:sub(
mes:find("\n",2)+1, mes:find("\n",2)+1,
mes:find("\n%[C%], in 'xpcall'") mes:find("\n%[C%], in 'xpcall'")

View File

@@ -26,7 +26,7 @@ function profile.hooker(event,line,info)
_telapsed[f]=_telapsed[f]+dt _telapsed[f]=_telapsed[f]+dt
_tcalled[f]=nil _tcalled[f]=nil
end end
if event=="tail call"then if event=='tail call'then
local prev=getInfo(3,'fnS') local prev=getInfo(3,'fnS')
profile.hooker('return',line,prev) profile.hooker('return',line,prev)
profile.hooker('call',line,info) profile.hooker('call',line,info)

View File

@@ -5,7 +5,7 @@ local SCR=SCR
local scenes={} local scenes={}
local SCN={ local SCN={
cur="NULL",--Current scene name cur='NULL',--Current scene name
swapping=false,--If Swapping swapping=false,--If Swapping
stat={ stat={
tar=false, --Swapping target tar=false, --Swapping target

View File

@@ -2,8 +2,8 @@ local gc=love.graphics
local newFont=gc.setNewFont local newFont=gc.setNewFont
local setNewFont=gc.setFont local setNewFont=gc.setFont
local fontCache,currentFontSize={} local fontCache,currentFontSize={}
if love.filesystem.getInfo("font.ttf")then if love.filesystem.getInfo('font.ttf')then
local fontData=love.filesystem.newFile("font.ttf") local fontData=love.filesystem.newFile('font.ttf')
function setFont(s) function setFont(s)
if s~=currentFontSize then if s~=currentFontSize then
if not fontCache[s]then if not fontCache[s]then

View File

@@ -13,7 +13,7 @@ function SFX.init(list)
local count=#list function SFX.getCount()return count end local count=#list function SFX.getCount()return count end
local function load(skip) local function load(skip)
for i=1,count do for i=1,count do
local N="media/SFX/"..list[i]..".ogg" local N='media/SFX/'..list[i]..'.ogg'
if love.filesystem.getInfo(N)then if love.filesystem.getInfo(N)then
Sources[list[i]]={love.audio.newSource(N,'static')} Sources[list[i]]={love.audio.newSource(N,'static')}
else else

View File

@@ -7,19 +7,19 @@ 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
M=="12"and math.abs(D-25)<4 and M=='12'and math.abs(D-25)<4 and
'xmas'or 'xmas'or
--Birthday --Birthday
M=="06"and D=="06"and M=='06'and D=='06'and
'birth'or 'birth'or
--Spring festival --Spring festival
M<"03"and math.abs((({ M<'03'and math.abs((({
--Festival days. Jan 26=26, Feb 1=32, etc. --Festival days. Jan 26=26, Feb 1=32, etc.
24,43,32,22,40,29,49,38,26,45, 24,43,32,22,40,29,49,38,26,45,
34,23,41,31,50,39,28,47,36,25, 34,23,41,31,50,39,28,47,36,25,
@@ -32,14 +32,14 @@ function THEME.calculate(Y,M,D)
'sprfes'or 'sprfes'or
--April fool's day --April fool's day
M=="04"and D=="01"and M=='04'and D=='01'and
'fool'or 'fool'or
--Z day (Feb./Mar./Apr./May./June. 26) --Z day (Feb./Mar./Apr./May./June. 26)
D=="26"and( D=='26'and(
(M=="01"or M=="02")and'zday1'or (M=='01'or M=='02')and'zday1'or
(M=="03"or M=="04")and'zday2'or (M=='03'or M=='04')and'zday2'or
(M=="05"or M=="06")and'zday3' (M=='05'or M=='06')and'zday3'
)or )or
'classic' 'classic'
@@ -48,7 +48,7 @@ end
function THEME.set(theme) function THEME.set(theme)
if theme=='classic'then if theme=='classic'then
BG.setDefault('space') BG.setDefault('space')
BGM.setDefault("space") BGM.setDefault('space')
elseif theme=='xmas'then elseif theme=='xmas'then
BG.setDefault('snow') BG.setDefault('snow')
BGM.setDefault('xmas') BGM.setDefault('xmas')
@@ -58,20 +58,20 @@ function THEME.set(theme)
BGM.setDefault('magicblock') BGM.setDefault('magicblock')
elseif theme=='sprfes'then elseif theme=='sprfes'then
BG.setDefault('firework') BG.setDefault('firework')
BGM.setDefault("spring festival") BGM.setDefault('spring festival')
MES.new('info',"★☆新年快乐☆★") MES.new('info',"★☆新年快乐☆★")
elseif theme=='zday1'then elseif theme=='zday1'then
BG.setDefault('lanterns') BG.setDefault('lanterns')
BGM.setDefault("empty") BGM.setDefault('empty')
elseif theme=='zday2'then elseif theme=='zday2'then
BG.setDefault('lanterns') BG.setDefault('lanterns')
BGM.setDefault("overzero") BGM.setDefault('overzero')
elseif theme=='zday3'then elseif theme=='zday3'then
BG.setDefault('lanterns') BG.setDefault('lanterns')
BGM.setDefault("vacuum") BGM.setDefault('vacuum')
elseif theme=='fool'then elseif theme=='fool'then
BG.setDefault('blockrain') BG.setDefault('blockrain')
BGM.setDefault("how feeling") BGM.setDefault('how feeling')
else else
return return
end end
@@ -87,7 +87,7 @@ function THEME.getThemeColor(theme)
end end
function THEME.fresh() function THEME.fresh()
THEME.set(THEME.calculate(os.date("%Y"),os.date("%m"),os.date("%d"))) THEME.set(THEME.calculate(os.date('%Y'),os.date('%m'),os.date('%d')))
end end
return THEME return THEME

View File

@@ -15,9 +15,9 @@ function VOC.init(list)
local count=#list function VOC.getCount()return count end local count=#list function VOC.getCount()return count end
local function loadVoiceFile(N,vocName) local function loadVoiceFile(N,vocName)
local fileName="media/VOICE/"..SETTING.cv.."/"..vocName..".ogg" local fileName='media/VOICE/'..SETTING.cv..'/'..vocName..'.ogg'
if love.filesystem.getInfo(fileName)then if love.filesystem.getInfo(fileName)then
bank[vocName]={love.audio.newSource(fileName,"static")} bank[vocName]={love.audio.newSource(fileName,'static')}
table.insert(Source[N],vocName) table.insert(Source[N],vocName)
return true return true
end end
@@ -41,7 +41,7 @@ function VOC.init(list)
Source[list[i]]={} Source[list[i]]={}
local n=0 local n=0
repeat n=n+1 until not loadVoiceFile(list[i],list[i].."_"..n) repeat n=n+1 until not loadVoiceFile(list[i],list[i]..'_'..n)
if n==1 then if n==1 then
if not loadVoiceFile(list[i],list[i])then if not loadVoiceFile(list[i],list[i])then

View File

@@ -1,12 +1,12 @@
local host= local host=
-- "127.0.0.1" -- '127.0.0.1'
-- "192.168.114.102" -- '192.168.114.102'
"krakens.tpddns.cn" 'krakens.tpddns.cn'
-- "game.techmino.org" -- 'game.techmino.org'
local port="10026" local port='10026'
local path="/tech/socket/v1" local path='/tech/socket/v1'
local debugMode=""--S:send, R:receive, M=mark local debugMode=''--S:send, R:receive, M=mark
local wsThread=[[ local wsThread=[[
-- lua + LÖVE threading websocket client -- lua + LÖVE threading websocket client
@@ -18,8 +18,8 @@ local triggerCHN,sendCHN,readCHN,threadName=...
local CHN_demand,CHN_getCount=triggerCHN.demand,triggerCHN.getCount local CHN_demand,CHN_getCount=triggerCHN.demand,triggerCHN.getCount
local CHN_push,CHN_pop=triggerCHN.push,triggerCHN.pop local CHN_push,CHN_pop=triggerCHN.push,triggerCHN.pop
local SOCK=require"socket".tcp() local SOCK=require'socket'.tcp()
local JSON=require"Zframework.json" local JSON=require'Zframework.json'
do--Connect do--Connect
local host=CHN_demand(sendCHN) local host=CHN_demand(sendCHN)
@@ -33,38 +33,38 @@ do--Connect
if err then CHN_push(readCHN,err)return end if err then CHN_push(readCHN,err)return end
--WebSocket handshake --WebSocket handshake
if not body then body=""end if not body then body=''end
SOCK:send( SOCK:send(
"GET "..path.." HTTP/1.1\r\n".. 'GET '..path..' HTTP/1.1\r\n'..
"Host: "..host..":"..port.."\r\n".. 'Host: '..host..':'..port..'\r\n'..
"Connection: Upgrade\r\n".. 'Connection: Upgrade\r\n'..
"Upgrade: websocket\r\n".. 'Upgrade: websocket\r\n'..
"Content-Type: application/json\r\n".. 'Content-Type: application/json\r\n'..
"Content-Length: "..#body.."\r\n".. 'Content-Length: '..#body..'\r\n'..
"Sec-WebSocket-Version: 13\r\n".. 'Sec-WebSocket-Version: 13\r\n'..
"Sec-WebSocket-Key: osT3F7mvlojIvf3/8uIsJQ==\r\n\r\n"..--secKey 'Sec-WebSocket-Key: osT3F7mvlojIvf3/8uIsJQ==\r\n\r\n'..--secKey
body body
) )
--First line of HTTP --First line of HTTP
res,err=SOCK:receive("*l") res,err=SOCK:receive('*l')
if not res then CHN_push(readCHN,err)return end if not res then CHN_push(readCHN,err)return end
local code,ctLen local code,ctLen
code=res:find(" ") code=res:find(' ')
code=res:sub(code+1,code+3) code=res:sub(code+1,code+3)
--Get body length from headers and remove headers --Get body length from headers and remove headers
repeat repeat
res,err=SOCK:receive("*l") res,err=SOCK:receive('*l')
if not res then CHN_push(readCHN,err)return end if not res then CHN_push(readCHN,err)return end
if not ctLen and res:find("length")then if not ctLen and res:find('length')then
ctLen=tonumber(res:match("%d+")) ctLen=tonumber(res:match('%d+'))
end end
until res=="" until res==''
--Result --Result
if ctLen then if ctLen then
if code=="101"then if code=='101'then
CHN_push(readCHN,'success') CHN_push(readCHN,'success')
else else
res,err=SOCK:receive(ctLen) res,err=SOCK:receive(ctLen)
@@ -94,7 +94,7 @@ local _send do
local mask_str=char(unpack(mask_key)) local mask_str=char(unpack(mask_key))
function _send(op,message) function _send(op,message)
]]..(debugMode:find'S'and""or"--")..[[print((">> %s[%d]:%s"):format(threadName,#message,message)) ]]..(debugMode:find'S'and''or'--')..[[print((">> %s[%d]:%s"):format(threadName,#message,message))
--Message type --Message type
SOCK:send(char(bor(0x80,op))) SOCK:send(char(bor(0x80,op)))
@@ -115,7 +115,7 @@ local _send do
end end
return SOCK:send(char(unpack(msgbyte))) return SOCK:send(char(unpack(msgbyte)))
else else
SOCK:send("\128"..mask_str) SOCK:send('\128'..mask_str)
return 0 return 0
end end
end end
@@ -162,7 +162,7 @@ while true do--Running
if s then if s then
res=s res=s
elseif p then--UNF head elseif p then--UNF head
]]..(debugMode:find'R'and""or"--")..[[print(("<< %s[%d/%d]:%s"):format(threadName,#p,length,#p<50 and p or p:sub(1,50))) ]]..(debugMode:find'R'and''or'--')..[[print(("<< %s[%d/%d]:%s"):format(threadName,#p,length,#p<50 and p or p:sub(1,50)))
UFF=true UFF=true
sBuffer=sBuffer..p sBuffer=sBuffer..p
length=length-#p length=length-#p
@@ -174,11 +174,11 @@ while true do--Running
else else
local s,e,p=SOCK:receive(length) local s,e,p=SOCK:receive(length)
if s then if s then
]]..(debugMode:find'R'and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#s<50 and s or s:sub(1,50))) ]]..(debugMode:find'R'and''or'--')..[[print(("<< %s(%d):%s"):format(threadName,length,#s<50 and s or s:sub(1,50)))
sBuffer=sBuffer..s sBuffer=sBuffer..s
length=length-#s length=length-#s
elseif p then elseif p then
]]..(debugMode:find'R'and""or"--")..[[print(("<< %s(%d):%s"):format(threadName,length,#p<50 and p or p:sub(1,50))) ]]..(debugMode:find'R'and''or'--')..[[print(("<< %s(%d):%s"):format(threadName,length,#p<50 and p or p:sub(1,50)))
sBuffer=sBuffer..p sBuffer=sBuffer..p
length=length-#p length=length-#p
end end
@@ -189,7 +189,7 @@ while true do--Running
break break
end end
end end
]]..(debugMode:find'R'and""or"--")..[[print(("<< %s[(%d)]:%s"):format(threadName,#res,#res<800 and res or res:sub(1,150).."\n...\n"..res:sub(-150))) ]]..(debugMode:find'R'and''or'--')..[[print(("<< %s[(%d)]:%s"):format(threadName,#res,#res<800 and res or res:sub(1,150).."\n...\n"..res:sub(-150)))
--React --React
if op==8 then--8=close if op==8 then--8=close
@@ -203,21 +203,21 @@ while true do--Running
elseif op==0 then--0=continue elseif op==0 then--0=continue
lBuffer=lBuffer..res lBuffer=lBuffer..res
if fin then if fin then
]]..(debugMode:find'M'and""or"--")..[[print("FIN=1 (c") ]]..(debugMode:find'M'and''or'--')..[[print("FIN=1 (c")
CHN_push(readCHN,lBuffer) CHN_push(readCHN,lBuffer)
lBuffer="" lBuffer=""
else else
]]..(debugMode:find'M'and""or"--")..[[print("FIN=0 (c") ]]..(debugMode:find'M'and''or'--')..[[print("FIN=0 (c")
end end
else else
CHN_push(readCHN,op) CHN_push(readCHN,op)
if fin then if fin then
]]..(debugMode:find'M'and""or"--")..[[print("OP: "..op.."\tFIN=1") ]]..(debugMode:find'M'and''or'--')..[[print("OP: "..op.."\tFIN=1")
CHN_push(readCHN,res) CHN_push(readCHN,res)
else else
]]..(debugMode:find'M'and""or"--")..[[print("OP: "..op.."\tFIN=0") ]]..(debugMode:find'M'and''or'--')..[[print("OP: "..op.."\tFIN=0")
sBuffer=res sBuffer=res
]]..(debugMode:find'M'and""or"--")..[[print("START pack: "..res) ]]..(debugMode:find'M'and''or'--')..[[print("START pack: "..res)
end end
end end
end end

216
main.lua
View File

@@ -24,7 +24,7 @@ local fs=love.filesystem
TIME=love.timer.getTime TIME=love.timer.getTime
YIELD=coroutine.yield YIELD=coroutine.yield
SYSTEM=love.system.getOS() SYSTEM=love.system.getOS()
MOBILE=SYSTEM=="Android"or SYSTEM=="iOS" MOBILE=SYSTEM=='Android'or SYSTEM=='iOS'
SAVEDIR=fs.getSaveDirectory() SAVEDIR=fs.getSaveDirectory()
--Global Vars & Settings --Global Vars & Settings
@@ -38,14 +38,14 @@ love.keyboard.setTextInput(false)
love.mouse.setVisible(false) love.mouse.setVisible(false)
--Load modules --Load modules
require"Zframework" require'Zframework'
SCR.setSize(1280,720)--Initialize Screen size SCR.setSize(1280,720)--Initialize Screen size
--Delete all naked files (from too old version) --Delete all naked files (from too old version)
FILE.clear("") FILE.clear('')
--Create directories --Create directories
for _,v in next,{"conf","record","replay","cache","lib"}do for _,v in next,{'conf','record','replay','cache','lib'}do
local info=fs.getInfo(v) local info=fs.getInfo(v)
if not info then if not info then
fs.createDirectory(v) fs.createDirectory(v)
@@ -57,30 +57,30 @@ end
--Load shader files from SOURCE ONLY --Load shader files from SOURCE ONLY
SHADER={} SHADER={}
for _,v in next,fs.getDirectoryItems("parts/shaders")do for _,v in next,fs.getDirectoryItems('parts/shaders')do
if fs.getRealDirectory("parts/shaders/"..v)~=SAVEDIR then if fs.getRealDirectory('parts/shaders/'..v)~=SAVEDIR then
local name=v:sub(1,-6) local name=v:sub(1,-6)
SHADER[name]=love.graphics.newShader("parts/shaders/"..name..".glsl") SHADER[name]=love.graphics.newShader('parts/shaders/'..name..'.glsl')
end end
end end
require"parts.list" require'parts.list'
require"parts.globalTables" require'parts.globalTables'
require"parts.gametoolfunc" require'parts.gametoolfunc'
FREEROW= require"parts.freeRow" FREEROW= require'parts.freeRow'
DATA= require"parts.data" DATA= require'parts.data'
TEXTURE= require"parts.texture" TEXTURE= require'parts.texture'
SKIN= require"parts.skin" SKIN= require'parts.skin'
USERS= require"parts.users" USERS= require'parts.users'
NET= require"parts.net" NET= require'parts.net'
VK= require"parts.virtualKey" VK= require'parts.virtualKey'
AIFUNC= require"parts.ai" AIFUNC= require'parts.ai'
AIBUILDER= require"parts.AITemplate" AIBUILDER= require'parts.AITemplate'
PLY= require"parts.player" PLY= require'parts.player'
netPLY= require"parts.netPlayer" netPLY= require'parts.netPlayer'
MODES= require"parts.modes" MODES= require'parts.modes'
--Initialize field[1] --Initialize field[1]
FIELD[1]=DATA.newBoard() FIELD[1]=DATA.newBoard()
@@ -96,69 +96,69 @@ if SETTING.fullscreen then love.window.setFullscreen(true)end
--Initialize image libs --Initialize image libs
IMG.init{ IMG.init{
lock="mess/lock.png", lock='mess/lock.png',
dialCircle="mess/dialCircle.png", dialCircle='mess/dialCircle.png',
dialNeedle="mess/dialNeedle.png", dialNeedle='mess/dialNeedle.png',
lifeIcon="mess/life.png", lifeIcon='mess/life.png',
badgeIcon="mess/badge.png", badgeIcon='mess/badge.png',
ctrlSpeedLimit="mess/ctrlSpeedLimit.png", ctrlSpeedLimit='mess/ctrlSpeedLimit.png',
speedLimit="mess/speedLimit.png",--Not used, for future C2-mode speedLimit='mess/speedLimit.png',--Not used, for future C2-mode
pay1="mess/pay1.png", pay1='mess/pay1.png',
pay2="mess/pay2.png", pay2='mess/pay2.png',
nakiCH="characters/nakiharu.png", nakiCH='characters/nakiharu.png',
miyaCH="characters/miya.png", miyaCH='characters/miya.png',
miyaF1="characters/miya_f1.png", miyaF1='characters/miya_f1.png',
miyaF2="characters/miya_f2.png", miyaF2='characters/miya_f2.png',
miyaF3="characters/miya_f3.png", miyaF3='characters/miya_f3.png',
miyaF4="characters/miya_f4.png", miyaF4='characters/miya_f4.png',
electric="characters/electric.png", electric='characters/electric.png',
hbm="characters/hbm.png", hbm='characters/hbm.png',
lanterns={ lanterns={
"lanterns/1.png", 'lanterns/1.png',
"lanterns/2.png", 'lanterns/2.png',
"lanterns/3.png", 'lanterns/3.png',
"lanterns/4.png", 'lanterns/4.png',
"lanterns/5.png", 'lanterns/5.png',
"lanterns/6.png", 'lanterns/6.png',
}, },
} }
SKIN.init{ SKIN.init{
"crystal_scf", 'crystal_scf',
"matte_mrz", 'matte_mrz',
"contrast_mrz", 'contrast_mrz',
"polkadots_scf", 'polkadots_scf',
"toy_scf", 'toy_scf',
"smooth_mrz", 'smooth_mrz',
"simple_scf", 'simple_scf',
"glass_scf", 'glass_scf',
"penta_scf", 'penta_scf',
"bubble_scf", 'bubble_scf',
"minoes_scf", 'minoes_scf',
"pure_mrz", 'pure_mrz',
"bright_scf", 'bright_scf',
"glow_mrz", 'glow_mrz',
"plastic_mrz", 'plastic_mrz',
"paper_mrz", 'paper_mrz',
"yinyang_scf", 'yinyang_scf',
"cartooncup_earety", 'cartooncup_earety',
"jelly_miya", 'jelly_miya',
"brick_notypey", 'brick_notypey',
"gem_notypey", 'gem_notypey',
"classic", 'classic',
"ball_shaw", 'ball_shaw',
"retro_notypey", 'retro_notypey',
"textbone_mrz", 'textbone_mrz',
"coloredbone_mrz", 'coloredbone_mrz',
"wtf", 'wtf',
} }
--Initialize sound libs --Initialize sound libs
SFX.init((function() SFX.init((function()
local L={} local L={}
for _,v in next,fs.getDirectoryItems("media/SFX")do for _,v in next,fs.getDirectoryItems('media/SFX')do
if fs.getRealDirectory("media/SFX/"..v)~=SAVEDIR then if fs.getRealDirectory('media/SFX/'..v)~=SAVEDIR then
table.insert(L,v:sub(1,-5)) table.insert(L,v:sub(1,-5))
else else
MES.new('warn',"Dangerous file : %SAVE%/media/SFX/"..v) MES.new('warn',"Dangerous file : %SAVE%/media/SFX/"..v)
@@ -168,8 +168,8 @@ SFX.init((function()
end)()) end)())
BGM.init((function() BGM.init((function()
local L={} local L={}
for _,v in next,fs.getDirectoryItems("media/BGM")do for _,v in next,fs.getDirectoryItems('media/BGM')do
if fs.getRealDirectory("media/BGM/"..v)~=SAVEDIR then if fs.getRealDirectory('media/BGM/'..v)~=SAVEDIR then
table.insert(L,v:sub(1,-5)) table.insert(L,v:sub(1,-5))
else else
MES.new('warn',"Dangerous file : %SAVE%/media/BGM/"..v) MES.new('warn',"Dangerous file : %SAVE%/media/BGM/"..v)
@@ -178,26 +178,26 @@ BGM.init((function()
return L return L
end)()) end)())
VOC.init{ VOC.init{
"zspin","sspin","lspin","jspin","tspin","ospin","ispin", 'zspin','sspin','lspin','jspin','tspin','ospin','ispin',
"single","double","triple","techrash", 'single','double','triple','techrash',
"mini","b2b","b3b", 'mini','b2b','b3b',
"perfect_clear","half_clear", 'perfect_clear','half_clear',
"win","lose","bye", 'win','lose','bye',
"test","happy","doubt","sad","egg", 'test','happy','doubt','sad','egg',
"welcome_voc", 'welcome_voc',
} }
--Initialize language lib --Initialize language lib
LANG.init( LANG.init(
{ {
require"parts.language.lang_zh", require'parts.language.lang_zh',
require"parts.language.lang_zh2", require'parts.language.lang_zh2',
require"parts.language.lang_yygq", require'parts.language.lang_yygq',
require"parts.language.lang_en", require'parts.language.lang_en',
require"parts.language.lang_fr", require'parts.language.lang_fr',
require"parts.language.lang_es", require'parts.language.lang_es',
require"parts.language.lang_pt", require'parts.language.lang_pt',
require"parts.language.lang_symbol", require'parts.language.lang_symbol',
--1. Add language file to LANG folder; --1. Add language file to LANG folder;
--2. Require it; --2. Require it;
--3. Add a button in parts/scenes/setting_lang.lua; --3. Add a button in parts/scenes/setting_lang.lua;
@@ -213,26 +213,26 @@ LANG.init(
} }
) )
--Load background files from SOURCE ONLY --Load background files from SOURCE ONLY
for _,v in next,fs.getDirectoryItems("parts/backgrounds")do for _,v in next,fs.getDirectoryItems('parts/backgrounds')do
if fs.getRealDirectory("parts/backgrounds/"..v)~=SAVEDIR then if fs.getRealDirectory('parts/backgrounds/'..v)~=SAVEDIR then
if v:sub(-3)=="lua"then if v:sub(-3)=='lua'then
local name=v:sub(1,-5) local name=v:sub(1,-5)
BG.add(name,require("parts.backgrounds."..name)) BG.add(name,require('parts.backgrounds.'..name))
end end
end end
end end
--Load scene files from SOURCE ONLY --Load scene files from SOURCE ONLY
for _,v in next,fs.getDirectoryItems("parts/scenes")do for _,v in next,fs.getDirectoryItems('parts/scenes')do
if fs.getRealDirectory("parts/scenes/"..v)~=SAVEDIR then if fs.getRealDirectory('parts/scenes/'..v)~=SAVEDIR then
local sceneName=v:sub(1,-5) local sceneName=v:sub(1,-5)
SCN.add(sceneName,require("parts.scenes."..sceneName)) SCN.add(sceneName,require('parts.scenes.'..sceneName))
LANG.addScene(sceneName) LANG.addScene(sceneName)
end end
end end
--Load mode files --Load mode files
for i=1,#MODES do for i=1,#MODES do
local m=MODES[i]--Mode template local m=MODES[i]--Mode template
local M=require("parts.modes."..m.name)--Mode file local M=require('parts.modes.'..m.name)--Mode file
for k,v in next,m do M[k]=v end for k,v in next,m do M[k]=v end
MODES[m.name],MODES[i]=M MODES[m.name],MODES[i]=M
end end
@@ -246,7 +246,7 @@ do
needSave=true needSave=true
end end
if STAT.version<1302 then if STAT.version<1302 then
FILE.clear_s("") FILE.clear_s('')
end end
if STAT.version<1405 then if STAT.version<1405 then
fs.remove('conf/user') fs.remove('conf/user')
@@ -282,14 +282,14 @@ do
RANKS[v]=RANKS[k] RANKS[v]=RANKS[k]
RANKS[k]=nil RANKS[k]=nil
end end
k="record/"..k k='record/'..k
if fs.getInfo(k..".dat")then if fs.getInfo(k..'.dat')then
fs.write("record/"..v..".rec",fs.read(k..".dat")) fs.write('record/'..v..'.rec',fs.read(k..'.dat'))
fs.remove(k..".dat") fs.remove(k..'.dat')
end end
if fs.getInfo(k..".rec")then if fs.getInfo(k..'.rec')then
fs.write("record/"..v..".rec",fs.read(k..".rec")) fs.write('record/'..v..'.rec',fs.read(k..'.rec'))
fs.remove(k..".rec") fs.remove(k..'.rec')
end end
end end
if not RANKS.sprint_10l then if not RANKS.sprint_10l then
@@ -309,7 +309,7 @@ end
LANG.set(SETTING.lang) LANG.set(SETTING.lang)
VK.setShape(SETTING.VKSkin) VK.setShape(SETTING.VKSkin)
--Load replays --Load replays
for _,fileName in next,fs.getDirectoryItems("replay")do for _,fileName in next,fs.getDirectoryItems('replay')do
if fileName:sub(12,12):match("[a-zA-Z]")then if fileName:sub(12,12):match("[a-zA-Z]")then
local date,mode,version,player,seed,setting,mod local date,mode,version,player,seed,setting,mod
local fileData=fs.read('replay/'..fileName) local fileData=fs.read('replay/'..fileName)