The Function editor is a simple code editor and a few fields to help create and manage user functions in the global scope.
Pictured above you can see a hypothetical function used to add or subtract the global PLAYER_CASH by the addedCash variable.
The function editor is pretty basic and only comes with three important properties in which you can manage.
- Function name - a global unused name that will be used to call the function.(Good example: render_worldmap, Bad Example: Array ).
- Function parameters - A list of variables inputted into a function with each parameter separated by a comma, left blank for functions without needed parameters.
These parameters when exported will look something like this
function_name( custom Parameter 1, custom Parameter 2,...etc )
Custom Function Language
Custom Function Scope
The Scope of all user-generated functions via this editor is in the GLOBAL SCOPE, but they are not available until after GPE loads. This means instead of saying gpe.custom_function( parameters ); you simply call custom_function( parameters );
Custom Function Parameters
One slight tweak to GPE's function editor instead of other systems is that allowance of default values within the parameters field. Default parameters are used in instances where if a user calls a function and will like to ignore or rely on a parameter's value to be assigned a default value. For example a function is named exponent and it takes 2 values, the number and the exponent level. One developer may want the exponent to default to a square. Thus a user can call either exponent(6,2) and get 36 or simply call exponent(6) and be returned 36. Default parameters often save time, so they are often advised for most functions.
Custom Function Return Types
Currently in Version 1.12x and older custom functions do not need to have a return type specified.