[ create a new paste ] login | about

Link: http://codepad.org/FYMyxkMm    [ raw code | fork ]

Lua, pasted on Jul 25:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local function OnFinished(self)
	local id = self.id
	if type(self.func) == "string" then
		-- We manually set the unpack count to prevent issues with an arg set that contains nil and ends with nil
		-- e.g. local t = {1, 2, nil, 3, nil} print(#t) will result in 2, instead of 5. This fixes said issue.
		self.object[self.func](self.object, unpack(self.args, 1, self.argsCount))
	else
		self.func(unpack(self.args, 1, self.argsCount))
	end

	-- If an error happens above, the below never runs!

	-- If the id is different it means that the timer was already cancelled
	-- and has been used to create a new timer during the OnFinished callback.
	if not self.looping and id == self.id then
		activeTimers[self.id] = nil
		self.args = nil
		inactiveTimers[self] = true
	end
end


Create a new paste based on this one


Comments: