Changes between Version 1 and Version 2 of Exposed_Misc_Functions


Ignore:
Timestamp:
Feb 23, 2008, 9:31:56 PM (16 years ago)
Author:
Jan Wassenberg
Comment:

remove old contents, replace by previous contents of ScriptGlue page

Legend:

Unmodified
Added
Removed
Modified
  • Exposed_Misc_Functions

    v1 v2  
    1 <font color="red">'''DEPRECATED; will be replaced by contents of "jan's stomping ground"'''</font>
    2 
    3 = Miscellaneous Methods =
     1
     2= Events =
     3
     4== addGlobalHandler ==
     5 * '''Overview:'''
     6  * Register a global handler for the specified DOM event.
     7 * '''Syntax:'''
     8  * success = addGlobalHandler(event_type_name, handler);
     9 * '''Parameters:'''
     10  * event type name [wstring], handler [fragment or function]
     11 * '''Returns:'''
     12  * whether it was actually newly registered [bool]
     13 * '''Notes:'''
     14  *
     15
     16== removeGlobalHandler ==
     17 * '''Overview:'''
     18  * Remove a previously registered global handler for the specified DOM event.
     19 * '''Syntax:'''
     20  * success = removeGlobalHandler(event_type_name, handler);
     21 * '''Parameters:'''
     22  * event type name [wstring], handler [fragment or function]
     23 * '''Returns:'''
     24  * whether it was successfully removed [bool]
     25 * '''Notes:'''
     26  *
     27
     28= Timer =
     29
     30== setTimeout ==
     31 * '''Overview:'''
     32  * Request a callback be executed after the specified delay.
     33 * '''Syntax:'''
     34  * setTimeout(delayed_func, 100);
     35 * '''Parameters:'''
     36  * callback [fragment or function], delay in milliseconds [int]
     37 * '''Returns:'''
     38  *
     39 * '''Notes:'''
     40  * Scripts and functions registered this way are called on the first simulation frame after the specified period has elapsed. If this causes multiple segments of code to be executed in the same frame, relative timing is maintained. Delays of 0 milliseconds cause code to be executed on the following simulation frame. If more than one script or function is scheduled to execute in the same millisecond, the order of execution is undefined. Code is scheduled in simulation time, and is therefore suspended while the game is paused or frozen. Granularity of timing is also limited to 1/(Simulation frame rate); currently 100ms. The called function or script executes in the same scope as the code that called setTimeout (amongst other things, the 'this' reference is usually maintained)
     41
     42== setInterval ==
     43 * '''Overview:'''
     44  * Request a callback be executed periodically.
     45 * '''Syntax:'''
     46  * setInterval(atlasUpdateInfoWindow, 500);
     47 * '''Parameters:'''
     48  * callback [fragment or function], initial delay in ms [int], period in ms [int] OR
     49  * callback [fragment or function], period in ms [int] (initial delay = period)
     50 * '''Returns:'''
     51  *
     52 * '''Notes:'''
     53  * setTimeout's notes apply here as well.
     54
     55== cancelInterval ==
     56 * '''Overview:'''
     57  * Cause all periodic functions registered via setInterval to no longer be called.
     58
     59 * '''Syntax:'''
     60  * cancelInterval();
     61 * '''Parameters:'''
     62  *
     63 * '''Returns:'''
     64  *
     65 * '''Notes:'''
     66  * Execution continues until the end of the triggered function or script fragment, but is not triggered again.
     67
     68= Debug =
     69
     70== crash ==
     71 * '''Overview:'''
     72  * Deliberately cause the game to crash.
     73 * '''Syntax:'''
     74  * crash()
     75 * '''Parameters:'''
     76  *
     77 * '''Returns:'''
     78  *
     79 * '''Notes:'''
     80  * Currently implemented via access violation (read of address 0)
     81  * Useful for testing the crashlog/stack trace code.
     82
     83== forceGC ==
     84 * '''Overview:'''
     85  * Force a JS GC (garbage collection) cycle to take place immediately.
     86 * '''Syntax:'''
     87  * forceGC()
     88 * '''Parameters:'''
     89  *
     90 * '''Returns:'''
     91  *
     92 * '''Notes:'''
     93  * Writes an indication of how long this took to the console.
     94
     95= Misc. Script System =
     96
     97== getGlobal ==
     98 * '''Overview:'''
     99  * Returns the global object.
     100 * '''Syntax:'''
     101  * global = getGlobal()
     102 * '''Parameters:'''
     103  *
     104 * '''Returns:'''
     105  * global object
     106 * '''Notes:'''
     107  * Useful for accessing an object from another scope.
     108
     109= Misc. Engine Interface =
     110
     111== writeLog ==
     112 * '''Overview:'''
     113  * Write values to the log file.
     114 * '''Syntax:'''
     115  * writeLog("string", 1234);
     116 * '''Parameters:'''
     117  * any number of any type.
     118 * '''Returns:'''
     119  *
     120 * '''Notes:'''
     121  * Each argument is converted to a string and then written to the log.
     122  * Output is in NORMAL style (see LOG).
     123
     124== setCursor ==
     125 * '''Overview:'''
     126  * Change the mouse cursor.
     127 * '''Syntax:'''
     128  * setCursor("action-attack")
     129 * '''Parameters:'''
     130  * cursor name [string] (i.e. basename of definition file and texture)
     131 * '''Returns:'''
     132  *
     133 * '''Notes:'''
     134  * Cursors are stored in "art\textures\cursors"
     135
     136== getFPS ==
     137 * '''Overview:'''
     138  * Return the global frames-per-second value.
     139 * '''Syntax:'''
     140  * fps = getFPS()
     141 * '''Parameters:'''
     142  *
     143 * '''Returns:'''
     144  * FPS [int]
     145 * '''Notes:'''
     146  * This value is recalculated once a frame. We take special care to filter it, so it is both accurate and free of jitter.
     147
     148== exit ==
     149 * '''Overview:'''
     150  * Cause the game to exit gracefully.
     151 * '''Syntax:'''
     152  * exit();
     153 * '''Parameters:'''
     154  *
     155 * '''Returns:'''
     156  *
     157 * '''Notes:'''
     158  * Exit happens after the current main loop iteration ends (since this only sets a flag telling it to end)
     159
     160== vmem ==
     161 * '''Overview:'''
     162  * Write an indication of total/available video RAM to console.
     163 * '''Syntax:'''
     164  * vmem()
     165 * '''Parameters:'''
     166  *
     167 * '''Returns:'''
     168  *
     169 * '''Notes:'''
     170  * Not supported on all platforms.
     171  * Only a rough approximation; do not base low-level decisions ("should I allocate one more texture?") on this.
     172
     173== _rewriteMaps ==
     174 * '''Overview:'''
     175  * Trigger a rewrite of all maps.
     176 * '''Syntax:'''
     177  * _rewriteMaps();
     178 * '''Parameters:'''
     179  *
     180 * '''Returns:'''
     181  *
     182 * '''Notes:'''
     183  * Usefulness is unclear. If you need it, consider renaming this and updating the docs.
     184
     185== _lodbias ==
     186 * '''Overview:'''
     187  * Change the LOD bias.
     188 * '''Syntax:'''
     189  * _lodbias(bias)
     190 * '''Parameters:'''
     191  * LOD bias [float]
     192 * '''Returns:'''
     193  *
     194 * '''Notes:'''
     195  * value is as required by GL_TEXTURE_LOD_BIAS.
     196  * useful for adjusting image "sharpness" (since it affects which mipmap level is chosen)
     197
     198= Miscellany =
     199
     200== v3dist ==
     201 * '''Overview:'''
     202  * Return distance between 2 points.
     203 * '''Syntax:'''
     204  * dist = v3dist(v1,v2);
     205 * '''Parameters:'''
     206  * 2 position vectors [CVector3D]
     207 * '''Returns:'''
     208  * Euclidean distance [float]
     209 * '''Notes:'''
     210  *
    4211
    5212== buildTime ==
    6213 * '''Overview:'''
    7   * Returns a string value of the date when the project was last built.
    8  * '''Syntax:'''
    9   * !ReturnString = buildTime (flag)
    10  * '''Parameters:'''
    11   * <font color="red">A flag set to 0 in the current example. Not sure what it does yet.</font>
    12  * '''Returns:'''
    13   * Date string in the format <Mon dd yyyy> (eg Jun 24 2005).
    14  * '''Notes:'''
    15   *
    16 
    17 == crash ==
    18  * '''Overview:'''
    19   * Crashes the engine.
    20   * Caution, debug only.
    21  * '''Syntax:'''
    22   * crash();
    23  * '''Parameters:'''
    24   * None.
    25  * '''Returns:'''
    26   * Nothing.
    27  * '''Notes:'''
    28   * Passes invalid data to the !SpiderMonkey engine.
    29 
    30 == exit ==
    31  * '''Overview:'''
    32   * Gracefully shuts down the engine, returning to the desktop.
    33  * '''Syntax:'''
    34   * exit()
    35  * '''Parameters:'''
    36   * None.
    37  * '''Returns:'''
    38   * None.
    39  * '''Notes:'''
    40   * Call this function to quit the game.
    41 
    42 == getFPS ==
    43  * '''Overview:'''
    44   * Return the current frames per second of the renderer.
    45  * '''Syntax:'''
    46   * FPS = getFPS()
    47  * '''Parameters:'''
    48   * None.
    49  * '''Returns:'''
    50   * FPS as a number (eg 30).
    51  * '''Notes:'''
    52   *
    53 
    54 == getGlobal ==
    55  * '''Overview:''' Access an object from another scope.
    56 
    57 == getGUIGlobal ==
    58  * '''Overview:''' Access a GUI object from another scope.
     214  * Return the date/time at which the current executable was compiled.
     215 * '''Syntax:'''
     216  * date = buildTime(0); // see below
     217 * '''Parameters:'''
     218  * none -> "$date $time"
     219  * 0    -> "$date"
     220  * 1    -> "$time"
     221 * '''Returns:'''
     222  * date and/or time [string]
     223 * '''Notes:'''
     224  * Displayed on main menu screen; tells non-programmers which auto-build they are running. Could also be determined via .EXE file properties, but that's a bit more trouble.
     225  * To be exact, the date/time returned is when scriptglue.cpp was last compiled; since the auto-build does full rebuilds, that is moot.
     226
    59227
    60228== getLanguageID ==
     
    69237 * '''Notes:'''
    70238  *
    71 
    72 == setInterval ==
    73  * '''Overview:'''
    74   * Schedules a function or script fragment to be called at a specified interval (the given JS function is continuously called each time a waiting period elapses).
    75  * '''Syntax:'''
    76   * setInterval( fragment, interval );
    77   * setInterval( function, interval );
    78   * setInterval( fragment, delay, interval );
    79   * setInterval( function, delay, interval );
    80   * Example: setInterval(atlasUpdateInfoWindow, 500); // Call the function atlasUpdateInfoWindow() every 500ms.
    81  * '''Parameters:'''
    82   * fragment: A text string containing executable !JavaScript.
    83   * function: An expression evaluating to a !JavaScript function.
    84   * interval: The interval between subsequent executions of the code. May not be negative.
    85   * delay: The delay, in milliseconds, before the code is first executed. (If unspecified, defaults to 'interval'). May not be negative.
    86  * '''Returns:'''
    87   * Nothing.
    88  * '''Notes:'''
    89   * Functions and script are executed first at 'delay' milliseconds after the call and then every 'interval' milliseconds thereafter. If 'delay' is not present, the first call is 'interval' milliseconds following the setInterval call.
    90   * All notes for setTimeout also apply to setInterval.
    91 
    92 == setTimeout ==
    93  * '''Overview:'''
    94   * Schedules a specified fragment of script or a script function to execute some time in the future.
    95  * '''Syntax:'''
    96   * setTimeout( fragment, delay );
    97   * setTimeout( function, delay );
    98  * '''Parameters:'''
    99   * delay: The desired delay, in milliseconds. May not be negative.
    100   * fragment: A text string containing executable !JavaScript.
    101   * function: An expression evaluating to a !JavaScript function.
    102  * '''Returns:'''
    103   * Nothing.
    104  * '''Notes:'''
    105   * Scripts and functions registered this way are called on the first simulation frame after the specified period has elapsed. If this causes multiple segments of code to be executed in the same frame, relative timing is maintained. Delays of 0 milliseconds cause code to be executed on the following simulation frame. If more than one script or function is scheduled to execute in the same millisecond, the order of execution is undefined. Code is scheduled in simulation time, and is therefore suspended while the game is paused or frozen. Granularity of timing is also limited to 1/(Simulation frame rate); currently 100ms. The called function or script executes in the same scope as the code that called setTimeout (amongst other things, the 'this' reference is usually maintained)
    106 
    107 == cancelInterval ==
    108  * '''Overview:'''
    109   * Ceases triggering the currently executing interval.
    110  * '''Syntax:'''
    111   * cancelInterval();
    112  * '''Parameters:'''
    113   * None.
    114  * '''Returns:'''
    115   * Nothing.
    116  * '''Notes:'''
    117   * Execution continues until the end of the triggered function or script fragment, but is not triggered again.
    118 
    119 == writeLog ==
    120  * '''Overview:'''
    121   * Writes an entry to the Prometheus log file.
    122  * '''Syntax:'''
    123   * writeLog( ... );
    124  * '''Parameters:'''
    125   * Any number of values of any type.
    126  * '''Returns:'''
    127   * Nothing.
    128  * '''Notes:'''
    129   * writeLog converts each of its arguments to a string, in turn. The message added to the logfile is all these strings concatenated together. The message is logged as 'NORMAL' style.