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

[Lua] How to take a function as an Argument

Started by gudenau, 03 September 2012 - 01:31 PM
gudenau #1
Posted 03 September 2012 - 03:31 PM
I want to write some apis that need to take a function as an argument to call later, I have looked for this but not found it.
KaoS #2
Posted 03 September 2012 - 03:46 PM
just pass the function name as an argument but omit the parenthesis at the end, when you add parenthesis then it is called so:


local function test()
print('me')
end
local function run(param1)
param1()
end
run(test)
gudenau #3
Posted 03 September 2012 - 04:28 PM
Thank you.
KaoS #4
Posted 04 September 2012 - 07:15 AM
no problem, what are you planning on using it for?
gudenau #5
Posted 04 September 2012 - 10:56 PM
My cc os.