0ad/docs/JSReg.rtf
pyrolink b5d9da29c1 #When appropriate (i.e. wheeled units), units will align with the slope of the terrain. *JS documentation
*added CTerrain::getSlopeAngle[Face]() which returns the angle in
radians of the slope of the terrain.  getSlopeAngleFace should be used
for entities because it takes into account which way the entity is
facing, which allows for negative angles.
*the max and min graphical rotation for the slope is under traits.pitch.
This is used so that you can have certain units such as infantry that
don't rotate very far go down steep slopes but not rotate too much.
*JS documentation in docs/JSReg.rtf -- I put in most of the relevant
global functions; still needs entity functions.

This was SVN commit r3794.
2006-04-22 05:52:23 +00:00

96 lines
6.4 KiB
Plaintext

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fswiss\fprq2\fcharset0 Arial;}{\f2\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\nowidctlpar\f0\fs24 This is a function reference for scripters and modders. If you're not familiar with data types, you may find this helpful:\par
\par
int = a whole number like 0, 1, 55 etc.\par
bool = can have two values - true or false.\par
float = a "real number" with six decimal places e.g. 1, 5.589, 6.2, 3.14 ....\par
string = a combination or "string" of characters and/or numbers. These are put in quotes e.g. "this is a string"\par
\par
entity = an object which represents a unit in the game. Each entity has its own set of functions and attributes.\par
handle = each entity has a number assigned to it that the engine uses as its "ID". \par
\par
============================================================\par
Class: Output\par
\par
WriteLog(...) - accepts any number of arguments of any type. All parameters are converted to strings. Output is NORMAL style log.\par
==============================================================\par
Class: Entity\par
\par
getEntityByHandle( int handle ) - returns the entity with the specified handle.\par
getEntityTemplateName( string name ) - returns the entity template object that has the specified name.\par
\par
issueCommand( entity(s), int order_type, args[0], args[1]) - this will create a command, or order, for an entity or group of entities. This entity(s) is specified in the first parameter. order_type should be one of the net messages listed in the "net message order" section. args is an array that contains the data necessary for the order. For example, if it is a location message such as NMT_GOTO, args[0] should be the x coordinate of the destination and args[1] should be the y coordinate. See functions_sim_entity.js worldClickHandler for more information.\par
\par
createEntityFormation( entities, string name ) - creates a formation of type "name" out of the units in "entities".\par
removeFromFormation( entity(s) ) - removes the entity(s) from their formation. It is required that if it is a group, they are all in the same formation.\par
lockEntityFormation( entity, bool lock ) - If lock is true, the formation "entity" is in will be locked. Otherwise, it will be unlocked.\par
isFormationLocked( entity ) -returns true if the entity's formation is locked, otherwise false.\par
\par
startPlacing( string name ) - Activates the building placement cursor for placing a building. "name" is the name of the entity to place. Returns true on sucess\par
==========================================================\par
Class: Events\par
\par
AddGlobalHandler( string event_name, function handler ) - Registers a global handler for the specified DOM event. function handler can be a fragment or function. Returns true on success, else false.\par
RemoveGlobalHandler( string event_name, function handler ) - Removes a global handler. function handler can be a fragment or function. Returns true success.\par
==========================================================\par
Class Timer:\par
\par
setTimeout( code, int time ) - time is a delay in milliseconds. When this time has elapsed, "code" is executed once. Code can be a fragment or function \par
Example: setTimeout( console.write("1 second passed"), 1000 ); Returns the ID of the timer (int).\par
\par
setIntervel( code, int time ) - nearly the same as setTimeout(), but "code" is executed every "time" milliseconds instead of once after a single delay.\par
cancelIntervel() - causes all functions registered with setInterval to no longer be called.\par
cancelTimer(int ID) - causes the timer or interval with this ID to longer be called.\par
====================================================\par
Class GameSetup:\par
\par
createServer() - creates and returns a network server object\par
createClient() \endash creates and returns a client server object\par
\par
startGame() \endash begins the process of starting the game. Returns true on success. \endash may be changed soon\par
\par
endGame() \endash immediately ends the game\par
\pard\brdrb\brdrdb\brdrw15\brsp20 \nowidctlpar =================================================\par
\pard\nowidctlpar Class Internationalization:\par
\par
loadLanguage( string language ) \endash replaces the current langauge with \ldblquote language\rdblquote .\par
getLanguageID() - returns the name of the current language [string].\par
=================================================\par
Class GUI:\par
\par
getGUIGlobal() - returns the "global" object associated with the current GUI.\par
=================================================\par
Class Misc. Engine:\par
\par
getFPS() - returns the frame rate of the game [int].\par
exitProgram() - causes the game to exit.\par
changeCursor(string cursor) - changes the cursor to [string]. Cursors are stored in "art\\textures\\cursors" and "cursor" is the basename of the texture.\par
_lodbias(float sharpness) - changes the sharpness of textures (to "sharpness).\par
setCameraTarget(CVector3D position) - move the camera to look at "position". Returns true on success. \par
\par
v3dist( CVector3D a, CVector3D b ) - returns the distance between vectors a and b [float].\par
toggleWater() - toggles the rendering of water.\par
===============================================\par
Class water:\par
\par
setWaterHeight( float height ) - changes the height of the water to "height".\par
getWaterHeight() - returns the height of the water plane [float].\par
setWaterColor( float r, float g, float b ) - sets the color of the water plane to the specified components.\par
setWaterMaxAlpha( float max ) - sets the maximum alpha value (when the water is at WaterFullDepth or deeper)\par
setWaterFullDepth( float depth ) - sets WaterFullDepth to "depth"-lower values result in water becoming opaque faster as the water gets deeper.\par
setAlphaWaterOffset( float offset ) - sets the water alpha offset (added to tweak water alpha near the shore).\par
==================================================\par
isPaused() - returns true if the game is paused (else false).\par
setPaused(bool pause) - if true, the game is paused, else unpaused.\par
getGameTime() - returns the amount of time elapsed since the start of the game.\par
\par
\par
\par
\par
\par
\par
\par
\f1\fs20\par
\pard\f2\par
}