Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maid:GiveTask varargs #143

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions Modules/Shared/Events/Maid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,24 @@ function Maid:__newindex(index, newTask)
end

--- Same as indexing, but uses an incremented number as a key.
-- @param task An item to clean
-- @treturn number taskId
function Maid:GiveTask(task)
assert(task, "Task cannot be false or nil")
-- @param tasks Item(s) to clean
-- @treturn table taskId(s)
function Maid:GiveTask(...)
local taskIds = {}

local taskId = #self._tasks+1
self[taskId] = task
for task in pairs({...}) do
05st marked this conversation as resolved.
Show resolved Hide resolved
assert(task, "Task cannot be false or nil")

if type(task) == "table" and (not task.Destroy) then
warn("[Maid.GiveTask] - Gave table task without .Destroy\n\n" .. debug.traceback())
local taskId = #self._tasks+1
table.insert(taskIds, taskId)
self[taskId] = task

if type(task) == "table" and (not task.Destroy) then
warn("[Maid.GiveTask] - Gave table task without .Destroy\n\n" .. debug.traceback())
end
end

return taskId
return taskIds
end

function Maid:GivePromise(promise)
Expand Down