|
| 06 Feb 2012 10:06 PM |
I'm confused.
I was reading the Wiki to get better with functions, and it randomly adds arguments in. What are they for? What do they do? |
|
|
| Report Abuse |
|
|
Riderj
|
  |
| Joined: 15 Aug 2011 |
| Total Posts: 1534 |
|
|
| 06 Feb 2012 10:07 PM |
They add functionality to a function.Here is an example of a function with arguments:
function add(num,num2) return num+num2 end
print(add(1,2))
That will print 3, arguments are basically variables that are stated when you call the function.
[=|I rate myself 6.5/10 in RBLX.Lua|=] |
|
|
| Report Abuse |
|
|
Zarcius
|
  |
| Joined: 08 Dec 2007 |
| Total Posts: 3024 |
|
|
| 06 Feb 2012 10:08 PM |
Arguments are things used as conditionals to pass a function.
workspace.Bob.Torso.Touched:connect(function(hit) --[[Here, hit is an argument.]] if hit.Parent.Name == "Steve" then print("Steve says: /""Hello, Bob!/""") else print("Go away!") end)
I think this is correct. |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 06 Feb 2012 10:09 PM |
function a(arg1,arg2) --these are called arguments print(arg1,arg2) end
a("b","c") >b c
function a(...) --this is argument local arg={...} --usually this wouldn't be needed, but roblox doesn't support arg print(unpack(arg)) end
a("b","c","d") >b c d
<'+1 Post. Ujelly?'> |
|
|
| Report Abuse |
|
|
|
| 06 Feb 2012 10:09 PM |
| http://www.roblox.com/Forum/ShowPost.aspx?PostID=62145553 |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 06 Feb 2012 10:10 PM |
Look at this for better reference
http://wiki.roblox.com/index.php/Arguments_and_Parameters
<'+1 Post. Ujelly?'> |
|
|
| Report Abuse |
|
|
Zarcius
|
  |
| Joined: 08 Dec 2007 |
| Total Posts: 3024 |
|
|
| 06 Feb 2012 10:10 PM |
| AFF, will you answer my thread pl0x? :3 |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2012 05:22 AM |
Actually,
function Test(P) --This is a Parameter. return P end
print(Test("Cool")) --This is a Argument. |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 07 Feb 2012 06:30 AM |
That is correct, however, most people just call the parameters inside the function arguments, mainly because it doesn't get as confusing.
<'+1 Post. Ujelly?'> |
|
|
| Report Abuse |
|
|
| |
|
Oysi
|
  |
| Joined: 06 Jul 2009 |
| Total Posts: 9058 |
|
| |
|