|
Title: Snippet: Function Arguments Post by: Access_Denied on June 14, 2007, 03:59:22 AM If
you read the tutorial on functions, you should know what a function is.
But, do you know that functions can take arguments? Let me show you.
function Test(one,two,three) y = two + three x = one * 5 return x + y end Notice the three things inside the parentheses. Now, say we put in the numbers 1,2,3. Then, x + y would equal 10. Look at this, it might help you. function Test(1,2,3) y = 2 + 3 x = 1 * 5 return x + y end Since y = 5 and x = 5, it will return 10. Easy huh? Here's another example. function print(x,y,text,) screen:print(x,y,text,bluer) end This creates a custom print function. So instead of doing this: screen:print(10,10,"Hello",blue) You can do this: print(10,10,"Hello") Arguments are easy to use, but you will use them often. Hopefully this helped you a little bit. |