mrSkortch/MissionScriptingTools

mist.removeFunction should return boolean true when function is removed

Closed this issue · 1 comments

The current implementation does not return anything, despite the docs saying so:

	--- Removes a scheduled function.
	-- @tparam number id function id
	-- @treturn boolean true if function was successfully removed, false otherwise.
	function mist.removeFunction(id)
		local i = 1
		while i <= #scheduledTasks do
			if scheduledTasks[i].id == id then
				table.remove(scheduledTasks, i)
			else
				i = i + 1
			end
		end
	end

The function should look like this:

	--- Removes a scheduled function.
	-- @tparam number id function id
	-- @treturn boolean true if function was successfully removed, false otherwise.
	function mist.removeFunction(id)
		local i = 1
		local removedFunction = false
		while i <= #scheduledTasks do
			if scheduledTasks[i].id == id then
				table.remove(scheduledTasks, i)
				removedFunction = true
			else
				i = i + 1
			end
		end
		return removedFunction
	end

de4b4e0

Fixed.