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

the pcall and the 3 dots (...)

Started by Ta©ti_Tac0Z, 09 July 2018 - 08:37 PM
Ta©ti_Tac0Z #1
Posted 09 July 2018 - 10:37 PM
so i was makeing a "safe script runner" basicly a save way to run my function so right easy right but i came in to an problem so we all know:
{…} this will give us a table of "argument" witch we can use. want to use pcall to catch the error the problem is that when i try to use … it will tell me that i cannot do that becuse of being out side a vararg function so? what do i have to do?

(forinstace i want this to work:

pcall(function() print(…) end, "hallo word")

target output:
halloworld
what we will get:
error: cannot use '…' outside a vararg function

what can we do to fix this?)
Lyqyd #2
Posted 10 July 2018 - 02:49 AM
You need to tell the function to expect extra arguments:


pcall(function(...) print(...) end, "Hello, world!")
Ta©ti_Tac0Z #3
Posted 10 July 2018 - 10:36 PM
i found why sorry for wasting your time but i was unable to say so given that my thread needed to be inspected by a moderrator first