Run()

From ZCWiki
Jump to: navigation, search

The run() function is a special function; it is the function called by Zelda Classic to run your scripts. You declare the run() function like any other function, however there are some unique features of this function that you must take into consideration.

run() Function Arguments

Like any "normal" function, the run() function may accept arguments. However, these arguments are tied to values you specify in ZQuest when you assign the associated script to a freeform combo or item.

The run() function can and must be declared only once, in every script.

Consider the following script example, which defines a script for a freeform combo:

ffc script myScript{
  void run(int X, int Y){
    // ...something exciting happens here...
  }
}
You can specify 8 arguments (D0 - D7) for the run() function

This particular run() function takes two inputs, X and Y. When you assign this script to a freeform combo, you can also specify the function arguments in the Arguments tab of the Edit FFC screen. You may use up to 8 arguments - they are labeled D0 through D7, and they are passed to the run() function in that order. Thus, the X in the example above corresponds to the value you enter for D0, the Y corresponds to D1, and so forth. The implication here is that you can name your arguments whatever you wish; Zelda Classic will know which argument is which.

Argument types are either int or float. You can "simulate" passing in boolean values by using 0 for false and 1 for true. Other data types, such as ffc and item, cannot be used as argument types with the run() function (they may be used as argument types for functions you declare yourself).

Like any other function, you don't have to use any arguments if you don't need them. If you do need to use arguments, keep in mind that you are limited to 8 total.