Zframework finished

This commit is contained in:
MrZ_26
2020-07-08 20:26:28 +08:00
parent cdd5194108
commit a3302ab2bc
47 changed files with 308 additions and 275 deletions

65
Zframework/task.lua Normal file
View File

@@ -0,0 +1,65 @@
local rem=table.remove
local tasks={}
local TASK={}
function TASK.getCount()
return #tasks
end
function TASK.update()
for i=#tasks,1,-1 do
local T=tasks[i]
if T.code(T.data)then
rem(tasks,i)
end
end
end
function TASK.new(code,data)
tasks[#tasks+1]={
code=code,
data=data,
}
end
function TASK.changeCode(c1,c2)
for i=#tasks,1,-1 do
if tasks[i].code==c1 then
tasks[i].code=c2
end
end
end
function TASK.removeTask_code(code)
for i=#tasks,1,-1 do
if tasks[i].code==code then
rem(tasks,i)
end
end
end
function TASK.removeTask_data(data)
for i=#tasks,1,-1 do
if tasks[i].data==data then
rem(tasks,i)
end
end
end
function TASK.clear(opt)
if opt=="all"then
local i=#tasks
while i>0 do
tasks[i]=nil
i=i-1
end
elseif opt=="play"then
for i=#tasks,1,-1 do
if tasks[i].P then
rem(tasks,i)
end
end
else--Player table
for i=#tasks,1,-1 do
if tasks[i].P==opt then
rem(tasks,i)
end
end
end
end
return TASK