Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 07 Jan 2012 10:04 AM |
| It needs to accept a virtually unlimited number of parameters, and then I need to loop over them and do something with them. |
|
|
| Report Abuse |
|
|
1Ra
|
  |
| Joined: 02 May 2010 |
| Total Posts: 2400 |
|
| |
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 07 Jan 2012 10:09 AM |
function print1337(...)
for i,v in pairs(...) do --- do stuff end
end
print1337(pcall(randomfunction, randomparameter)) |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 07 Jan 2012 10:12 AM |
| Never mind I figured it out, you use "arg" |
|
|
| Report Abuse |
|
|
|
| 07 Jan 2012 10:15 AM |
| Print works that way already. I thought you meant a custom function to print something to the output without using the 'print' function. That would be difficult, if not impossible, with RBX.lua. |
|
|
| Report Abuse |
|
|
Seranok
|
  |
| Joined: 12 Dec 2009 |
| Total Posts: 11083 |
|
|
| 07 Jan 2012 10:21 AM |
I want to make a function that accepts any amount of arguments, and does something for each argument.
function f(...) for i,v in ipairs(...) do -- do something end end
f(string.gsub("lojksdflja", "a", "e"))
But I can't figure out how to do this. Help? |
|
|
| Report Abuse |
|
|