Difference between revisions of "Global Functions"
Shadlington (Talk | contribs) |
Shadlington (Talk | contribs) |
||
Line 1: | Line 1: | ||
<onlyinclude> | <onlyinclude> | ||
− | + | Global functions are functions that are globally available to be called by any script. | |
</onlyinclude> | </onlyinclude> | ||
− | + | This is a list of all of the global functions provided by the KAG application (that is, not defined in a script). | |
{| class="wikitableShiny" border="1" | {| class="wikitableShiny" border="1" |
Revision as of 18:33, 14 August 2012
Global functions are functions that are globally available to be called by any script.
This is a list of all of the global functions provided by the KAG application (that is, not defined in a script).
Function | Description |
---|---|
Blobs | |
CreateBlob |
Creates a CBlob with the given factory and the given path to a config file defining the CBlob. Returns a reference to the created CBlob. |
getBlob |
Returns a reference to the CBlob with the given index in the list of blobs that currently exist. |
getBlobByNetworkId |
Returns a reference to the CBlob with the given Network ID. |
getBlobByName |
Returns a reference to the first CBlob with the given name. Probably not very useful. |
getPlayingBlobsSize |
Returns the number of CBlobs that are currently active and in play - i.e. not settled map blocks or in inventories. |
getBlobSize |
Returns the number of CBlobs that currently exist. |
Inventory | |
AddRequirement |
Pushes the given requirements to a CBitStream, to be read by other requirement methods. |
ReadRequirement |
Reads requirements from the given CBitStream into variables you provide. |
hasRequirements |
Checks 1 or 2 inventories to see if they have the given requirements, and writes any missing requirements into a given CBitStream. Returns true if the requirements are met, otherwise false. |
TakeRequirementsCombined |
Removes the requirements in the given CBitStream from one of the CInventorys passed to it. |
GUI | |
LoadSkin |
Loads a skin config file. See GUI/guiSkin.cfg for example file. |
DrawPane |
Draws a pane with a shape specified by the given rect. |
DrawSunkenPane |
Draws a sunken pane with a shape specified by the given rect. |
DrawWindow |
Draws a window with a shape specified by the given rect. |
DrawFramedPane |
Draws a framed pane with a shape specified by the given rect. |
DrawButton |
Draws a button with a shape specified by the given rect. |
DrawButtonPressed |
Draws a pressed button with a shape specified by the given rect. |
DrawButtonHover |
Draws a hover-highlighted button with a shape specified by the given rect. |
DrawRectangle |
Draws a rectangle with a shape specified by the given rect. |
DrawProgressBar |
Draws a progress bar with a shape specified by the given rect and a given % fill. |
DrawIconByName |
Draws an icon added by AddIconToken using its token name. |
DrawIcon |
Draws an icon from the given file. |
DrawText |
Draws some text. |
Maths | |
Cos |
Returns the cosine of the given angle in radians. |
FastCos |
Returns the cosine of the given angle in radians. Faster, less reliable version. |
ACos |
Returns the arc cosine of the given angle in radians. |
Sin |
Returns the sine of the given angle in radians. |
FastSin |
Returns the sine of the given angle in radians. Faster, less reliable version. |
ASin |
Returns the arc sine of the given angle in radians. |
Tan |
Returns the tangent of the given angle in radians. |
ATan |
Returns the arc tangent of the given angle in radians. |
Pow |
Returns base raised to the power exponent. |
Sqrt |
Returns the square root of x. |
FastSqrt | FastSqrt |
InvSqrt |
Returns the inverse square root of x. |
isValid |
Returns true if the given float is a valid number (not NaN or infinity) or not. |
Floor |
Returns the largest integral value that is not greater than the given number. |
Ceil |
Returns the smallest integral value that is not less than the given number. |
Equals |
Returns true if the two given floats are equal, otherwise false. |
Min |
Returns the smaller of the two given numbers. |
Max |
Returns the larger of the two given numbers. |
Abs |
Returns the absolute value of the given number. |
FMod |
Returns the floating-point remainder of the given numerator divided by the given denominator. |
Round |
Rounds the given float to the nearest whole number, as an int. |
Roundf |
Rounds the given float to the nearest whole number, as a float. |
get256DegreesFrom360 | Get256DegreesFrom360 |
get360DegreesFrom256 | Get360DegreesFrom256 |
Random |
Returns a pseudo-random int in the range 0 to the given max int. |
FastRandom |
Returns a seemingly-random (much less random than Random, though it is faster) int in the range 0 to the given max int. |
Strings | |
formatInt |
Returns a formatted string representation of the given int. |
formatFloat |
Returns a formatted string representation of the given float. |
parseInt |
Returns an int from the given string representation of an int. |
parseFloat |
Returns a double from the given string representation of an float. |
Printing | |
Prints the given text - to the console, if its available. | |
printf | Printf |
printInt |
Prints the given integer with the given prefix text - to the console, if its available. |
printFloat |
Prints the given float with the given prefix text - to the console, if its available. |
printString |
Prints the given string with the given prefix text - to the console, if its available. |
printVec2f |
Prints the given Vec2f with the given prefix text - to the console, if its available. |
printBool |
Prints the given bool with the given prefix text - to the console, if its available. |
printPos |
Prints the given position2d with the given prefix text - to the console, if its available. |
printPosition2di | PrintPosition2di |
error |
Prints an error with the given text - to the console, if its available. |
warn | Warn |
warning |
Prints a warning with the given text - to the console, if its available. |
World | |
getMap |
Returns a reference to the CMap object. |
getRules |
Returns a reference to the CRules object. |
getRespawn |
Returns a reference to the CRespawn object. |
getHUD |
Returns a reference to the CHUD object. |
getNet |
Returns a reference to the CNet object. |
getCamera |
Returns a reference to the CCamera object. |
getControls |
Returns a reference to the CControls object. |
getDriver |
Returns a reference to the CNet object. |
LoadRules |
Loads the given rules config file. |
LoadMap |
Loads the given map file. |
LoadNextMap |
Loads the next map in the map cycle. |
LoadMapCycle |
Loads the given map cycle file. |
getGameTime |
Returns the game time (number of ticks) as an integer (s32). |
Misc | |
AddIconMarker |
This defines a token (e.g. $EmptyShop$) for icon replacement in menus and suchlike. |
AddColorMarker |
This defines a token (e.g. $RED$) for colouring text in menus and suchlike. |
CreateGridMenu |
Creates a CGridMenu with the given position on-screen, a reference to the owner blob, the grid dimensions and a caption. Returns a reference to the created CGridMenu. |
makeAnimatedParticle |
Creates a particle with a number of different options. |
makeAnimatedParticle |
Creates a particle with a number of different options. |
Play |
Plays the a sound file at the given position (position used to determine if it can be heard). |