Difference between revisions of "Run()"

From ZCWiki
Jump to navigationJump to search
m (→‎run() Function Arguments: Added image of Arguments tab.)
m (→‎run() Function Arguments: Noted that the limitation on floats and ints as arguments only applies to the run() function.)
 
(2 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
== run() Function Arguments ==
 
== 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.
 
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:
 
Consider the following script example, which defines a script for a freeform combo:
Line 14: Line 16:
 
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.
 
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.
  
Arguement types are either {{KW|int}} or {{KW|float}}.  You can "simulate" passing in boolean values by using 0 for false and 1 for true.
+
Argument types are either {{KW|int}} or {{KW|float}}.  You can "simulate" passing in boolean values by using 0 for false and 1 for true.  Other data types, such as {{KW|ffc}} and {{KW|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.
 
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.
  
 
[[Category:ZScript]]
 
[[Category:ZScript]]

Latest revision as of 13:25, 1 June 2008

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.