This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
cyanisaac's profile picture

Attempting to override Parallel.waitForAny() is having issues.

Started by cyanisaac, 12 July 2015 - 06:43 PM
cyanisaac #1
Posted 12 July 2015 - 08:43 PM
Hello there, I am trying to write a very tricky piece of code that is having a lot of issues.

I am trying to override parallel.waitForAny() to run additional tasks if conditions are met. The code looks like this:


local oldParallelWFA = parallel.waitForAny
function parallel.waitForAny(...)
  -- Blah blah blah additional stuff.
  oldParallelWFA(arg) -- Crashes
end

What is the proper way to do this so that it can pass through the function calls to the backed up function oldParallelWFA?

(And before anyone asks, I am taking this approach because I have to) (Specifically I am trying to override stuff in the new O[OS] 2.2 alphas that lock the filesystem).

EDIT: The error is "Expected function, got table."
Edited on 12 July 2015 - 06:45 PM
Lyqyd #2
Posted 12 July 2015 - 09:21 PM
You should probably use unpack() to separate out the table elements into an arguments list.
Grim Reaper #3
Posted 12 July 2015 - 09:44 PM
You should probably use unpack() to separate out the table elements into an arguments list.

This AND, although I'm not terribly familiar with the parallel API, you should return whatever the old function does.
cyanisaac #4
Posted 12 July 2015 - 10:11 PM
You should probably use unpack() to separate out the table elements into an arguments list.

This AND, although I'm not terribly familiar with the parallel API, you should return whatever the old function does.

These suggestions worked. Thank you very much.