GML Overview: Scripts

When you create a script, you want to access the arguments passed to it (either when using the script action, or when calling the script as a function from a program (or from another, or even the same script).

These arguments are stored in the variables argument0, argument1, ..., argument15. So there can be at most 16 arguments. (Note that when calling the script from an action, only the first 5 arguments can be specified.) You can also use argument[0] etc.

Scripts can also return a value, so that they can be used in expressions. For this end you use the return statement: return Execution of the script ends at the return statement!

Example Here is the definition for a little script that computes the square of the argument: {   return (argument0*argument0); }

To call a script from within a piece of code, just act the same way as when calling functions. That is, write the script name with the argument values in parentheses.

"square_val." So to call it, we'd need a program like this:

{   x = square_val(2); }

Then 'x' would get the value of '4'.

Previous: Functions

Next: Comments

Back To GML For Non-Programmers