Script functions
This page is incomplete.
This page documents all scripts available in Amnesia: The Dark Descent.
Entry point hooks
The following functions are the main hps functions that the HPL2 engine looks to run on certain events - similar to the C++ int main() function.
void OnStart();
The function that runs only when the map is loaded for the first time.
void OnEnter();
The function that runs each time the player enters the map, including the first time.
void OnLeave();
The function that runs each time the player leaves the map.
void OnUpdate(float afStep);
The function that runs every time the game updates - usually 60 times per second. Generally only used for very specialized purposes that require constant synchronization with the game loop. Use with caution as complex logic can impact performance.
void OnGameStart();
This function only applies to global.hps
and inventory.hps
.
Is it run only once, similarly to OnStart
, but is not associated with a map. It runs when the game is first started by the player (such as via "Start new game").
Math
float RandFloat(float afMin, float afMax);
Generates a random float.
- afMin - minimum value, inclusive.
- afMax - maximum value, inclusive.
int RandInt(int alMin, int alMax);
Generates a random int. Note: the maximum value is inclusive - the RandInt() function may return this value.
- alMin - minimum value
- alMax - maximum value
bool StringContains(string& asString, string& asSubString);
Checks whether a string contains the specified string. Example: searching for "hello" in "hello world" would return true.
- asString - the string to check
- asSubString - the string to search for
string& StringSub(string& asString, int alStart, int alCount);
Returns the substring in a string. Example: in the string "frictional games rocks", using 4 as alStart and 6 as alCount would return "tional".
- asString - the string
- alStart - start position in the string
- alCount - amount of characters
int StringToInt(string&in asString);
If possible, returns an integer converted from a string, else returns 0.
asString
- String to convert.