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

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={
none={draw=function()gc_clear(.15,.15,.15)end}
}
local BGlist={"none"}
local BGlist={'none'}
local BG={
cur="none",
default="none",
cur='none',
default='none',
init=false,
resize=false,
update=NULL,

View File

@@ -44,7 +44,7 @@ function BGM.init(list)
end
local function load(skip)
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
Sources[list[i]]=love.audio.newSource(file,'stream')
Sources[list[i]]:setLooping(true)

View File

@@ -57,7 +57,7 @@ end
function FILE.clear(path)
if fs.getRealDirectory(path)~=SAVEDIR or fs.getInfo(path).type~='directory'then return end
for _,name in next,fs.getDirectoryItems(path)do
name=path.."/"..name
name=path..'/'..name
if fs.getRealDirectory(name)==SAVEDIR then
local t=fs.getInfo(name).type
if t=='file'then
@@ -67,9 +67,9 @@ function FILE.clear(path)
end
end
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
name=path.."/"..name
name=path..'/'..name
if fs.getRealDirectory(name)==SAVEDIR then
local t=fs.getInfo(name).type
if t=='file'then

View File

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

View File

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

View File

@@ -26,7 +26,7 @@ function LANG.init(langList,publicText)--Attention, calling this will destory al
end
--Metatable:__call for table:getTip
if type(rawget(L,"getTip"))=='table'then
if type(rawget(L,'getTip'))=='table'then
setmetatable(L.getTip,tipMeta)
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_setColor,gc_draw=gc.setColor,gc.draw
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 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 Lights={}--Lightsource objects
local function move(L,x,y)
L.x,L.y=x,y
@@ -22,8 +22,8 @@ local function drawLight(L)
gc_setCanvas(L.blackCanvas)clear()
gc_setCanvas(L.shadowCanvas)clear()
gc_setCanvas(L.renderCanvas)clear()
lightRenderShader:send("xresolution",s)
shadowMapShader:send("yresolution",s)
lightRenderShader:send('xresolution',s)
shadowMapShader:send('yresolution',s)
--Get up-left of light
local X=L.x-s*.5

View File

@@ -1,21 +1,21 @@
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])
if r1 and r2 then
return r2
else
MES.new('error',"Cannot load "..name..": "..(r2 or r3))
end
elseif SYSTEM=="Android"then
elseif SYSTEM=='Android'then
local fs=love.filesystem
local platform={'arm64-v8a','armeabi-v7a'}
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
local success,mes2=fs.write("lib/"..libName.Android,soFile)
local success,mes2=fs.write('lib/'..libName.Android,soFile)
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
MES.new('check',name.." lib loaded")
break

View File

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

View File

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

View File

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

View File

@@ -2,8 +2,8 @@ local gc=love.graphics
local newFont=gc.setNewFont
local setNewFont=gc.setFont
local fontCache,currentFontSize={}
if love.filesystem.getInfo("font.ttf")then
local fontData=love.filesystem.newFile("font.ttf")
if love.filesystem.getInfo('font.ttf')then
local fontData=love.filesystem.newFile('font.ttf')
function setFont(s)
if s~=currentFontSize 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 function load(skip)
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
Sources[list[i]]={love.audio.newSource(N,'static')}
else

View File

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

View File

@@ -15,9 +15,9 @@ function VOC.init(list)
local count=#list function VOC.getCount()return count end
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
bank[vocName]={love.audio.newSource(fileName,"static")}
bank[vocName]={love.audio.newSource(fileName,'static')}
table.insert(Source[N],vocName)
return true
end
@@ -41,7 +41,7 @@ function VOC.init(list)
Source[list[i]]={}
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 not loadVoiceFile(list[i],list[i])then

View File

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