整理全局函数名以及库的require方法
This commit is contained in:
@@ -7,7 +7,7 @@ local tabs={
|
||||
"\t\t\t\t",
|
||||
"\t\t\t\t\t",
|
||||
}
|
||||
function dumpTable(L,t)
|
||||
return function(L,t)
|
||||
local s
|
||||
if t then
|
||||
s="{\n"
|
||||
@@ -40,7 +40,7 @@ function dumpTable(L,t)
|
||||
T=type(v)
|
||||
if T=="number"then v=tostring(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)
|
||||
else error("Error data type!")
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ function FILE.load(name)
|
||||
return s()
|
||||
end
|
||||
else
|
||||
local res=json.decode(s)
|
||||
local res=JSON.decode(s)
|
||||
if res then
|
||||
return res
|
||||
end
|
||||
@@ -26,13 +26,13 @@ function FILE.save(data,name,mode)
|
||||
if not mode then mode=""end
|
||||
name=name
|
||||
if mode:find("l")then
|
||||
data=dumpTable(data)
|
||||
data=DUMPTABLE(data)
|
||||
if not data then
|
||||
LOG.print(name.." "..text.saveError.."dump error","error")
|
||||
return
|
||||
end
|
||||
else
|
||||
data=json.encode(data)
|
||||
data=JSON.encode(data)
|
||||
if not data then
|
||||
LOG.print(name.." "..text.saveError.."json error","error")
|
||||
return
|
||||
|
||||
@@ -4,20 +4,20 @@ SCN= require"Zframework/scene"
|
||||
LOG= require"Zframework/log"
|
||||
WS= require"Zframework/websocket"
|
||||
|
||||
loadLib=require"Zframework/loadLib"
|
||||
require"Zframework/wheelScroll"
|
||||
LOADLIB=require"Zframework/loadLib"
|
||||
WHEELMOV=require"Zframework/wheelScroll"
|
||||
|
||||
require"Zframework/setFont"
|
||||
require"Zframework/mDraw"
|
||||
|
||||
require"Zframework/json"
|
||||
require"Zframework/dumpTable"
|
||||
require"Zframework/urlEncode"
|
||||
JSON=require"Zframework/json"
|
||||
DUMPTABLE=require"Zframework/dumpTable"
|
||||
URLENCODE=require"Zframework/urlEncode"
|
||||
|
||||
-- require"Zframework/upperChar"
|
||||
-- UPPERCHAR=require"Zframework/upperChar"
|
||||
require"Zframework/copyTable"
|
||||
require"Zframework/splitStr"
|
||||
require"Zframework/toTime"
|
||||
SPLITSTR=require"Zframework/splitStr"
|
||||
TIMESTR=require"Zframework/timeStr"
|
||||
|
||||
VIB= require"Zframework/vibrate"
|
||||
SFX= require"Zframework/sfx"
|
||||
|
||||
@@ -20,9 +20,10 @@
|
||||
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
-- SOFTWARE.
|
||||
|
||||
-- Editted by MrZ
|
||||
|
||||
local ins,char=table.insert,string.char
|
||||
json = {}
|
||||
local json = {}
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- Encode
|
||||
@@ -350,4 +351,5 @@ function json.decode(str)
|
||||
elseif LOG then
|
||||
LOG.print(text.jsonError..": "..(b or"uknErr"),"warn")
|
||||
end
|
||||
end
|
||||
end
|
||||
return json
|
||||
@@ -1,10 +1,11 @@
|
||||
local gc=love.graphics
|
||||
local printf=love.graphics.printf
|
||||
local draw=love.graphics.draw
|
||||
function mStr(s,x,y)
|
||||
gc.printf(s,x-626,y,1252,"center")
|
||||
printf(s,x-626,y,1252,"center")
|
||||
end
|
||||
function mText(s,x,y)
|
||||
gc.draw(s,x-s:getWidth()*.5,y)
|
||||
draw(s,x-s:getWidth()*.5,y)
|
||||
end
|
||||
function mDraw(s,x,y,a,k)
|
||||
gc.draw(s,x,y,a,k,nil,s:getWidth()*.5,s:getHeight()*.5)
|
||||
draw(s,x,y,a,k,nil,s:getWidth()*.5,s:getHeight()*.5)
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
local find,sub=string.find,string.sub
|
||||
function splitStr(s,sep)
|
||||
return function(s,sep)
|
||||
local L={}
|
||||
local p1,p2=1--start,target
|
||||
while p1<=#s do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local int,format=math.floor,string.format
|
||||
function toTime(s)
|
||||
return function(s)
|
||||
if s<60 then
|
||||
return format("%.3fs",s)
|
||||
elseif s<3600 then
|
||||
@@ -7,6 +7,6 @@ local upperList={
|
||||
[";"]=":",["'"]="\"",
|
||||
[","]="<",["."]=">",["/"]="?",
|
||||
}
|
||||
function upperChar(c)
|
||||
return function(c)
|
||||
return upperList[c]or upper(c)
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
local rshift=bit.rshift
|
||||
local b16={[0]="0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"}
|
||||
function urlEncode(str)
|
||||
return function(str)
|
||||
local out=""
|
||||
for i=1,#str do
|
||||
if str:sub(i,i):match("[a-zA-Z0-9]")then
|
||||
|
||||
@@ -16,7 +16,7 @@ local band,bor,bxor=bit.band,bit.bor,bit.bxor
|
||||
local shl,shr=bit.lshift,bit.rshift
|
||||
|
||||
local SOCK=require"socket".tcp()
|
||||
require"Zframework/json"
|
||||
local JSON=require"Zframework/json"
|
||||
|
||||
local mask_key={1,14,5,14}
|
||||
local function _send(opcode,message)
|
||||
@@ -81,7 +81,7 @@ do--Connect
|
||||
l=SOCK:receive("*l")
|
||||
until l==""
|
||||
l=SOCK:receive("*l")
|
||||
local reason=json.decode(l)if reason then reason=reason.message end
|
||||
local reason=JSON.decode(l)if reason then reason=reason.message end
|
||||
readCHN:push(code.."-"..(reason or l))
|
||||
end
|
||||
else
|
||||
@@ -129,7 +129,7 @@ while true do
|
||||
local code=res:find(" ")
|
||||
code=res:sub(code+1,code+3)
|
||||
local res=res:sub(res:find("\n\n")+1)
|
||||
reason=json.decode(res)if reason then reason=reason.message end
|
||||
reason=JSON.decode(res)if reason then reason=reason.message end
|
||||
readCHN:push(code.."-"..(reason or res))
|
||||
else
|
||||
readCHN:push(string.format("%d-%s",shl(byte(res,1),8)+byte(res,2).."-"..res:sub(3,-3)))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local floatWheel=0
|
||||
function wheelScroll(y)
|
||||
return function(y)
|
||||
if y>0 then
|
||||
if floatWheel<0 then floatWheel=0 end
|
||||
floatWheel=floatWheel+y^1.2
|
||||
|
||||
Reference in New Issue
Block a user