diff --git a/Zframework/init.lua b/Zframework/init.lua index 3ad40a70..743bb6dc 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -532,6 +532,13 @@ function love.run() _.draw(_.time) end + --Draw network working + if TASK.netTaskCount>0 then + setFont(30) + gc.setColor(color.rainbow(Timer()*5)) + gc.print("E",1250,0,.26+.355*math.sin(Timer()*6.26)) + end + --Draw FPS gc.setColor(1,1,1) setFont(15) diff --git a/Zframework/task.lua b/Zframework/task.lua index b94f7918..92eee54a 100644 --- a/Zframework/task.lua +++ b/Zframework/task.lua @@ -1,7 +1,9 @@ local rem=table.remove local tasks={} -local TASK={} +local TASK={ + netTaskCount=0, +} function TASK.getCount() return #tasks end @@ -9,6 +11,9 @@ function TASK.update() for i=#tasks,1,-1 do local T=tasks[i] if T.code(T.data)then + if T.data.net then + TASK.netTaskCount=TASK.netTaskCount-1 + end rem(tasks,i) end end diff --git a/Zframework/toolfunc.lua b/Zframework/toolfunc.lua index fd04a55a..e14fdce7 100644 --- a/Zframework/toolfunc.lua +++ b/Zframework/toolfunc.lua @@ -164,24 +164,23 @@ do--dumpTable end do--httpRequest client=LOADLIB("NETlib") - if client then - function httpRequest(tick,url,method,header,body) - local task,err=client.httpraw{ - url=url, - method=method or"GET", - header=header, - body=body, - } - if task then - TASK.new(tick,{task=task,time=0}) - else - LOG.print("NETlib error: "..err,"warn") - end - end - else - function httpRequest(...) - LOG.print("[NO NETlib]",5,color.yellow) + httpRequest= + client and function(tick,api,method,header,body) + local task,err=client.httpraw{ + url="http://47.103.200.40/"..api, + method=method or"GET", + header=header, + body=body, + } + if task then + TASK.new(tick,{task=task,time=0,net=true}) + else + LOG.print("NETlib error: "..err,"warn") end + TASK.netTaskCount=TASK.netTaskCount+1 + end or + function() + LOG.print("[NO NETlib]",5,color.yellow) end end do--json diff --git a/parts/scenes.lua b/parts/scenes.lua index 87efa7d2..c697deef 100644 --- a/parts/scenes.lua +++ b/parts/scenes.lua @@ -232,7 +232,7 @@ do--load -------------------------- SFX.play("welcome_sfx") VOC.play("welcome_voc") - httpRequest(TICK.httpREQ_launch,"http://47.103.200.40/api/game") + httpRequest(TICK.httpREQ_launch,"api/game") else S.cur=S.cur+1 S.tar=S.cur