net/multi/loop.lua
Ryan aad031062f Changed how steps and loops work
Added multi.compat.backwards[ver]
Require this to be able to use features that were changed from that version.
loops callback args are now: self,dt
steps callback args are now: self,pos
If requiring the backwards compat for the previous version do so after requiring all of the modules you are using.
2017-06-20 23:32:57 -04:00

27 lines
480 B
Lua

require("multi")
function multi:newLoop(func)
local c=self:newBase()
c.Type='loop'
c.Start=self.clock()
if func then
c.func={func}
end
function c:tofile(path)
local m=bin.new()
m:addBlock(self.Type)
m:addBlock(self.func)
m:addBlock(self.Active)
m:tofile(path)
end
function c:Act()
for i=1,#self.func do
self.func[i](self,self.Parent.clock()-self.Start)
end
end
function c:OnLoop(func)
table.insert(self.func,func)
end
self:create(c)
return c
end