Function

Functions allow for you to "package" snippets of code that you use in your scripts.

Parts of a function:
Arguments - Also called args, arguments give functions the information they need to preform their task.

Arguments are local variables created when you declare the script.

function NAME( ARGUMENT_ONE, ARGUMENT_TWO )

Body - The body of the function is where all the action takes place.

Any code you want in the function must go in the function body.

function NAME --Function body print(2+2) --End of function body end Return - The return ends the function and returns what we wanted the function to provide.

You may return as many values as you want

function NAME --Function body print(2+2) return 2 --The script ends here --End of function body print("TACO") --This won't happen because we already returned! end End - The end keyword signals that our function has ended and that the interpreter can progress with the rest of the script

ONCE YOU END A FUNCTION NOTHING PAST THE END IS IN THE FUNCTION!

function NAME --Function body print(2+2) return 2 --The script ends here --End of function body print("TACO") --This won't happen because we already returned! end --This is the end keyword! This means the function code ends here.