Game Development Reference
In-Depth Information
Arguments in scripts
A script can have up to 16 arguments. An argument is a value or variable that is given to
the script as it is run. This could be a number or a string.
Let's take a look at using arguments with our add script.
Instead of setting n1 and n2 to numbers directly, we are going to set them when the script
is actually running through the use of arguments. To do this, we set n1 to argument0 and
n2 to argument1 .
This is how our code should now look:
As you can see, we are no longer setting the variables directly to numbers and instead are
giving them the value of arguments 0 and 1.
Now, how do we set what those arguments are equal to? To do this, we go back to where
the script is executed in our object and input the arguments just like we would with any
other function. We type their values in between the brackets separated by a comma.
The following screenshot shows how this looks in GameMaker:
Search WWH ::




Custom Search