working on task management

This commit is contained in:
2026-03-15 01:13:00 -07:00
parent 40de9a8d22
commit 0a92890290
91 changed files with 28728 additions and 28727 deletions
File diff suppressed because it is too large Load Diff
+53 -53
View File
@@ -1,53 +1,53 @@
IsEvent=true
event={
Active=true,
CT=false,
tag={},
Events={},
EventTracker={},
Steps={},
setAlarm=function(self,tag,set) event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]]) event:addTracker("_Alarm_"..tag,SetCounter()) end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end event:new("Event_"..fname,condition,also) end,
removeAlarm=function(self,tag) event:destroy("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,var) return event.EventTracker[var] end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroy=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do for d=1,#event.Events do if event.Active==true then loadstring(event.Events[d])() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end event.OnClose() end,
CManager=function() for d=1,#event.Events do if event.Active==true then loadstring(event.Events[d])() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end for d=1,#event.Events do if event.Active==true then loadstring(event.Events[d])() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
createStep=function(self,tag,reset,endc)
if not(endc) then endc=false end
if not(reset) then reset=0 end
temp={Name=tag,pos=1,endAt=reset,active=true,endc=endc,
Step=function(self) if self~=nil then _G.__CStep__=self if self.active==true then loadstring("Step_"..tag.."("..self.pos..",__CStep__)")() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then loadstring("Step_"..self.Name.."_End(__CStep__)")() end end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
table.insert(event.Steps,temp) return temp end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
}
IsEvent=true
event={
Active=true,
CT=false,
tag={},
Events={},
EventTracker={},
Steps={},
setAlarm=function(self,tag,set) event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]]) event:addTracker("_Alarm_"..tag,SetCounter()) end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end event:new("Event_"..fname,condition,also) end,
removeAlarm=function(self,tag) event:destroy("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,var) return event.EventTracker[var] end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroy=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do for d=1,#event.Events do if event.Active==true then loadstring(event.Events[d])() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end event.OnClose() end,
CManager=function() for d=1,#event.Events do if event.Active==true then loadstring(event.Events[d])() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end for d=1,#event.Events do if event.Active==true then loadstring(event.Events[d])() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
createStep=function(self,tag,reset,endc)
if not(endc) then endc=false end
if not(reset) then reset=0 end
temp={Name=tag,pos=1,endAt=reset,active=true,endc=endc,
Step=function(self) if self~=nil then _G.__CStep__=self if self.active==true then loadstring("Step_"..tag.."("..self.pos..",__CStep__)")() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then loadstring("Step_"..self.Name.."_End(__CStep__)")() end end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
table.insert(event.Steps,temp) return temp end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
}
+55 -55
View File
@@ -1,55 +1,55 @@
IsEvent=true
event={
Active=true,
CT=false,
tag={},
Events={},
EventTracker={},
Steps={},
--addAlarm=function(self,tag) end,
setAlarm=function(self,tag,set) event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]]) event:addTracker("_Alarm_"..tag,SetCounter()) assert(loadstring("if Alarm_"..tag.."==nil then function Alarm_"..tag.."() print('No function \"Alarm_"..tag.."()\" exists make sure you created it') end end"))() end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end a=string.find(fname,"(",1,true) tempstr=string.sub(fname,1,a-1) event:new("Event_"..fname,condition,also) assert(loadstring("if Event_"..tempstr.."==nil then function Event_"..tempstr.."() print('No function \"Event_"..tempstr.."()\" exists make sure you created it') end end"))() end,
removeAlarm=function(self,tag) event:destroy("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,var) return event.EventTracker[var] end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroy=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end event.OnClose() end,
CManager=function() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
RManager=function() event.OnCreate() while event.Active==true do event.OnUpdate() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end end event.OnClose() end,
createStep=function(self,tag,reset,endc)
if not(endc) then endc=false end
if not(reset) then reset=0 end
temp={Name=tag,pos=1,endAt=reset,active=true,endc=endc,
Step=function(self) if self~=nil then _G.__CStep__=self if self.active==true then assert(loadstring("Step_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CStep__)"))() end end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
table.insert(event.Steps,temp) return temp end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
}
IsEvent=true
event={
Active=true,
CT=false,
tag={},
Events={},
EventTracker={},
Steps={},
--addAlarm=function(self,tag) end,
setAlarm=function(self,tag,set) event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]]) event:addTracker("_Alarm_"..tag,SetCounter()) assert(loadstring("if Alarm_"..tag.."==nil then function Alarm_"..tag.."() print('No function \"Alarm_"..tag.."()\" exists make sure you created it') end end"))() end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end a=string.find(fname,"(",1,true) tempstr=string.sub(fname,1,a-1) event:new("Event_"..fname,condition,also) assert(loadstring("if Event_"..tempstr.."==nil then function Event_"..tempstr.."() print('No function \"Event_"..tempstr.."()\" exists make sure you created it') end end"))() end,
removeAlarm=function(self,tag) event:destroy("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,var) return event.EventTracker[var] end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroy=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end event.OnClose() end,
CManager=function() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
RManager=function() event.OnCreate() while event.Active==true do event.OnUpdate() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end end event.OnClose() end,
createStep=function(self,tag,reset,endc)
if not(endc) then endc=false end
if not(reset) then reset=0 end
temp={Name=tag,pos=1,endAt=reset,active=true,endc=endc,
Step=function(self) if self~=nil then _G.__CStep__=self if self.active==true then assert(loadstring("Step_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CStep__)"))() end end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
table.insert(event.Steps,temp) return temp end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
}
+55 -55
View File
@@ -1,55 +1,55 @@
IsEvent=true
event={
Active=true,
CT=false,
tag={},
Events={},
EventTracker={},
Steps={},
--addAlarm=function(self,tag) end,
setAlarm=function(self,tag,set) event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]]) event:addTracker("_Alarm_"..tag,SetCounter()) assert(loadstring("if Alarm_"..tag.."==nil then function Alarm_"..tag.."() print('No function \"Alarm_"..tag.."()\" exists make sure you created it') end end"))() end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end a=string.find(fname,"(",1,true) tempstr=string.sub(fname,1,a-1) event:new("Event_"..fname,condition,also) assert(loadstring("if Event_"..tempstr.."==nil then function Event_"..tempstr.."() print('No function \"Event_"..tempstr.."()\" exists make sure you created it') end end"))() end,
removeAlarm=function(self,tag) event:destroy("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,var) return event.EventTracker[var] end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroy=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end event.OnClose() end,
CManager=function() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
RManager=function() event.OnCreate() while event.Active==true do event.OnUpdate() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end end event.OnClose() end,
createStep=function(self,tag,reset,endc)
if not(endc) then endc=false end
if not(reset) then reset=0 end
temp={Name=tag,pos=1,endAt=reset,active=true,endc=endc,
Step=function(self) if self~=nil then _G.__CStep__=self if self.active==true then assert(loadstring("Step_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CStep__)"))() end end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
table.insert(event.Steps,temp) return temp end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
}
IsEvent=true
event={
Active=true,
CT=false,
tag={},
Events={},
EventTracker={},
Steps={},
--addAlarm=function(self,tag) end,
setAlarm=function(self,tag,set) event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]]) event:addTracker("_Alarm_"..tag,SetCounter()) assert(loadstring("if Alarm_"..tag.."==nil then function Alarm_"..tag.."() print('No function \"Alarm_"..tag.."()\" exists make sure you created it') end end"))() end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end a=string.find(fname,"(",1,true) tempstr=string.sub(fname,1,a-1) event:new("Event_"..fname,condition,also) assert(loadstring("if Event_"..tempstr.."==nil then function Event_"..tempstr.."() print('No function \"Event_"..tempstr.."()\" exists make sure you created it') end end"))() end,
removeAlarm=function(self,tag) event:destroy("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,var) return event.EventTracker[var] end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroy=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end event.OnClose() end,
CManager=function() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
RManager=function() event.OnCreate() while event.Active==true do event.OnUpdate() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end end event.OnClose() end,
createStep=function(self,tag,reset,endc)
if not(endc) then endc=false end
if not(reset) then reset=0 end
temp={Name=tag,pos=1,endAt=reset,active=true,endc=endc,
Step=function(self) if self~=nil then _G.__CStep__=self if self.active==true then assert(loadstring("Step_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CStep__)"))() end end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
table.insert(event.Steps,temp) return temp end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
}
+98 -98
View File
@@ -1,98 +1,98 @@
require("Data/BasicCommands")
IsEvent=true
event={
Active=true,
CT=false,
tag={},
Events={},
EventTracker={},
Steps={},
TSteps={},
LoadOrder="/E/S/U",-- types = ESU,EUS,USE,UES,SEU,SUE
setLoadOrder=function(self,str) event.LoadOrder=string.upper(str) end,
DO_Order=function() LoadOrder=event.LoadOrder LoadOrder=LoadOrder:gsub("/E", "event.RUN_EVENTS(); ") LoadOrder=LoadOrder:gsub("/S", "event.RUN_STEPS(); ") LoadOrder=LoadOrder:gsub("/U", "event.RUN_UPDATES(); ") assert(loadstring(LoadOrder))() end,
RUN_EVENTS=function() for d=1,#event.Events do assert(loadstring(event.Events[d]))() end end,
RUN_STEPS=function() for s_g=1,#event.Steps do event.Steps[s_g]:Step() end end,
RUN_UPDATES=function() event.OnUpdate() end,
setAlarm=function(self,tag,set) event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]]) event:addTracker("_Alarm_"..tag,SetCounter()) assert(loadstring("if Alarm_"..tag.."==nil then function Alarm_"..tag.."() print('No function \"Alarm_"..tag.."()\" exists make sure you created it') end end"))() end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end a=string.find(fname,"(",1,true) tempstr=string.sub(fname,1,a-1) event:new("Event_"..fname,condition,also) assert(loadstring("if Event_"..tempstr.."==nil then function Event_"..tempstr.."() print('No function \"Event_"..tempstr.."()\" exists make sure you created it') end end"))() end,
removeAlarm=function(self,tag) event:destroy("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,varname) return event.EventTracker[varname] end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroy=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do event.DO_Order() end event.OnClose() end,
--Manager=function() event.OnCreate() while event.Active==true do for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end event.OnClose() end,
CManager=function() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
createStep=function(self,tag,reset,skip,endc)
if not(endc) then endc=false end
temp=
{
Name=tag,
pos=1,
endAt=reset or math.huge,
active=true,
endc=endc,
skip=skip or 0,
spos=0,
Step=function(self) if self~=nil then if self.spos==0 then _G.__CStep__=self if self.active==true then assert(loadstring("Step_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CStep__)"))() end end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
FStep=function(self) if self~=nil then if self.spos==0 then _G.__CStep__=self assert(loadstring("Step_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CStep__)"))() end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
table.insert(event.Steps,temp) return temp end,
createTStep=function(self,tag,reset,timer,endc)
if not(endc) then endc=false end
timer=timer or 1
temp=
{
Name=tag,
pos=1,
endAt=reset or math.huge,
active=true,
endc=endc,
skip= 0,
spos=0,
Step=function(self) if self~=nil then if self.spos==0 then _G.__CStep__=self if self.active==true then assert(loadstring("TStep_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("TStep_"..self.Name.."_End(__CStep__)"))() end end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
FStep=function(self) if self~=nil then if self.spos==0 then _G.__CStep__=self assert(loadstring("TStep_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("TStep_"..self.Name.."_End(__CStep__)"))() end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
event:setAlarm("TStep_"..tag,timer)
event:addTracker("_TStep_"..tag,temp)
table.insert(event.TSteps,temp)
assert(loadstring("function Alarm_TStep_"..tag.."(alarm) event:getTracker(\"_\"..alarm):Step() event:setAlarm(alarm,"..timer..") end"))()
return temp end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
}
require("Data/BasicCommands")
IsEvent=true
event={
Active=true,
CT=false,
tag={},
Events={},
EventTracker={},
Steps={},
TSteps={},
LoadOrder="/E/S/U",-- types = ESU,EUS,USE,UES,SEU,SUE
setLoadOrder=function(self,str) event.LoadOrder=string.upper(str) end,
DO_Order=function() LoadOrder=event.LoadOrder LoadOrder=LoadOrder:gsub("/E", "event.RUN_EVENTS(); ") LoadOrder=LoadOrder:gsub("/S", "event.RUN_STEPS(); ") LoadOrder=LoadOrder:gsub("/U", "event.RUN_UPDATES(); ") assert(loadstring(LoadOrder))() end,
RUN_EVENTS=function() for d=1,#event.Events do assert(loadstring(event.Events[d]))() end end,
RUN_STEPS=function() for s_g=1,#event.Steps do event.Steps[s_g]:Step() end end,
RUN_UPDATES=function() event.OnUpdate() end,
setAlarm=function(self,tag,set) event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]]) event:addTracker("_Alarm_"..tag,SetCounter()) assert(loadstring("if Alarm_"..tag.."==nil then function Alarm_"..tag.."() print('No function \"Alarm_"..tag.."()\" exists make sure you created it') end end"))() end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end a=string.find(fname,"(",1,true) tempstr=string.sub(fname,1,a-1) event:new("Event_"..fname,condition,also) assert(loadstring("if Event_"..tempstr.."==nil then function Event_"..tempstr.."() print('No function \"Event_"..tempstr.."()\" exists make sure you created it') end end"))() end,
removeAlarm=function(self,tag) event:destroy("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,varname) return event.EventTracker[varname] end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroy=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do event.DO_Order() end event.OnClose() end,
--Manager=function() event.OnCreate() while event.Active==true do for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end event.OnClose() end,
CManager=function() for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end for d=1,#event.Events do if event.Active==true then assert(loadstring(event.Events[d]))() end end for s_g=1,#event.Steps do event.Steps[s_g]:Step() end event.OnUpdate() end,
createStep=function(self,tag,reset,skip,endc)
if not(endc) then endc=false end
temp=
{
Name=tag,
pos=1,
endAt=reset or math.huge,
active=true,
endc=endc,
skip=skip or 0,
spos=0,
Step=function(self) if self~=nil then if self.spos==0 then _G.__CStep__=self if self.active==true then assert(loadstring("Step_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CStep__)"))() end end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
FStep=function(self) if self~=nil then if self.spos==0 then _G.__CStep__=self assert(loadstring("Step_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CStep__)"))() end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
table.insert(event.Steps,temp) return temp end,
createTStep=function(self,tag,reset,timer,endc)
if not(endc) then endc=false end
timer=timer or 1
temp=
{
Name=tag,
pos=1,
endAt=reset or math.huge,
active=true,
endc=endc,
skip= 0,
spos=0,
Step=function(self) if self~=nil then if self.spos==0 then _G.__CStep__=self if self.active==true then assert(loadstring("TStep_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("TStep_"..self.Name.."_End(__CStep__)"))() end end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
FStep=function(self) if self~=nil then if self.spos==0 then _G.__CStep__=self assert(loadstring("TStep_"..tag.."("..self.pos..",__CStep__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("TStep_"..self.Name.."_End(__CStep__)"))() end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
event:setAlarm("TStep_"..tag,timer)
event:addTracker("_TStep_"..tag,temp)
table.insert(event.TSteps,temp)
assert(loadstring("function Alarm_TStep_"..tag.."(alarm) event:getTracker(\"_\"..alarm):Step() event:setAlarm(alarm,"..timer..") end"))()
return temp end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
}
+203 -203
View File
@@ -1,203 +1,203 @@
function dump(t,indent)
local names = {}
if not indent then indent = "" end
for n,g in pairs(t) do
table.insert(names,n)
end
table.sort(names)
for i,n in pairs(names) do
local v = t[n]
if type(v) == "table" then
if(v==t) then -- prevent endless loop if table contains reference to itself
print(indent..tostring(n)..": <-")
else
print(indent..tostring(n)..":")
dump(v,indent.." ")
end
else
if type(v) == "function" then
print(indent..tostring(n).."()")
else
print(indent..tostring(n)..": "..tostring(v))
end
end
end
end
function SetCounter()
return os.clock()
end
----------------------------------------------------------------------------------------------------
function GetCounter(count)
if count~=nil then
return os.clock()-count
else
return 0
end
end
----------------------------------------------------------------------------------------------------
clock=os.clock
event={
Active=true,
CT=false,
tag={},
Events={},
Alarms={},
EventTracker={},
Steps={},
TSteps={},
CTask="",
LoadOrder="/E/S/A/U",
UpdateObj=
{
LoadOrder="",
Resume=function(self) event.LoadOrder=self.LoadOrder end,
Pause=function(self) self.LoadOrder=event.LoadOrder event.LoadOrder=event.LoadOrder:gsub("/U", "") end,
},
setLoadOrder=function(self,str) event.LoadOrder=string.upper(str) end,
DO_Order=function() LoadOrder=event.LoadOrder LoadOrder=LoadOrder:gsub("/A", "event.RUN_ALARMS(); ") LoadOrder=LoadOrder:gsub("/E", "event.RUN_EVENTS(); ") LoadOrder=LoadOrder:gsub("/S", "event.RUN_STEPS(); ") LoadOrder=LoadOrder:gsub("/U", "event.RUN_UPDATES(); ") assert(loadstring(LoadOrder))() end,
RUN_EVENTS=function() event.CTask="events" for d=1,#event.Events do assert(loadstring(event.Events[d]))() end end,
RUN_STEPS=function() event.CTask="steps" for s_g=1,#event.Steps do event.Steps[s_g]:Step() end end,
RUN_UPDATES=function() _G.__CAction__=event.UpdateObj event.CTask="updates" event.OnUpdate() end,
RUN_ALARMS=function() for i=1,#event.Alarms do event.Alarms[i]:Tick() end end,
--System Used Functions
Hold=function(self,task) -- as many conditions and times that you want can be used
local action=__CAction__
action:Pause()
if type(task)=="number" then
local func=function() end
local alarm=event:newAlarm(task,func,true)
while alarm.active==true do
event.CManager()
end
alarm:Destroy()
action:Resume()
elseif type(task)=="string" then
assert(loadstring("while not("..task..") do event.CManager() end"))()
action:Resume()
end
end,
newAlarm=function(self,set,func,start)
if not(start) then timer=0 active=false else timer=clock() active=true end
if not(func) then func=(function() end) end
Alarm=
{
active=active,
timer=timer,
set=set or 0,
func=func,
Tick=function(self) _G.__CAction__=self if self.active==true then if clock()-self.timer>=self.set then self:Pause() self:Ring() end end end,
Pause=function(self) self.active=false end,
Set=function(self,amt) self.set=amt self.timer=clock() self:Resume() end,
OnRing=function(self,func) self.func=func end,
Ring=function(self) self:func(self) end,
Reset=function(self) self.timer=clock() self:Resume() end,
Resume=function(self) self.active=true end,
Destroy=function(self) for i=1,#event.Alarms do if tostring(event.Alarms[i])==tostring(self) then table.remove(event.Alarms,i) end end end,
}
table.insert(event.Alarms,Alarm)
return Alarm
end,
setAlarm=function(self,tag,set)
if event:eventExist("Alarm_"..tag.."(\""..tag.."\")")==false then
event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]])
event:addTracker("_Alarm_"..tag,SetCounter())
assert(loadstring("if Alarm_"..tag.."==nil then function Alarm_"..tag.."() print('No function \"Alarm_"..tag.."()\" exists make sure you created it') end end"))()
else
event:addTracker("_Alarm_"..tag,SetCounter())
end
end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end a=string.find(fname,"(",1,true) tempstr=string.sub(fname,1,a-1) event:new("Event_"..fname,condition,also) assert(loadstring("if Event_"..tempstr.."==nil then function Event_"..tempstr.."() print('No function \"Event_"..tempstr.."()\" exists make sure you created it') end end"))() end,
removeAlarm=function(self,tag) event:destroyEvent("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,varname) return event.EventTracker[varname] end,
listTrackers=function(self) return event.EventTracker end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroyEvent=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do event.DO_Order() end event.OnClose() end,
CManager=function() if event.Active==true then event.DO_Order() end end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end if event.Active==true then event.DO_Order() end end,
createStep=function(self,tag,reset,skip,endc)
if not(endc) then
endc=false
end
temp=
{
Name=tag,
pos=1,
endAt=reset or math.huge,
active=true,
endc=endc,
skip=skip or 0,
spos=0,
Step=function(self) if self~=nil then if self.spos==0 then _G.__CAction__=self if self.active==true then assert(loadstring("Step_"..tag.."("..self.pos..",__CAction__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CAction__)"))() end end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
FStep=function(self) if self~=nil then if self.spos==0 then _G.__CAction__=self assert(loadstring("Step_"..tag.."("..self.pos..",__CAction__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CAction__)"))() end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) _G.__CAction__=self assert(loadstring("Step_"..self.Name.."_End(__CAction__)"))() self:Reset() end,
}
table.insert(event.Steps,temp) return temp
end,
createTStep=function(self,tag,reset,timer,endc)
if not(endc) then
endc=false
end
timer=timer or 1
temp=
{
Name=tag,
pos=1,
endAt=reset or math.huge,
active=true,
endc=endc,
skip= 0,
spos=0,
Step=function(self) if self~=nil then if self.spos==0 then _G.__CAction__=self if self.active==true then assert(loadstring("TStep_"..tag.."("..self.pos..",__CAction__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("TStep_"..self.Name.."_End(__CAction__)"))() end end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
FStep=function(self) if self~=nil then if self.spos==0 then _G.__CAction__=self assert(loadstring("TStep_"..tag.."("..self.pos..",__CAction__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("TStep_"..self.Name.."_End(__CAction__)"))() end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
event:setAlarm("TStep_"..tag,timer)
event:addTracker("_TStep_"..tag,temp)
table.insert(event.TSteps,temp)
assert(loadstring("function Alarm_TStep_"..tag.."(alarm) event:getTracker(\"_\"..alarm):Step() event:updateAlarm(alarm,"..timer..") end"))()
return temp
end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
tstepExist=function(self,tag)
for a_s=1,#event.TSteps do
if event.TSteps[a_s].Name==tag then
return true
end
end
return false
end,
}
function dump(t,indent)
local names = {}
if not indent then indent = "" end
for n,g in pairs(t) do
table.insert(names,n)
end
table.sort(names)
for i,n in pairs(names) do
local v = t[n]
if type(v) == "table" then
if(v==t) then -- prevent endless loop if table contains reference to itself
print(indent..tostring(n)..": <-")
else
print(indent..tostring(n)..":")
dump(v,indent.." ")
end
else
if type(v) == "function" then
print(indent..tostring(n).."()")
else
print(indent..tostring(n)..": "..tostring(v))
end
end
end
end
function SetCounter()
return os.clock()
end
----------------------------------------------------------------------------------------------------
function GetCounter(count)
if count~=nil then
return os.clock()-count
else
return 0
end
end
----------------------------------------------------------------------------------------------------
clock=os.clock
event={
Active=true,
CT=false,
tag={},
Events={},
Alarms={},
EventTracker={},
Steps={},
TSteps={},
CTask="",
LoadOrder="/E/S/A/U",
UpdateObj=
{
LoadOrder="",
Resume=function(self) event.LoadOrder=self.LoadOrder end,
Pause=function(self) self.LoadOrder=event.LoadOrder event.LoadOrder=event.LoadOrder:gsub("/U", "") end,
},
setLoadOrder=function(self,str) event.LoadOrder=string.upper(str) end,
DO_Order=function() LoadOrder=event.LoadOrder LoadOrder=LoadOrder:gsub("/A", "event.RUN_ALARMS(); ") LoadOrder=LoadOrder:gsub("/E", "event.RUN_EVENTS(); ") LoadOrder=LoadOrder:gsub("/S", "event.RUN_STEPS(); ") LoadOrder=LoadOrder:gsub("/U", "event.RUN_UPDATES(); ") assert(loadstring(LoadOrder))() end,
RUN_EVENTS=function() event.CTask="events" for d=1,#event.Events do assert(loadstring(event.Events[d]))() end end,
RUN_STEPS=function() event.CTask="steps" for s_g=1,#event.Steps do event.Steps[s_g]:Step() end end,
RUN_UPDATES=function() _G.__CAction__=event.UpdateObj event.CTask="updates" event.OnUpdate() end,
RUN_ALARMS=function() for i=1,#event.Alarms do event.Alarms[i]:Tick() end end,
--System Used Functions
Hold=function(self,task) -- as many conditions and times that you want can be used
local action=__CAction__
action:Pause()
if type(task)=="number" then
local func=function() end
local alarm=event:newAlarm(task,func,true)
while alarm.active==true do
event.CManager()
end
alarm:Destroy()
action:Resume()
elseif type(task)=="string" then
assert(loadstring("while not("..task..") do event.CManager() end"))()
action:Resume()
end
end,
newAlarm=function(self,set,func,start)
if not(start) then timer=0 active=false else timer=clock() active=true end
if not(func) then func=(function() end) end
Alarm=
{
active=active,
timer=timer,
set=set or 0,
func=func,
Tick=function(self) _G.__CAction__=self if self.active==true then if clock()-self.timer>=self.set then self:Pause() self:Ring() end end end,
Pause=function(self) self.active=false end,
Set=function(self,amt) self.set=amt self.timer=clock() self:Resume() end,
OnRing=function(self,func) self.func=func end,
Ring=function(self) self:func(self) end,
Reset=function(self) self.timer=clock() self:Resume() end,
Resume=function(self) self.active=true end,
Destroy=function(self) for i=1,#event.Alarms do if tostring(event.Alarms[i])==tostring(self) then table.remove(event.Alarms,i) end end end,
}
table.insert(event.Alarms,Alarm)
return Alarm
end,
setAlarm=function(self,tag,set)
if event:eventExist("Alarm_"..tag.."(\""..tag.."\")")==false then
event:new("Alarm_"..tag.."(\""..tag.."\")",[[GetCounter(event:getTracker("_Alarm_]]..tag..[["))>=]]..set,[[event:removeAlarm("]]..tag..[[")]])
event:addTracker("_Alarm_"..tag,SetCounter())
assert(loadstring("if Alarm_"..tag.."==nil then function Alarm_"..tag.."() print('No function \"Alarm_"..tag.."()\" exists make sure you created it') end end"))()
else
event:addTracker("_Alarm_"..tag,SetCounter())
end
end,
setEvent=function(self,fname,condition,also) if not(string.find(fname,"(",1,true)) and not(string.find(fname,")",1,true)) then fname=fname.."()" end a=string.find(fname,"(",1,true) tempstr=string.sub(fname,1,a-1) event:new("Event_"..fname,condition,also) assert(loadstring("if Event_"..tempstr.."==nil then function Event_"..tempstr.."() print('No function \"Event_"..tempstr.."()\" exists make sure you created it') end end"))() end,
removeAlarm=function(self,tag) event:destroyEvent("Alarm_"..tag) event:removeTracker("_Alarm_"..tag) end,
updateAlarm=function(self,tag,set) event:removeAlarm(tag) event:setAlarm(tag,set) end,
addTracker=function(self,varname,var) event.EventTracker[varname]=var end,
getTracker=function(self,varname) return event.EventTracker[varname] end,
listTrackers=function(self) return event.EventTracker end,
removeTracker=function(self,var) event.EventTracker[var]=nil end,
trackerExist=function(self,tag) return event.EventTracker[tag]~=nil end,
updateTracker=function(self,tag,val) if event:trackerExist(tag) then event.EventTracker[tag]=val end end,
alarmExist=function(self,tag) return (event:getTracker("_Alarm_"..tag)~=nil) end,
new=function(self,fname,condition,also) if not(also) then also="" end table.insert(self.Events,"if "..condition.." then "..also.." "..fname.." end") table.insert(event.tag,fname) end,
eventExist=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then return true end end return false end,
destroyEvent=function(self,tag) for j=1,#event.tag do if event.tag[j]==tag then table.remove(event.tag,j) table.remove(event.Events,j) end end end,
Stop=function() event.Active=false end,
OnCreate=function() end,
OnUpdate=function() end,
OnClose=function() end,
getActive=function() return event.tag end,
Manager=function() event.OnCreate() while event.Active==true do event.DO_Order() end event.OnClose() end,
CManager=function() if event.Active==true then event.DO_Order() end end,
UManager=function() if event.CT==false then event.CT=true event.OnCreate() end if event.Active==true then event.DO_Order() end end,
createStep=function(self,tag,reset,skip,endc)
if not(endc) then
endc=false
end
temp=
{
Name=tag,
pos=1,
endAt=reset or math.huge,
active=true,
endc=endc,
skip=skip or 0,
spos=0,
Step=function(self) if self~=nil then if self.spos==0 then _G.__CAction__=self if self.active==true then assert(loadstring("Step_"..tag.."("..self.pos..",__CAction__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CAction__)"))() end end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
FStep=function(self) if self~=nil then if self.spos==0 then _G.__CAction__=self assert(loadstring("Step_"..tag.."("..self.pos..",__CAction__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("Step_"..self.Name.."_End(__CAction__)"))() end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) _G.__CAction__=self assert(loadstring("Step_"..self.Name.."_End(__CAction__)"))() self:Reset() end,
}
table.insert(event.Steps,temp) return temp
end,
createTStep=function(self,tag,reset,timer,endc)
if not(endc) then
endc=false
end
timer=timer or 1
temp=
{
Name=tag,
pos=1,
endAt=reset or math.huge,
active=true,
endc=endc,
skip= 0,
spos=0,
Step=function(self) if self~=nil then if self.spos==0 then _G.__CAction__=self if self.active==true then assert(loadstring("TStep_"..tag.."("..self.pos..",__CAction__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("TStep_"..self.Name.."_End(__CAction__)"))() end end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
FStep=function(self) if self~=nil then if self.spos==0 then _G.__CAction__=self assert(loadstring("TStep_"..tag.."("..self.pos..",__CAction__)"))() self.pos=self.pos+1 end end if self.endAt+1<=self.pos then self:Reset() if endc==true then assert(loadstring("TStep_"..self.Name.."_End(__CAction__)"))() end end self.spos=self.spos+1 if self.spos>=self.skip then self.spos=0 end end,
Remove=function(self) for as=1,#event.Steps do if event.Steps[as].Name==self.Name then table.remove(event.Steps,as) end end end,
Reset=function(self) self.pos=1 end,
Set=function(self,amt) self.pos=amt end,
Pause=function(self) self.active=false end,
Resume=function(self) self.active=true end,
Stop=function(self) self:Reset() self:Pause() end,
Start=function(self) self:Resume() end,
End=function(self) self.pos=self.EndAt self.endc=true end,
}
event:setAlarm("TStep_"..tag,timer)
event:addTracker("_TStep_"..tag,temp)
table.insert(event.TSteps,temp)
assert(loadstring("function Alarm_TStep_"..tag.."(alarm) event:getTracker(\"_\"..alarm):Step() event:updateAlarm(alarm,"..timer..") end"))()
return temp
end,
stepExist=function(self,tag)
for a_s=1,#event.Steps do
if event.Steps[a_s].Name==tag then
return true
end
end
return false
end,
tstepExist=function(self,tag)
for a_s=1,#event.TSteps do
if event.TSteps[a_s].Name==tag then
return true
end
end
return false
end,
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+365 -365
View File
@@ -1,365 +1,365 @@
multi = {}
multi.__index = multi
multi.Mainloop={}
multi.Tasks={}
multi.Tasks2={}
multi.Garbage={}
multi.Children={}
multi.Paused={}
multi.MasterId=0
multi.Active=true
multi.Id=-1
-- System
function multi:newBase(ins)
local c = {}
setmetatable(c, multi)
c.Parent=self
c.Active=true
c.func={}
c.Id=0
c.Act=function() end
if ins then
table.insert(multi.Mainloop,ins,c)
else
table.insert(multi.Mainloop,c)
end
multi.MasterId=multi.MasterId+1
return c
end
function multi:reboot(r)
multi.Mainloop={}
multi.Tasks={}
multi.Tasks2={}
multi.Garbage={}
multi.Children={}
multi.Paused={}
multi.MasterId=0
multi.Active=true
multi.Id=-1
if r then
for i,v in pairs(_G) do
if type(i)=="table" then
if i.Parent and i.Id and i.Act then
i={}
end
end
end
end
end
--Processor
function multi.Do_Order()
for _D=#multi.Mainloop,1,-1 do
if multi.Mainloop[_D]~=nil then
multi.Mainloop[_D].Id=_D
multi.Mainloop[_D]:Act()
end
end
end
function multi:benchMark(sec)
local temp=multi:newStep(2)
temp.CC=0
temp:OnStep(function(pos,step) step.CC=step.CC+1 end)
local Loud=multi:newAlarm(sec)
Loud.Link=temp
Loud:OnRing(function(alarm) alarm.Link.CC=alarm.Link.CC print((alarm.Link.CC).." steps in "..alarm.set.." second(s)") alarm.bench=alarm.Link.CC alarm.Link:Destroy() alarm:Destroy() end)
return Loud
end
--Helpers
function multi:FreeMainEvent()
self.func={}
end
function multi:isPaused()
return not(self.Active)
end
function multi:Pause(n)
if not(n) then
self.Active=false
table.remove(multi.Mainloop,self.Id)
table.insert(multi.Paused,self)
else
self:hold(n)
end
end
function multi:Resume()
if self:isPaused() then
self.Active=true
table.remove(multi.Paused,self.Id)
table.insert(multi.Mainloop,self)
end
end
function multi:Remove()
self:Pause()
self:Destroy()
end
function multi:Destroy()
self:Pause()
if self:isPaused() then
for i=1,#multi.Paused do
if multi.Paused[i]==self then
table.remove(multi.Paused,i)
return
end
end
else
table.remove(multi.Mainloop,self.Id)
end
self.Act=function() end
end
function multi:hold(task)
self:Pause()
if type(task)=="number" then
local alarm=multi:newAlarm(task)
while alarm.Active==true do
if love then
multi.lManager()
else
multi.Do_Order()
end
end
alarm:Destroy()
self:Resume()
elseif type(task)=="function" then
local env=multi:newEvent(task)
env:OnEvent(function(envt) envt:Pause() envt:Stop() end)
while env.Active do
if love then
multi.lManager()
else
multi.Do_Order()
end
end
env:Destroy()
self:Resume()
else
print("Error Data Type!!!")
end
end
function multi:oneTime(func,...)
for _k=1,#multi.Tasks2 do
if multi.Tasks2[_k]==func then
return false
end
end
table.insert(multi.Tasks2,func)
func(...)
return true
end
--Constructors
function multi:newEvent(task)
local c=multi:newBase()
c.Type="Event"
c.Task=task or function() end
function c:Act()
if self.Task(self) and self.Active==true then
self:Pause()
for _E=1,#self.func do
self.func[_E](self)
end
end
end
function c:OnEvent(func)
table.insert(self.func,func)
end
return c
end
function multi:newAlarm(set)
local c=multi:newBase()
c.Type="Alarm"
c.timer=os.clock()
c.set=set or 0
function c:Act()
if self.Active==true then
if os.clock()-self.timer>=self.set then
self:Pause()
for i=1,#self.func do
self.func[i](self)
end
end
end
end
function c:Reset(n)
if n then self.set=n end
self.timer=os.clock()
self:Resume()
end
function c:OnRing(func)
table.insert(self.func,func)
end
return c
end
function multi:newTask(func)
table.insert(multi.Tasks,func)
end
function multi:newLoop()
local c=multi:newBase()
c.Type="Loop"
function c:Act()
if self.Active==true then
for i=1,#self.func do
self.func[i](os.clock()-multi.Start,self)
end
end
end
function c:OnLoop(func)
table.insert(self.func,func)
end
return c
end
function multi:newStep(start,reset,count,skip)
local c=multi:newBase()
think=1
c.Type="Step"
c.pos=start or 1
c.endAt=reset or math.huge
c.skip=skip or 0
c.spos=0
c.count=count or 1*think
c.funcE={}
c.start=start or 1
if start~=nil and reset~=nil then
if start>reset then
think=-1
end
end
function c:Act()
if self~=nil then
if self.spos==0 then
if self.Active==true then
for i=1,#self.func do
self.func[i](self.pos,self)
end
self.pos=self.pos+self.count
end
end
end
self.spos=self.spos+1
if self.spos>=self.skip then
self.spos=0
end
end
function c:OnStep(func)
table.insert(self.func,1,func)
end
function c:OnEnd(func)
table.insert(self.funcE,func)
end
function c:Update(start,reset,count,skip)
self.start=start or self.start
self.endAt=reset or self.endAt
self.skip=skip or self.skip
self.count=count or self.count
self:Resume()
end
c:OnStep(function(p,s)
if s.count>0 and s.endAt==p then
for fe=1,#s.funcE do
s.funcE[fe](s)
end
s.pos=s.start-1
elseif s.count<0 and s.endAt==p then
for fe=1,#s.funcE do
s.funcE[fe](s)
end
s.pos=s.start-1
end
end)
return c
end
function multi:newTStep(start,reset,count,set)
local c=multi:newBase()
think=1
c.Type="TStep"
c.start=start or 1
local reset = reset or math.huge
c.endAt=reset
c.pos=start or 1
c.skip=skip or 0
c.count=count or 1*think
c.funcE={}
c.timer=os.clock()
c.set=set or 1
function c:Update(start,reset,count,set)
self.start=start or self.start
self.pos=start
self.endAt=reset or self.endAt
self.set=set or self.set
self.count=count or self.count or 1
self.timer=os.clock()
self:Resume()
end
function c:Act()
if self.Active then
if os.clock()-self.timer>=self.set then
self:Reset()
for i=1,#self.func do
self.func[i](self.pos,self)
end
if self.endAt==self.pos then
for fe=1,#self.funcE do
self.funcE[fe](self)
end
self.pos=self.start-1
end
self.pos=self.pos+self.count
end
end
end
function c:OnEnd(func)
table.insert(self.funcE,func)
end
function c:Reset(n)
if n then self.set=n end
self.timer=os.clock()
self:Resume()
end
function c:OnStep(func)
table.insert(self.func,func)
end
return c
end
function multi:inQueue(func)
if self.Id==-1 then
print("Error: Can't queue the multi object")
return
end
local c=multi:newBase(self.Id)
self.Id=self.Id-1
c.Type="Queue"
c.Task=func
c.Link=self
function c:Act()
self.Task(self.Link)
self:Destroy()
end
end
function multi:newTrigger(func)
local c=multi:newBase()
c.Type="Trigger"
c.trigfunc=func or function() end
function c:Fire(...)
self:trigfunc(self,...)
end
return c
end
--Managers
function multi:mainloop()
for i=1,#multi.Tasks do
multi.Tasks[i]()
end
multi.Start=os.clock()
while self.Active do
multi.Do_Order()
end
end
function multi._tFunc(dt)
if dt then
multi.pump=true
end
multi.pumpvar=dt
multi.Start=os.clock()
end
function multi:uManager(dt)
multi:oneTime(multi._tFunc,dt)
multi.Do_Order()
end
multi = {}
multi.__index = multi
multi.Mainloop={}
multi.Tasks={}
multi.Tasks2={}
multi.Garbage={}
multi.Children={}
multi.Paused={}
multi.MasterId=0
multi.Active=true
multi.Id=-1
-- System
function multi:newBase(ins)
local c = {}
setmetatable(c, multi)
c.Parent=self
c.Active=true
c.func={}
c.Id=0
c.Act=function() end
if ins then
table.insert(multi.Mainloop,ins,c)
else
table.insert(multi.Mainloop,c)
end
multi.MasterId=multi.MasterId+1
return c
end
function multi:reboot(r)
multi.Mainloop={}
multi.Tasks={}
multi.Tasks2={}
multi.Garbage={}
multi.Children={}
multi.Paused={}
multi.MasterId=0
multi.Active=true
multi.Id=-1
if r then
for i,v in pairs(_G) do
if type(i)=="table" then
if i.Parent and i.Id and i.Act then
i={}
end
end
end
end
end
--Processor
function multi.Do_Order()
for _D=#multi.Mainloop,1,-1 do
if multi.Mainloop[_D]~=nil then
multi.Mainloop[_D].Id=_D
multi.Mainloop[_D]:Act()
end
end
end
function multi:benchMark(sec)
local temp=multi:newStep(2)
temp.CC=0
temp:OnStep(function(pos,step) step.CC=step.CC+1 end)
local Loud=multi:newAlarm(sec)
Loud.Link=temp
Loud:OnRing(function(alarm) alarm.Link.CC=alarm.Link.CC print((alarm.Link.CC).." steps in "..alarm.set.." second(s)") alarm.bench=alarm.Link.CC alarm.Link:Destroy() alarm:Destroy() end)
return Loud
end
--Helpers
function multi:FreeMainEvent()
self.func={}
end
function multi:isPaused()
return not(self.Active)
end
function multi:Pause(n)
if not(n) then
self.Active=false
table.remove(multi.Mainloop,self.Id)
table.insert(multi.Paused,self)
else
self:hold(n)
end
end
function multi:Resume()
if self:isPaused() then
self.Active=true
table.remove(multi.Paused,self.Id)
table.insert(multi.Mainloop,self)
end
end
function multi:Remove()
self:Pause()
self:Destroy()
end
function multi:Destroy()
self:Pause()
if self:isPaused() then
for i=1,#multi.Paused do
if multi.Paused[i]==self then
table.remove(multi.Paused,i)
return
end
end
else
table.remove(multi.Mainloop,self.Id)
end
self.Act=function() end
end
function multi:hold(task)
self:Pause()
if type(task)=="number" then
local alarm=multi:newAlarm(task)
while alarm.Active==true do
if love then
multi.lManager()
else
multi.Do_Order()
end
end
alarm:Destroy()
self:Resume()
elseif type(task)=="function" then
local env=multi:newEvent(task)
env:OnEvent(function(envt) envt:Pause() envt:Stop() end)
while env.Active do
if love then
multi.lManager()
else
multi.Do_Order()
end
end
env:Destroy()
self:Resume()
else
print("Error Data Type!!!")
end
end
function multi:oneTime(func,...)
for _k=1,#multi.Tasks2 do
if multi.Tasks2[_k]==func then
return false
end
end
table.insert(multi.Tasks2,func)
func(...)
return true
end
--Constructors
function multi:newEvent(task)
local c=multi:newBase()
c.Type="Event"
c.Task=task or function() end
function c:Act()
if self.Task(self) and self.Active==true then
self:Pause()
for _E=1,#self.func do
self.func[_E](self)
end
end
end
function c:OnEvent(func)
table.insert(self.func,func)
end
return c
end
function multi:newAlarm(set)
local c=multi:newBase()
c.Type="Alarm"
c.timer=os.clock()
c.set=set or 0
function c:Act()
if self.Active==true then
if os.clock()-self.timer>=self.set then
self:Pause()
for i=1,#self.func do
self.func[i](self)
end
end
end
end
function c:Reset(n)
if n then self.set=n end
self.timer=os.clock()
self:Resume()
end
function c:OnRing(func)
table.insert(self.func,func)
end
return c
end
function multi:newTask(func)
table.insert(multi.Tasks,func)
end
function multi:newLoop()
local c=multi:newBase()
c.Type="Loop"
function c:Act()
if self.Active==true then
for i=1,#self.func do
self.func[i](os.clock()-multi.Start,self)
end
end
end
function c:OnLoop(func)
table.insert(self.func,func)
end
return c
end
function multi:newStep(start,reset,count,skip)
local c=multi:newBase()
think=1
c.Type="Step"
c.pos=start or 1
c.endAt=reset or math.huge
c.skip=skip or 0
c.spos=0
c.count=count or 1*think
c.funcE={}
c.start=start or 1
if start~=nil and reset~=nil then
if start>reset then
think=-1
end
end
function c:Act()
if self~=nil then
if self.spos==0 then
if self.Active==true then
for i=1,#self.func do
self.func[i](self.pos,self)
end
self.pos=self.pos+self.count
end
end
end
self.spos=self.spos+1
if self.spos>=self.skip then
self.spos=0
end
end
function c:OnStep(func)
table.insert(self.func,1,func)
end
function c:OnEnd(func)
table.insert(self.funcE,func)
end
function c:Update(start,reset,count,skip)
self.start=start or self.start
self.endAt=reset or self.endAt
self.skip=skip or self.skip
self.count=count or self.count
self:Resume()
end
c:OnStep(function(p,s)
if s.count>0 and s.endAt==p then
for fe=1,#s.funcE do
s.funcE[fe](s)
end
s.pos=s.start-1
elseif s.count<0 and s.endAt==p then
for fe=1,#s.funcE do
s.funcE[fe](s)
end
s.pos=s.start-1
end
end)
return c
end
function multi:newTStep(start,reset,count,set)
local c=multi:newBase()
think=1
c.Type="TStep"
c.start=start or 1
local reset = reset or math.huge
c.endAt=reset
c.pos=start or 1
c.skip=skip or 0
c.count=count or 1*think
c.funcE={}
c.timer=os.clock()
c.set=set or 1
function c:Update(start,reset,count,set)
self.start=start or self.start
self.pos=start
self.endAt=reset or self.endAt
self.set=set or self.set
self.count=count or self.count or 1
self.timer=os.clock()
self:Resume()
end
function c:Act()
if self.Active then
if os.clock()-self.timer>=self.set then
self:Reset()
for i=1,#self.func do
self.func[i](self.pos,self)
end
if self.endAt==self.pos then
for fe=1,#self.funcE do
self.funcE[fe](self)
end
self.pos=self.start-1
end
self.pos=self.pos+self.count
end
end
end
function c:OnEnd(func)
table.insert(self.funcE,func)
end
function c:Reset(n)
if n then self.set=n end
self.timer=os.clock()
self:Resume()
end
function c:OnStep(func)
table.insert(self.func,func)
end
return c
end
function multi:inQueue(func)
if self.Id==-1 then
print("Error: Can't queue the multi object")
return
end
local c=multi:newBase(self.Id)
self.Id=self.Id-1
c.Type="Queue"
c.Task=func
c.Link=self
function c:Act()
self.Task(self.Link)
self:Destroy()
end
end
function multi:newTrigger(func)
local c=multi:newBase()
c.Type="Trigger"
c.trigfunc=func or function() end
function c:Fire(...)
self:trigfunc(self,...)
end
return c
end
--Managers
function multi:mainloop()
for i=1,#multi.Tasks do
multi.Tasks[i]()
end
multi.Start=os.clock()
while self.Active do
multi.Do_Order()
end
end
function multi._tFunc(dt)
if dt then
multi.pump=true
end
multi.pumpvar=dt
multi.Start=os.clock()
end
function multi:uManager(dt)
multi:oneTime(multi._tFunc,dt)
multi.Do_Order()
end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff