整理代码
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
local gc=love.graphics
|
local gc=love.graphics
|
||||||
local rnd=math.random
|
local rnd,rem=math.random,table.remove
|
||||||
local rem=table.remove
|
|
||||||
local setFont,mStr=setFont,mStr
|
local setFont,mStr=setFont,mStr
|
||||||
|
|
||||||
local texts={}
|
local texts={}
|
||||||
@@ -74,18 +73,6 @@ local TEXT={}
|
|||||||
function TEXT.clear()
|
function TEXT.clear()
|
||||||
texts={}
|
texts={}
|
||||||
end
|
end
|
||||||
function TEXT.getText(text,x,y,font,style,spd,stop)--Another version of TEXT()
|
|
||||||
return{
|
|
||||||
c=0,
|
|
||||||
text=text,
|
|
||||||
x=x or 0,
|
|
||||||
y=y or 0,
|
|
||||||
font=font or 40,
|
|
||||||
spd=(spd or 1)/60,
|
|
||||||
stop=stop,
|
|
||||||
draw=textFX[style]or assert(false,"unavailable type:"..style),
|
|
||||||
}
|
|
||||||
end
|
|
||||||
function TEXT.show(text,x,y,font,style,spd,stop)
|
function TEXT.show(text,x,y,font,style,spd,stop)
|
||||||
texts[#texts+1]={
|
texts[#texts+1]={
|
||||||
c=0, --Timer
|
c=0, --Timer
|
||||||
@@ -95,7 +82,19 @@ function TEXT.show(text,x,y,font,style,spd,stop)
|
|||||||
font=font or 40, --Font
|
font=font or 40, --Font
|
||||||
spd=(spd or 1)/60, --Timing speed(1=last 1 sec)
|
spd=(spd or 1)/60, --Timing speed(1=last 1 sec)
|
||||||
stop=stop, --Stop time(sustained text)
|
stop=stop, --Stop time(sustained text)
|
||||||
draw=textFX[style]or assert(false,"unavailable type:"..style), --Draw method
|
draw=textFX[style]or error("unavailable type:"..style), --Draw method
|
||||||
|
}
|
||||||
|
end
|
||||||
|
function TEXT.getText(text,x,y,font,style,spd,stop)--Another version of TEXT.show(), but only return text object, need manual management
|
||||||
|
return{
|
||||||
|
c=0,
|
||||||
|
text=text,
|
||||||
|
x=x or 0,
|
||||||
|
y=y or 0,
|
||||||
|
font=font or 40,
|
||||||
|
spd=(spd or 1)/60,
|
||||||
|
stop=stop,
|
||||||
|
draw=textFX[style]or error("unavailable type:"..style),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
function TEXT.update(list)
|
function TEXT.update(list)
|
||||||
|
|||||||
@@ -152,14 +152,14 @@ do--dumpTable
|
|||||||
k=k.."="
|
k=k.."="
|
||||||
end
|
end
|
||||||
elseif T=="boolean"then k="["..k.."]="
|
elseif T=="boolean"then k="["..k.."]="
|
||||||
else assert(false,"Error key type!")
|
else error("Error key type!")
|
||||||
end
|
end
|
||||||
T=type(v)
|
T=type(v)
|
||||||
if T=="number"then v=tostring(v)
|
if T=="number"then v=tostring(v)
|
||||||
elseif T=="string"then v="\""..v.."\""
|
elseif T=="string"then v="\""..v.."\""
|
||||||
elseif T=="table"then v=dumpTable(v,t+1)
|
elseif T=="table"then v=dumpTable(v,t+1)
|
||||||
elseif T=="boolean"then v=tostring(v)
|
elseif T=="boolean"then v=tostring(v)
|
||||||
else assert(false,"Error data type!")
|
else error("Error data type!")
|
||||||
end
|
end
|
||||||
s=s..tabs[t]..k..v..",\n"
|
s=s..tabs[t]..k..v..",\n"
|
||||||
end
|
end
|
||||||
@@ -167,21 +167,21 @@ do--dumpTable
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
do--json
|
do--json
|
||||||
--
|
|
||||||
-- json.lua
|
-- json.lua
|
||||||
--
|
|
||||||
-- Copyright (c) 2020 rxi
|
-- Copyright (c) 2020 rxi
|
||||||
--
|
|
||||||
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
|
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
-- this software and associated documentation files (the "Software"), to deal in
|
-- this software and associated documentation files (the "Software"), to deal in
|
||||||
-- the Software without restriction, including without limitation the rights to
|
-- the Software without restriction, including without limitation the rights to
|
||||||
-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
-- of the Software, and to permit persons to whom the Software is furnished to do
|
-- of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
-- so, subject to the following conditions:
|
-- so, subject to the following conditions:
|
||||||
--
|
|
||||||
-- The above copyright notice and this permission notice shall be included in all
|
-- The above copyright notice and this permission notice shall be included in all
|
||||||
-- copies or substantial portions of the Software.
|
-- copies or substantial portions of the Software.
|
||||||
--
|
|
||||||
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
@@ -189,7 +189,7 @@ do--json
|
|||||||
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
-- SOFTWARE.
|
-- SOFTWARE.
|
||||||
--
|
|
||||||
|
|
||||||
local char=string.char
|
local char=string.char
|
||||||
json = {}
|
json = {}
|
||||||
@@ -588,7 +588,7 @@ do--httpRequest & wsConnect
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
local function noNetLib()
|
local function noNetLib()
|
||||||
LOG.print("[NO NETlib]",5,COLOR.yellow)
|
LOG.print("[NO NETlib for "..SYSTEM.."]",5,COLOR.yellow)
|
||||||
end
|
end
|
||||||
httpRequest=noNetLib
|
httpRequest=noNetLib
|
||||||
wsConnect=noNetLib
|
wsConnect=noNetLib
|
||||||
|
|||||||
Reference in New Issue
Block a user