Difference between revisions of "Common Script External Code"

From Wolfire Games Wiki
Jump to: navigation, search
m (ASContext class)
m (DebugText function)
 
(57 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Category: Modding]]
 +
[[Category:Overgrowth]]
 
This is a list of the external code that is available inside all scripts - variables, functions, and classes that "magically" exist.
 
This is a list of the external code that is available inside all scripts - variables, functions, and classes that "magically" exist.
  
To see a list of external code that is available only in specific scripts, please see the corresponding page page - [[Level Script External Code]] [[Character Script External Code]]
+
To see a list of external code that is available only in specific scripts, please see the corresponding page:
  
This list is pulled from the ~/Documents/Wolfire/Overgrowth/ directory, from the aschar_docs.h and aslevel_docs.h files, which are automatically generated by the game.
+
* [[Level Script External Code]]
 +
* [[Level Script External Code|Hotspot Script External Code]] (hotspots share level script code - '''read carefully to see what code doesn't apply!''')
 +
* [[Character Script External Code]]
 +
* [[Editor Camera Script External Code]]
 +
 
 +
'''Note''': The editor camera script cannot use some of the data and functions defined below - '''read this page carefully to see what code doesn't apply'''!
 +
 
 +
This list is pulled from the <code>~/Documents/Wolfire/Overgrowth/</code> directory, from the aschar_docs.h and aslevel_docs.h files, which are automatically generated by the game.
  
 
See this page to find the location for the Wolfire/Overgrowth folder on each OS - [[How to clear the game's cache]]
 
See this page to find the location for the Wolfire/Overgrowth folder on each OS - [[How to clear the game's cache]]
  
'''TODO''': These can be documented individually, possibly on their own pages - or maybe as just subsections?
+
'''TODO''': Finish documenting the rest of the classes, and lists of related global functions
  
'''TODO''': Provide different groupings as well? Might be fine to duplicate them into feature sections of this page or another page.
+
'''TODO''': It's possible some of these might not work in hotspot scripts. If you find that to be the case, please copy a function to level scripts/character scripts and remove it from here.
  
'''TODO''': It's possible some of these might not work in hotspot scripts. If you find that to be the case, please copy a function to level scripts/character scripts and remove it from here.
+
'''TODO''': Missing TokenIterator definition - note, cannot be used from the editor camera script, but can from level scripts, movement object scripts, hotspot scripts
  
 
== Global Variables ==
 
== Global Variables ==
Line 17: Line 26:
 
<pre style="white-space: pre-wrap;">Camera camera;</pre>
 
<pre style="white-space: pre-wrap;">Camera camera;</pre>
 
<pre style="white-space: pre-wrap;">CharacterScriptGetter character_getter;</pre>
 
<pre style="white-space: pre-wrap;">CharacterScriptGetter character_getter;</pre>
<pre style="white-space: pre-wrap;">ASContext context;</pre>
+
<pre style="white-space: pre-wrap;">ASContext context; // The context for the currently running script, whether that is the menu script, level script, character script, or hotspot script</pre>
 
<pre style="white-space: pre-wrap;">float last_controller_event_time;  // The time the last game controller input event occurred</pre>
 
<pre style="white-space: pre-wrap;">float last_controller_event_time;  // The time the last game controller input event occurred</pre>
 
<pre style="white-space: pre-wrap;">float last_keyboard_event_time;  // The time the last keyboard input event occurred</pre>
 
<pre style="white-space: pre-wrap;">float last_keyboard_event_time;  // The time the last keyboard input event occurred</pre>
Line 41: Line 50:
 
     kPreviewCamera,
 
     kPreviewCamera,
 
};</pre>
 
};</pre>
 +
=== DebugDrawLifespanType enum ===
 
<pre style="white-space: pre-wrap;">enum DebugDrawLifespanType : int {
 
<pre style="white-space: pre-wrap;">enum DebugDrawLifespanType : int {
 
     _delete_on_draw,
 
     _delete_on_draw,
Line 47: Line 57:
 
     _persistent,
 
     _persistent,
 
};</pre>
 
};</pre>
 +
 +
Used for specifying how long a debug draw object that you create should stick around. Usually the last argument to one of those calls.
 +
 +
Different lifespans are useful for different scenarios:
 +
 +
* '''<code>_delete_on_draw</code>''' - The engine will automatically delete this debug draw object the next time Draw gets called. Recommended if your debug draw object gets created every time inside a Draw function, e.g. <code>DrawGui</code>. You might choose to use this instead of '''<code>_delete_on_update</code>''' so you can get smooth per-frame interpolation of the positions for the line you are drawing.
 +
 +
* '''<code>_delete_on_update</code>''' - The engine will automatically delete this debug draw object the next time Update gets called. Recommended if your debug draw object gets created every time inside <code>Update</code>. You might choose to use this instead of '''<code>_delete_on_draw</code>''' inside an enemy character script so you have less code running less frequently (since update is called at 30hz for enemy control scripts).
 +
 +
* '''<code>_fade</code>''' - The engine will automatically delete this debug draw object after a few frames, and make it fade out. Recommended if your debug draw object is triggered sporadically, rather than every frame or every update, and you want the results to stick around on screen for a few updates/frames.
 +
 +
* '''<code>_persistent</code>''' - The engine will automatically delete this debug draw object when you leave the level. This tells the engine that you would prefer to delete this object manually. If you use this value, then make sure to hold onto the return value from the call to <code>DebugDraw*</code>. Recommended if you want to draw a line that shows up while in-game, isn't moving around a lot (unless you're using the editor to move the object), and isn't conditional. If the display should be conditional, or the line is expected to move around quite frequently (every update or every frame), then one of the other values might make more sense, unless you're trying to conserve CPU time in your <code>Update</code> or <code>Draw*</code> function.
 
<pre style="white-space: pre-wrap;">enum EngineState {
 
<pre style="white-space: pre-wrap;">enum EngineState {
 
     kEngineNoState,
 
     kEngineNoState,
Line 102: Line 124:
 
     spam,
 
     spam,
 
};</pre>
 
};</pre>
<pre style="white-space: pre-wrap;">enum MessageType : int {
+
<pre style="white-space: pre-wrap;">enum MessageType : int { // Note, not available in the editor camera script
 
     _editor_msg;
 
     _editor_msg;
 
     _plant_movement_msg;
 
     _plant_movement_msg;
Line 149: Line 171:
  
 
== Global Functions ==
 
== Global Functions ==
 
+
=== Math Functions ===
 
<pre style="white-space: pre-wrap;">float abs(float);</pre>
 
<pre style="white-space: pre-wrap;">float abs(float);</pre>
 
<pre style="white-space: pre-wrap;">float acos(float);</pre>
 
<pre style="white-space: pre-wrap;">float acos(float);</pre>
Line 156: Line 178:
 
<pre style="white-space: pre-wrap;">float atan(float);</pre>
 
<pre style="white-space: pre-wrap;">float atan(float);</pre>
 
<pre style="white-space: pre-wrap;">float atan2(float, float);</pre>
 
<pre style="white-space: pre-wrap;">float atan2(float, float);</pre>
<pre style="white-space: pre-wrap;">float atof(const string &in str);</pre>
+
<pre style="white-space: pre-wrap;">float atof(const string &in str); // Note, not callable from the editor camera script</pre>
<pre style="white-space: pre-wrap;">int atoi(const string &in str);</pre>
+
<pre style="white-space: pre-wrap;">int atoi(const string &in str); // Note, not callable from the editor camera script</pre>
 
<pre style="white-space: pre-wrap;">float ceil(float);</pre>
 
<pre style="white-space: pre-wrap;">float ceil(float);</pre>
 
<pre style="white-space: pre-wrap;">float cos(float);</pre>
 
<pre style="white-space: pre-wrap;">float cos(float);</pre>
Line 194: Line 216:
 
<pre style="white-space: pre-wrap;">float xz_distance_squared(const vec3 &in, const vec3 &in);
 
<pre style="white-space: pre-wrap;">float xz_distance_squared(const vec3 &in, const vec3 &in);
 
// Get the squared distance on the x/z plane between two vec3 values (flat. faster than xz_distance function, no square-root done)</pre>
 
// Get the squared distance on the x/z plane between two vec3 values (flat. faster than xz_distance function, no square-root done)</pre>
<pre style="white-space: pre-wrap;">void ActivateKeyboardEvents();</pre>
+
<pre style="white-space: pre-wrap;">void GetRotationBetweenVectors(const vec3 &in start, const vec3 &in end, quaternion &out rotation); // Get a relative rotation from one direction vector to another</pre>
<pre style="white-space: pre-wrap;">void AddDebugDrawRibbonPoint(int which, vec3 pos, vec4 color, float width);</pre>
+
<pre style="white-space: pre-wrap;">mat3 Mat3FromQuaternion(const quaternion &in); // Convert a quaternion to its corresponding 3x3 rotation matrix</pre>
<pre style="white-space: pre-wrap;">bool AddMusic(const string &in);</pre>
+
<pre style="white-space: pre-wrap;">mat4 Mat4FromQuaternion(const quaternion &in); // Convert a quaternion to its corresponding 4x4 rotation matrix</pre>
<pre style="white-space: pre-wrap;">void Breakpoint(int);</pre>
+
<pre style="white-space: pre-wrap;">vec3 Mult(quaternion, vec3); // Applies a quaternion rotation to a vector</pre>
<pre style="white-space: pre-wrap;">bool CheckSaveLevelChanges();</pre>
+
<pre style="white-space: pre-wrap;">quaternion QuaternionFromMat4(const mat4 &in); // Convert a 4x4 matrix to its corresponding quaternion</pre>
<pre style="white-space: pre-wrap;">void ClearTemporaryDecals(); // Like blood splats and footprints</pre>
+
<pre style="white-space: pre-wrap;">float RangedRandomFloat(float min, float max);</pre>
<pre style="white-space: pre-wrap;">void ClearUndoHistory();</pre>
+
 
<pre style="white-space: pre-wrap;">void ConnectParticles(uint32 id_a, uint32 id_b); // Used for ribbon particles, like throat-cut blood</pre>
+
=== String Functions ===
<pre style="white-space: pre-wrap;">void CreateCustomHull(const string &in key, const array<vec3> &vertices);</pre>
+
<pre style="white-space: pre-wrap;">string FloatString(float val, int digits);</pre>
 +
<pre style="white-space: pre-wrap;">uint GetCodepointCount( const string &in );</pre>
 +
<pre style="white-space: pre-wrap;">string ToUpper(string &in);</pre>
 +
=== Game Object Functions ===
 
<pre style="white-space: pre-wrap;">int CreateObject(const string &in path);</pre>
 
<pre style="white-space: pre-wrap;">int CreateObject(const string &in path);</pre>
 
<pre style="white-space: pre-wrap;">int CreateObject(const string &in path, bool exclude_from_save);</pre>
 
<pre style="white-space: pre-wrap;">int CreateObject(const string &in path, bool exclude_from_save);</pre>
<pre style="white-space: pre-wrap;">void DeactivateAllMods();</pre>
 
<pre style="white-space: pre-wrap;">void DeactivateKeyboardEvents();</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawBillboard(const string &in path, vec3 center, float scale, vec4 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawCircle(mat4 transform, vec4 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawLine(vec3 start, vec3 end, vec3 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawLine(vec3 start, vec3 end, vec3 start_color, vec3 end_color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawLine(vec3 start, vec3 end, vec4 start_color, vec4 end_color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawLines(const array<vec3> &vertices, vec4 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawPoint(vec3 pos, vec4 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">void DebugDrawRemove(int id);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawRibbon(int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawRibbon(vec3 start, vec3 end, vec4 start_color, vec4 end_color, float start_width, float end_width, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawText(vec3 pos, string text, float scale, bool screen_space, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawWireBox(vec3 pos, vec3 dimensions, vec3 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawWireCylinder(vec3 pos, float radius, float height, vec3 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawWireMesh(string path, mat4 transform, vec4 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawWireScaledSphere(vec3 pos, float radius, vec3 scale, vec3 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawWireScaledSphere(vec3 pos, float radius, vec3 scale, vec4 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">int DebugDrawWireSphere(vec3 pos, float radius, vec3 color, int lifespan);</pre>
 
<pre style="white-space: pre-wrap;">bool DebugKeysEnabled();</pre>
 
 
<pre style="white-space: pre-wrap;">int DebugSetPosition(int id, vec3 pos);</pre>
 
<pre style="white-space: pre-wrap;">int DebugSetPosition(int id, vec3 pos);</pre>
<pre style="white-space: pre-wrap;">void DebugText(string key, string display_text, float lifetime);</pre>
 
 
<pre style="white-space: pre-wrap;">void DeleteObjectID(int);</pre>
 
<pre style="white-space: pre-wrap;">void DeleteObjectID(int);</pre>
<pre style="white-space: pre-wrap;">void DeselectAll();</pre>
 
<pre style="white-space: pre-wrap;">void DisplayError(const string &in title, const string &in contents);</pre>
 
<pre style="white-space: pre-wrap;">void DisposeTextAtlases();</pre>
 
 
<pre style="white-space: pre-wrap;">bool DoesItemFitInItem(int item_id, int holster_item_id);</pre>
 
<pre style="white-space: pre-wrap;">bool DoesItemFitInItem(int item_id, int holster_item_id);</pre>
<pre style="white-space: pre-wrap;">void DrawTextAtlas(const string &in path, int pixel_height, int flags, const string &in txt, int x, int y, vec4 color);</pre>
 
<pre style="white-space: pre-wrap;">void DrawTextAtlas2(const string &in path, int pixel_height, int flags, const string &in txt, int x, int y, vec4 color, uint char_limit);</pre>
 
 
<pre style="white-space: pre-wrap;">int DuplicateObject(Object@ obj);</pre>
 
<pre style="white-space: pre-wrap;">int DuplicateObject(Object@ obj);</pre>
<pre style="white-space: pre-wrap;">bool EditorEnabled();</pre>
 
<pre style="white-space: pre-wrap;">bool EditorModeActive();</pre>
 
<pre style="white-space: pre-wrap;">void EnterTelemetryZone(const string &in name);</pre>
 
<pre style="white-space: pre-wrap;">bool FileExists(string &in);</pre>
 
 
<pre style="white-space: pre-wrap;">int FindFirstCharacterInGroup(int id);</pre>
 
<pre style="white-space: pre-wrap;">int FindFirstCharacterInGroup(int id);</pre>
<pre style="white-space: pre-wrap;">string FloatString(float val, int digits);</pre>
 
<pre style="white-space: pre-wrap;">array<ModID>@ GetActiveModSids();</pre>
 
<pre style="white-space: pre-wrap;">array<string>@ GetAvailableBindingCategories();</pre>
 
<pre style="white-space: pre-wrap;">array<string>@ GetAvailableBindings(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">vec3 GetBaseSkyTint();</pre>
 
<pre style="white-space: pre-wrap;">string GetBindingValue(string binding_category, string binding);</pre>
 
<pre style="white-space: pre-wrap;">int GetBloodLevel();</pre>
 
<pre style="white-space: pre-wrap;">const vec3& GetBloodTint();</pre>
 
<pre style="white-space: pre-wrap;">string GetBuildTimestamp( );</pre>
 
<pre style="white-space: pre-wrap;">string GetBuildVersionFull( );</pre>
 
<pre style="white-space: pre-wrap;">string GetBuildVersionShort( );</pre>
 
<pre style="white-space: pre-wrap;">Campaign GetCampaign(string& campaign_id);</pre>
 
<pre style="white-space: pre-wrap;">array<Campaign>@ GetCampaigns();</pre>
 
 
<pre style="white-space: pre-wrap;">void GetCharacters(array<int>@ id_array);</pre>
 
<pre style="white-space: pre-wrap;">void GetCharacters(array<int>@ id_array);</pre>
 +
<pre style="white-space: pre-wrap;">int GetNumCharacters();</pre>
 +
<pre style="white-space: pre-wrap;">int GetNumHotspots();</pre>
 +
<pre style="white-space: pre-wrap;">int GetNumItems();</pre>
 +
<pre style="white-space: pre-wrap;">array<int>@ GetObjectIDs();</pre>
 +
<pre style="white-space: pre-wrap;">array<int>@ GetObjectIDsType(int type);</pre>
 +
<pre style="white-space: pre-wrap;">bool IsGroupDerived(int id);</pre>
 +
<pre style="white-space: pre-wrap;">bool MovementObjectExists(int id);</pre>
 +
<pre style="white-space: pre-wrap;">bool ObjectExists();</pre>
 +
<pre style="white-space: pre-wrap;">bool ObjectExists(int id);</pre>
 +
<pre style="white-space: pre-wrap;">void QueueDeleteObjectID(int);</pre>
 +
<pre style="white-space: pre-wrap;">MovementObject@ ReadCharacter(int index);  // e.g. first character in scene</pre>
 +
<pre style="white-space: pre-wrap;">MovementObject@ ReadCharacterID(int id);  // e.g. character with object ID 39</pre>
 +
<pre style="white-space: pre-wrap;">EnvObject@ ReadEnvObjectID(int id);</pre>
 +
<pre style="white-space: pre-wrap;">Hotspot@ ReadHotspot(int index);</pre>
 +
<pre style="white-space: pre-wrap;">ItemObject@ ReadItem(int index);</pre>
 +
<pre style="white-space: pre-wrap;">ItemObject@ ReadItemID(int id);</pre>
 +
<pre style="white-space: pre-wrap;">Object@ ReadObjectFromID(int);</pre>
 +
=== Physics Functions ===
 +
<pre style="white-space: pre-wrap;">void CreateCustomHull(const string &in key, const array<vec3> &vertices);</pre>
 
<pre style="white-space: pre-wrap;">void GetCharactersInHull(string model_path, mat4, array<int>@ id_array);</pre>
 
<pre style="white-space: pre-wrap;">void GetCharactersInHull(string model_path, mat4, array<int>@ id_array);</pre>
 
<pre style="white-space: pre-wrap;">void GetCharactersInSphere(vec3 position, float radius, array<int>@ id_array);</pre>
 
<pre style="white-space: pre-wrap;">void GetCharactersInSphere(vec3 position, float radius, array<int>@ id_array);</pre>
<pre style="white-space: pre-wrap;">int GetCodeForKey(string key_name);</pre>
+
<pre style="white-space: pre-wrap;">float GetFriction(const vec3 &in position);</pre>
<pre style="white-space: pre-wrap;">uint GetCodepointCount( const string &in );</pre>
+
<pre style="white-space: pre-wrap;">void GetObjectsInHull(string model_path, mat4, array<int>@ id_array);</pre>
 +
=== Script Message Functions ===
 +
<pre style="white-space: pre-wrap;">void SendGlobalMessage(string msg);  // Note, not callable from the editor camera script</pre>
 +
<pre style="white-space: pre-wrap;">void SendMessage(int target, int type, vec3 vec_a, vec3 vec_b);  // Note, not callable from the editor camera script</pre>
 +
<pre style="white-space: pre-wrap;">void SendMessage(int type, string msg);  // Note, not callable from the editor camera script</pre>
 +
 
 +
=== Particle and Decal Functions ===
 +
<pre style="white-space: pre-wrap;">void ClearTemporaryDecals();  // Like blood splats and footprints</pre>
 +
<pre style="white-space: pre-wrap;">void ConnectParticles(uint32 id_a, uint32 id_b);  // Used for ribbon particles, like throat-cut blood</pre>
 +
<pre style="white-space: pre-wrap;">int GetBloodLevel();</pre>
 +
<pre style="white-space: pre-wrap;">const vec3& GetBloodTint();</pre>
 +
<pre style="white-space: pre-wrap;">uint32 MakeParticle(string path, vec3 pos, vec3 vel);</pre>
 +
<pre style="white-space: pre-wrap;">uint32 MakeParticle(string path, vec3 pos, vec3 vel, vec3 color);</pre>
 +
<pre style="white-space: pre-wrap;">void TintParticle(uint32 id, const vec3 &in color);</pre>
 +
=== Scene Access Functions ===
 +
<pre style="white-space: pre-wrap;">vec3 GetBaseSkyTint();</pre>
 +
<pre style="white-space: pre-wrap;">float GetHDRBlackPoint(void);</pre>
 +
<pre style="white-space: pre-wrap;">float GetHDRBloomMult(void);</pre>
 +
<pre style="white-space: pre-wrap;">float GetHDRWhitePoint(void);</pre>
 +
<pre style="white-space: pre-wrap;">vec3 GetSkyTint();</pre>
 +
<pre style="white-space: pre-wrap;">float GetSunAmbient();</pre>
 +
<pre style="white-space: pre-wrap;">vec3 GetSunColor();</pre>
 +
<pre style="white-space: pre-wrap;">vec3 GetSunPosition();</pre>
 +
<pre style="white-space: pre-wrap;">void SetFlareDiffuse(float);</pre>
 +
<pre style="white-space: pre-wrap;">void SetHDRBlackPoint(float);</pre>
 +
<pre style="white-space: pre-wrap;">void SetHDRBloomMult(float);</pre>
 +
<pre style="white-space: pre-wrap;">void SetHDRWhitePoint(float);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSkyTint(vec3);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSunAmbient(float);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSunColor(vec3);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSunPosition(vec3);</pre>
 +
=== Text Drawing Functions ===
 +
<pre style="white-space: pre-wrap;">void DrawTextAtlas(const string &in path, int pixel_height, int flags, const string &in txt, int x, int y, vec4 color);</pre>
 +
<pre style="white-space: pre-wrap;">void DrawTextAtlas2(const string &in path, int pixel_height, int flags, const string &in txt, int x, int y, vec4 color, uint char_limit);</pre>
 +
<pre style="white-space: pre-wrap;">void DisposeTextAtlases();</pre>
 +
<pre style="white-space: pre-wrap;">int GetFontFaceID(const string &in path, int pixel_height);</pre>
 +
<pre style="white-space: pre-wrap;">uint GetLengthInBytesForNCodepoints( const string &in, uint codepoint_index );</pre>
 +
<pre style="white-space: pre-wrap;">TextMetrics GetTextAtlasMetrics(const string &in path, int pixel_height, int flags, const string &in txt );</pre>
 +
<pre style="white-space: pre-wrap;">TextMetrics GetTextAtlasMetrics2(const string &in path, int pixel_height, int flags, const string &in txt, uint char_limit );</pre>
 +
=== Sound and Music Functions ===
 +
<pre style="white-space: pre-wrap;">bool AddMusic(const string &in);</pre>
 +
<pre style="white-space: pre-wrap;">float GetLayerGain(const string &in layer);</pre>
 +
<pre style="white-space: pre-wrap;">array<string>@ GetLayerNames();</pre>
 +
<pre style="white-space: pre-wrap;">string GetSegment();</pre>
 +
<pre style="white-space: pre-wrap;">string GetSong();</pre>
 +
<pre style="white-space: pre-wrap;">void PlaySegment(const string &in);</pre>
 +
<pre style="white-space: pre-wrap;">void PlaySong(const string &in);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySound(string path);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySound(string path, vec3 position);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path, float gain);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path, vec3 position);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path, vec3 position, float gain);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path, vec3 position, int priority);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySoundLoop(const string &in path, float gain);</pre>
 +
<pre style="white-space: pre-wrap;">int PlaySoundLoopAtLocation(const string &in path, vec3 pos, float gain);</pre>
 +
<pre style="white-space: pre-wrap;">void QueueSegment(const string &in);</pre>
 +
<pre style="white-space: pre-wrap;">bool RemoveMusic(const string &in);</pre>
 +
<pre style="white-space: pre-wrap;">void SetAirWhoosh(float volume, float pitch);</pre>
 +
<pre style="white-space: pre-wrap;">void SetLayerGain(const string &in layer, float gain);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSegment(const string &in);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSong(const string &in);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSoundGain(int handle, float gain);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSoundPitch(int handle, float pitch);</pre>
 +
<pre style="white-space: pre-wrap;">void SetSoundPosition(int handle, vec3 pos);</pre>
 +
<pre style="white-space: pre-wrap;">void StopSound(int handle);</pre>
 +
<pre style="white-space: pre-wrap;">void UpdateListener(vec3 pos, vec3 vel, vec3 facing, vec3 up);</pre>
 +
=== Gameplay State Functions ===
 +
<pre style="white-space: pre-wrap;">bool GetMenuPaused();  // Is game paused by a menu</pre>
 +
<pre style="white-space: pre-wrap;">void ResetLevel();  // Queue a level reset, including respawns, such as after a death</pre>
 +
=== Time Manipulation Functions ===
 +
<pre style="white-space: pre-wrap;">void TimedSlowMotion(float target_time_scale, float how_long, float delay);  // Used to trigger brief periods of slow motion</pre>
 +
<pre style="white-space: pre-wrap;">void SetPaused(bool paused);</pre>
 +
=== Config Access Functions ===
 
<pre style="white-space: pre-wrap;">bool GetConfigValueBool(string index);</pre>
 
<pre style="white-space: pre-wrap;">bool GetConfigValueBool(string index);</pre>
 
<pre style="white-space: pre-wrap;">float GetConfigValueFloat(string index);</pre>
 
<pre style="white-space: pre-wrap;">float GetConfigValueFloat(string index);</pre>
Line 263: Line 337:
 
<pre style="white-space: pre-wrap;">array<string>@ GetConfigValueOptions(string index);</pre>
 
<pre style="white-space: pre-wrap;">array<string>@ GetConfigValueOptions(string index);</pre>
 
<pre style="white-space: pre-wrap;">string GetConfigValueString(string index);</pre>
 
<pre style="white-space: pre-wrap;">string GetConfigValueString(string index);</pre>
 +
<pre style="white-space: pre-wrap;">void ReloadStaticValues();</pre>
 +
<pre style="white-space: pre-wrap;">string SaveConfig();</pre>
 +
<pre style="white-space: pre-wrap;">void SetConfigValueBool(string key, bool value);</pre>
 +
<pre style="white-space: pre-wrap;">void SetConfigValueFloat(string key, float value);</pre>
 +
<pre style="white-space: pre-wrap;">void SetConfigValueInt(string key, int value);</pre>
 +
<pre style="white-space: pre-wrap;">void SetConfigValueString(string key, string value);</pre>
 +
=== Debug Functions ===
 +
These functions allow you to create artifacts to help you debug scripts and game beahvior.
 +
 +
With them you can write to the logfile, print to the debug window, draw in-game (and/or in-editor) 3D objects, do basic profiling of scripts, and get build information.
 +
<pre style="white-space: pre-wrap;">void AddDebugDrawRibbonPoint(int which, vec3 pos, vec4 color, float width);</pre>
 +
<pre style="white-space: pre-wrap;">void Breakpoint(int);</pre>
 +
==== DebugDrawBillboard function ====
 +
<pre style="white-space: pre-wrap;">int DebugDrawBillboard(const string &in path, vec3 center, float scale, vec4 color, DebugDrawLifespanType lifespan);</pre>
 +
Draw an image that exists in the 3D world space (as opposed to being a 2D HUD overlay image). This image is rotated to face the camera, and will scale when you get closer to it (since it lives in 3D).
 +
 +
The '''<code>return value</code>''' is an id that you can pass to [[#DebugDrawRemove function|'''<code>DebugDrawRemove</code>''']] to delete the object at a future time.
 +
 +
Parameters:
 +
* '''<code>path</code>''' - The path to the file that contains this image. Should be specified relative to the game install directory (e.g. <code>Data/Textures/ui/stealth_debug/exclamation.tga</code>)
 +
 +
* '''<code>center</code>''' - The origin of the billboard image in 3D space. The center of the image will sit on this point.
 +
 +
* '''<code>scale</code>''' - The relative size of the image. Set to <code>1.0</code> to start with, and change it from there if need be. '''WARNING''': The scale parameter might not do anything right now. ('''TODO''': Verify, and remove this warning if you find out that the scale parameter actually does work, or remove this todo if it doesn't work)
 +
 +
* '''<code>color</code>''' - The RGBA tint you want to apply to the object. You can use this to make the object transparent if you set the value to <code>vec4(1.0, 1.0, 1.0, alpha_value_between_0_and_1)</code>.
 +
 +
* '''<code>lifespan</code>''' - How long you would like this billboard to stick around before it automatically gets deleted by the engine. See [[#DebugDrawLifespanType enum|'''<code>DebugDrawLifespanType</code>''']] for the values you can pass here.<br>Note that you can't move billboards around, so you might need to set a lifetime lower that <code>_persistent</code>, and call draw repeatedly, depending on how often you expect your object to move.
 +
 +
==== DebugDrawCircle function ====
 +
<pre style="white-space: pre-wrap;">int DebugDrawCircle(mat4 transform, vec4 color, DebugDrawLifespanType lifespan);</pre>
 +
Draw a circle that exists in the 3D world space (as opposed to being a 2D HUD overlay circle shape).
 +
 +
The '''<code>return value</code>''' is an id that you can pass to [[#DebugDrawRemove function|'''<code>DebugDrawRemove</code>''']] to delete the object at a future time.
 +
 +
Parameters:
 +
* '''<code>transform</code>''' - The transformation matrix describing the translation, rotation, and scale of the circle. '''TODO''': What shape is the circle if the identity matrix is passed? Where its origin (center of the cirlce?), and which plane will it lie on?
 +
 +
* '''<code>color</code>''' - The color to draw the entire circle. You can specify transparency using an alpha value between 0.0 (fully transparent, and thus invisible) and 1.0 (fully opaque).
 +
 +
* '''<code>lifespan</code>''' - How long you would like this circle to stick around before it automatically gets deleted by the engine. See [[#DebugDrawLifespanType enum|'''<code>DebugDrawLifespanType</code>''']] for the values you can pass here.<br>Note that you can't move debug draw circles around, so you might need to set a lifetime lower that <code>_persistent</code>, and call draw repeatedly, depending on how often you expect your object to move.
 +
 +
==== DebugDrawLine function ====
 +
<pre style="white-space: pre-wrap;">int DebugDrawLine(vec3 start, vec3 end, vec3 color, DebugDrawLifespanType lifespan);</pre>
 +
Draw a line that exists in the 3D world space (as opposed to being a 2D HUD overlay line). This line will be opaque, and will only have a single color over the entire span of the line.
 +
 +
The '''<code>return value</code>''' is an id that you can pass to [[#DebugDrawRemove function|'''<code>DebugDrawRemove</code>''']] to delete the object at a future time.
 +
 +
Parameters:
 +
* '''<code>start</code>''' - The point in 3D space of the beginning of the line. The line will begin at this point. (If you're confused about start/end, then don't worry about it. There isn't really a distinction between the two points).
 +
 +
* '''<code>end</code>''' - The point in 3D space of the end of the line. The line will end at this point. (If you're confused about start/end, then don't worry about it. There isn't really a distinction between the two points).
 +
 +
* '''<code>color</code>''' - The color to draw the entire line. This will be an opaque color.<br>If you want to have different colors down the length of the line, see [[#DebugDrawLine function (multiple colors)|the '''<code>DebugDrawLine</code>''' overload that supports multiple colors]].<br>If you want to draw a line that has transparency, see [[#DebugDrawLine function (transparent)|the '''<code>DebugDrawLine</code>''' overload that supports transparency]].
 +
 +
* '''<code>lifespan</code>''' - How long you would like this line to stick around before it automatically gets deleted by the engine. See [[#DebugDrawLifespanType enum|'''<code>DebugDrawLifespanType</code>''']] for the values you can pass here.<br>Note that you can't move lines around, so you might need to set a lifetime lower that <code>_persistent</code>, and call draw repeatedly, depending on how often you expect your object to move.
 +
 +
==== DebugDrawLine function (multiple colors) ====
 +
<pre style="white-space: pre-wrap;">int DebugDrawLine(vec3 start, vec3 end, vec3 start_color, vec3 end_color, DebugDrawLifespanType lifespan);</pre>
 +
Draw a line that exists in the 3D world space (as opposed to being a 2D HUD overlay line). This line will be opaque, and will have a color gradient between the start and end of the line.
 +
 +
The '''<code>return value</code>''' is an id that you can pass to [[#DebugDrawRemove function|'''<code>DebugDrawRemove</code>''']] to delete the object at a future time.
 +
 +
Parameters:
 +
* '''<code>start</code>''' - The point in 3D space of the beginning of the line. The line will begin at this point. The <code>start_color</code> will be applied to this point.
 +
 +
* '''<code>end</code>''' - The point in 3D space of the end of the line. The line will end at this point. The <code>end_color</code> will be applied to this point.
 +
 +
* '''<code>start_color</code>''' - The color to draw the beginning of the line. The line will begin with this color, and will be blended to the value at the end of the line. This will be an opaque color.<br>If you want to draw a line that has transparency, see [[#DebugDrawLine function (transparent)|the '''<code>DebugDrawLine</code>''' overload that supports transparency]].
 +
 +
* '''<code>end_color</code>''' - The color to draw the end of the line. The line will end with this color, and will be blended to the value at the beginning of the line. This will be an opaque color.<br>If you want to draw a line that has transparency, see [[#DebugDrawLine function (transparent)|the '''<code>DebugDrawLine</code>''' overload that supports transparency]].
 +
 +
* '''<code>lifespan</code>''' - How long you would like this line to stick around before it automatically gets deleted by the engine. See [[#DebugDrawLifespanType enum|'''<code>DebugDrawLifespanType</code>''']] for the values you can pass here.<br>Note that you can't move lines around, so you might need to set a lifetime lower that <code>_persistent</code>, and call draw repeatedly, depending on how often you expect your object to move.
 +
 +
==== DebugDrawLine function (transparent) ====
 +
<pre style="white-space: pre-wrap;">int DebugDrawLine(vec3 start, vec3 end, vec4 start_color, vec4 end_color, DebugDrawLifespanType lifespan);</pre>
 +
Draw a line that exists in the 3D world space (as opposed to being a 2D HUD overlay line). This line can be transparent, and will have a color gradient between the start and end of the line.
 +
 +
The '''<code>return value</code>''' is an id that you can pass to [[#DebugDrawRemove function|'''<code>DebugDrawRemove</code>''']] to delete the object at a future time.
 +
 +
Parameters:
 +
* '''<code>start</code>''' - The point in 3D space of the beginning of the line. The line will begin at this point. The <code>start_color</code> will be applied to this point.
 +
 +
* '''<code>end</code>''' - The point in 3D space of the end of the line. The line will end at this point. The <code>end_color</code> will be applied to this point.
 +
 +
* '''<code>start_color</code>''' - The color to draw the beginning of the line. The line will begin with this color, and will be blended to the value at the end of the line.<br>You can specify transparency using an alpha value between <code>0.0</code> (fully transparent, and thus invisible) and <code>1.0</code> (fully opaque).
 +
 +
* '''<code>end_color</code>''' - The color to draw the end of the line. The line will end with this color, and will be blended to the value at the beginning of the line.<br>You can specify transparency using an alpha value between <code>0.0</code> (fully transparent, and thus invisible) and <code>1.0</code> (fully opaque).
 +
 +
* '''<code>lifespan</code>''' - How long you would like this line to stick around before it automatically gets deleted by the engine. See [[#DebugDrawLifespanType enum|'''<code>DebugDrawLifespanType</code>''']] for the values you can pass here.<br>Note that you can't move lines around, so you might need to set a lifetime lower that <code>_persistent</code>, and call draw repeatedly, depending on how often you expect your object to move.
 +
 +
==== DebugDrawLines function ====
 +
<pre style="white-space: pre-wrap;">int DebugDrawLines(const array<vec3> &vertices, vec4 color, DebugDrawLifespanType lifespan);</pre>
 +
Draw multiple lines that exists in the 3D world space (as opposed to being 2D HUD overlay lines). These lines can be transparent, and will have a single color that applies to all the lines.
 +
 +
The '''<code>return value</code>''' is an id that you can pass to [[#DebugDrawRemove function|'''<code>DebugDrawRemove</code>''']] to delete the object at a future time.
 +
 +
Parameters:
 +
* '''<code>vertices</code>''' - A list of points in 3D space of the beginning and ends of the lines. '''TODO''': Are the lines automatically connected, or do you specify start/end pairs?
 +
 +
* '''<code>color</code>''' - The color to draw all the lines. You can specify transparency using an alpha value between <code>0.0</code> (fully transparent, and thus invisible) and <code>1.0</code> (fully opaque).
 +
 +
* '''<code>lifespan</code>''' - How long you would like these lines to stick around before it automatically gets deleted by the engine. See [[#DebugDrawLifespanType enum|'''<code>DebugDrawLifespanType</code>''']] for the values you can pass here.<br>Note that you can't move the lines around, so you might need to set a lifetime lower that <code>_persistent</code>, and call draw repeatedly, depending on how often you expect your object to move.
 +
 +
==== DebugDrawPoint function ====
 +
<pre style="white-space: pre-wrap;">int DebugDrawPoint(vec3 pos, vec4 color, DebugDrawLifespanType lifespan);</pre>
 +
Draw a point that exists in the 3D world space (as opposed to being a 2D HUD overlay point).
 +
 +
The '''<code>return value</code>''' is an id that you can pass to [[#DebugDrawRemove function|'''<code>DebugDrawRemove</code>''']] to delete the object at a future time.
 +
 +
Parameters:
 +
* '''<code>pos</code>''' - The origin of the point in 3D space. The point will be drawn here.
 +
 +
* '''<code>color</code>''' - The color to draw the point. You can specify transparency using an alpha value between 0.0 (fully transparent, and thus invisible) and 1.0 (fully opaque).
 +
 +
* '''<code>lifespan</code>''' - How long you would like this point to stick around before it automatically gets deleted by the engine. See [[#DebugDrawLifespanType enum|'''<code>DebugDrawLifespanType</code>''']] for the values you can pass here.<br>Note that you can't move debug draw points around, so you might need to set a lifetime lower that <code>_persistent</code>, and call draw repeatedly, depending on how often you expect your object to move.
 +
 +
==== DebugDrawRemove function ====
 +
<pre style="white-space: pre-wrap;">void DebugDrawRemove(int debug_draw_id);</pre>
 +
Delete a debug draw object that you previously created.
 +
 +
Parameters:
 +
* '''<code>debug_draw_id</code>''' - The debug draw id returned from a previously called <code>DebugDraw*</code> function, that you now want to delete.
 +
<pre style="white-space: pre-wrap;">int DebugDrawRibbon(DebugDrawLifespanType lifespan);</pre>
 +
<pre style="white-space: pre-wrap;">int DebugDrawRibbon(vec3 start, vec3 end, vec4 start_color, vec4 end_color, float start_width, float end_width, DebugDrawLifespanType lifespan);</pre>
 +
<pre style="white-space: pre-wrap;">int DebugDrawText(vec3 pos, string text, float scale, bool screen_space, DebugDrawLifespanType lifespan);</pre>
 +
<pre style="white-space: pre-wrap;">int DebugDrawWireBox(vec3 pos, vec3 dimensions, vec3 color, DebugDrawLifespanType lifespan);</pre>
 +
<pre style="white-space: pre-wrap;">int DebugDrawWireCylinder(vec3 pos, float radius, float height, vec3 color, DebugDrawLifespanType lifespan);</pre>
 +
<pre style="white-space: pre-wrap;">int DebugDrawWireMesh(string path, mat4 transform, vec4 color, DebugDrawLifespanType lifespan);</pre>
 +
<pre style="white-space: pre-wrap;">int DebugDrawWireScaledSphere(vec3 pos, float radius, vec3 scale, vec3 color, DebugDrawLifespanType lifespan);</pre>
 +
<pre style="white-space: pre-wrap;">int DebugDrawWireScaledSphere(vec3 pos, float radius, vec3 scale, vec4 color, DebugDrawLifespanType lifespan);</pre>
 +
<pre style="white-space: pre-wrap;">int DebugDrawWireSphere(vec3 pos, float radius, vec3 color, DebugDrawLifespanType lifespan);</pre>
 +
==== DebugText function ====
 +
<pre style="white-space: pre-wrap;">void DebugText(string key, string display_text, float lifetime_in_seconds);</pre>
 +
Write a line of text in the debug window, that will stick around for a short period of time.
 +
 +
You must pass a long value for '''<code>lifetime_in_seconds</code>''' (not recommended) or keep calling this function (recommended) if you want this text to remain in the debug window.
 +
 +
The debug window is accessible via '''Top Bar''' -> '''Windows''' -> '''Debug''', and only visible if the editor is active ('''<kbd>F1</kbd>''' key to activate).
 +
 +
Parameters:
 +
* '''<code>key</code>''' - The virtual "slot" that this debug text should reside in. If you call [[#DebugText function|'''<code>DebugText</code>''']] again with the same '''<code>key</code>''' value, it will overwrite the previous value.<br>Make sure to make this unique if you don't want overwriting to happen (use a random unique value, and/or append an index to the key if you're calling this inside a loop).
 +
 +
* '''<code>display_text</code>''' - The text you want to display. If you want to display a non-text value, one trick is to concatenate the value to a string: '''<code>"" + value</code>'''
 +
 +
* '''<code>lifetime_in_seconds</code>''' - The number of seconds you want the text to stick around for. The engine will automatically remove the debug text after this time has elapsed.<br>You may want to call this function repeatedly if you want text to stick around, instead of using an extraordinarily long value for '''<code>lifetime_in_seconds</code>''' (say, longer than <code>5.0</code> or <code>10.0</code> seconds). That way you can be sure that your debug values are actually fresh.
 +
 +
<pre style="white-space: pre-wrap;">void DisplayError(const string &in title, const string &in contents);</pre>
 +
<pre style="white-space: pre-wrap;">void EnterTelemetryZone(const string &in name);</pre>
 +
<pre style="white-space: pre-wrap;">string GetBuildTimestamp( );</pre>
 +
<pre style="white-space: pre-wrap;">string GetBuildVersionFull( );</pre>
 +
<pre style="white-space: pre-wrap;">string GetBuildVersionShort( );</pre>
 +
<pre style="white-space: pre-wrap;">uint64 GetPerformanceCounter();  // Get high precision time info for profiling</pre>
 +
<pre style="white-space: pre-wrap;">uint64 GetPerformanceFrequency();  // Used to convert PerformanceCounter into seconds</pre>
 +
<pre style="white-space: pre-wrap;">void LeaveTelemetryZone();</pre>
 +
<pre style="white-space: pre-wrap;">void Log( LogType level, const string &in str );</pre>
 +
<pre style="white-space: pre-wrap;">void PrintCallstack();</pre>
 +
<pre style="white-space: pre-wrap;">void StartStopwatch();</pre>
 +
<pre style="white-space: pre-wrap;">uint64 StopAndReportStopwatch();</pre>
 +
 +
=== Level and Campaign Data Access Functions ===
 +
<pre style="white-space: pre-wrap;">Campaign GetCampaign(string& campaign_id);</pre>
 +
<pre style="white-space: pre-wrap;">array<Campaign>@ GetCampaigns();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrCampaignID();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrCampaignID();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrLevel();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrLevel();</pre>
Line 269: Line 506:
 
<pre style="white-space: pre-wrap;">string GetCurrLevelName();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrLevelName();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrLevelRelPath();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrLevelRelPath();</pre>
 +
<pre style="white-space: pre-wrap;">string GetInterlevelData(const string &in);</pre>
 +
<pre style="white-space: pre-wrap;">string GetLevelName(const string& path);</pre>
 +
<pre style="white-space: pre-wrap;">void SetCampaignID(string id);</pre>
 +
<pre style="white-space: pre-wrap;">void SetInterlevelData(const string &in, const string &in);</pre>
 +
=== Mod Access Functions ===
 +
<pre style="white-space: pre-wrap;">void DeactivateAllMods();</pre>
 +
<pre style="white-space: pre-wrap;">array<ModID>@ GetActiveModSids();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrentLevelModsourceID();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrentLevelModsourceID();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrentMenuModsourceID();</pre>
 
<pre style="white-space: pre-wrap;">string GetCurrentMenuModsourceID();</pre>
<pre style="white-space: pre-wrap;">int GetFontFaceID(const string &in path, int pixel_height);</pre>
 
<pre style="white-space: pre-wrap;">float GetFriction(const vec3 &in position);</pre>
 
<pre style="white-space: pre-wrap;">float GetHDRBlackPoint(void);</pre>
 
<pre style="white-space: pre-wrap;">float GetHDRBloomMult(void);</pre>
 
<pre style="white-space: pre-wrap;">float GetHDRWhitePoint(void);</pre>
 
<pre style="white-space: pre-wrap;">bool GetInputDown(int controller_id, const string &in input_label);</pre>
 
<pre style="white-space: pre-wrap;">bool GetInputDownFiltered(int controller_id, const string &in input_label, uint filter);</pre>
 
<pre style="white-space: pre-wrap;">uint GetInputMode();</pre>
 
<pre style="white-space: pre-wrap;">bool GetInputPressed(int controller_id, const string &in input_label);</pre>
 
<pre style="white-space: pre-wrap;">bool GetInputPressedFiltered(int controller_id, const string &in input_label, uint filter);</pre>
 
<pre style="white-space: pre-wrap;">string GetInterlevelData(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">float GetLayerGain(const string &in layer);</pre>
 
<pre style="white-space: pre-wrap;">array<string>@ GetLayerNames();</pre>
 
<pre style="white-space: pre-wrap;">uint GetLengthInBytesForNCodepoints( const string &in, uint codepoint_index );</pre>
 
<pre style="white-space: pre-wrap;">string GetLevelName(const string& path);</pre>
 
<pre style="white-space: pre-wrap;">string GetLocaleStringForScancode(int scancode);</pre>
 
<pre style="white-space: pre-wrap;">float GetLookXAxis(int controller_id);</pre>
 
<pre style="white-space: pre-wrap;">float GetLookYAxis(int controller_id);</pre>
 
<pre style="white-space: pre-wrap;">bool GetMenuPaused();  // Is game paused by a menu</pre>
 
 
<pre style="white-space: pre-wrap;">array<ModID>@ GetModSids();</pre>
 
<pre style="white-space: pre-wrap;">array<ModID>@ GetModSids();</pre>
<pre style="white-space: pre-wrap;">float GetMoveXAxis(int controller_id);</pre>
 
<pre style="white-space: pre-wrap;">float GetMoveYAxis(int controller_id);</pre>
 
<pre style="white-space: pre-wrap;">int GetNumCharacters();</pre>
 
<pre style="white-space: pre-wrap;">int GetNumHotspots();</pre>
 
<pre style="white-space: pre-wrap;">int GetNumItems();</pre>
 
<pre style="white-space: pre-wrap;">array<int>@ GetObjectIDs();</pre>
 
<pre style="white-space: pre-wrap;">array<int>@ GetObjectIDsType(int type);</pre>
 
<pre style="white-space: pre-wrap;">void GetObjectsInHull(string model_path, mat4, array<int>@ id_array);</pre>
 
<pre style="white-space: pre-wrap;">uint64 GetPerformanceCounter();  // Get high precision time info for profiling</pre>
 
<pre style="white-space: pre-wrap;">uint64 GetPerformanceFrequency();  // Used to convert PerformanceCounter into seconds</pre>
 
<pre style="white-space: pre-wrap;">array<vec2>@ GetPossibleResolutions();</pre>
 
<pre style="white-space: pre-wrap;">array<KeyboardPress>@ GetRawKeyboardInputs();</pre>
 
<pre style="white-space: pre-wrap;">void GetRotationBetweenVectors(const vec3 &in start, const vec3 &in end, quaternion &out rotation);  // Get a relative rotation from one direction vector to another</pre>
 
<pre style="white-space: pre-wrap;">int GetScreenHeight();</pre>
 
<pre style="white-space: pre-wrap;">int GetScreenWidth();</pre>
 
<pre style="white-space: pre-wrap;">string GetSegment();</pre>
 
<pre style="white-space: pre-wrap;">vec3 GetSkyTint();</pre>
 
<pre style="white-space: pre-wrap;">string GetSong();</pre>
 
<pre style="white-space: pre-wrap;">bool GetSplitscreen();</pre>
 
<pre style="white-space: pre-wrap;">string GetStringDescriptionForBinding( const string &in, const string &in );</pre>
 
<pre style="white-space: pre-wrap;">float GetSunAmbient();</pre>
 
<pre style="white-space: pre-wrap;">vec3 GetSunColor();</pre>
 
<pre style="white-space: pre-wrap;">vec3 GetSunPosition();</pre>
 
<pre style="white-space: pre-wrap;">TextMetrics GetTextAtlasMetrics(const string &in path, int pixel_height, int flags, const string &in txt );</pre>
 
<pre style="white-space: pre-wrap;">TextMetrics GetTextAtlasMetrics2(const string &in path, int pixel_height, int flags, const string &in txt, uint char_limit );</pre>
 
<pre style="white-space: pre-wrap;">bool IsGroupDerived(int id);</pre>
 
<pre style="white-space: pre-wrap;">bool IsKeyDown(int key_code);</pre>
 
<pre style="white-space: pre-wrap;">bool IsWorkshopAvailable();</pre>
 
<pre style="white-space: pre-wrap;">bool IsWorkshopMod(ModID& id);</pre>
 
<pre style="white-space: pre-wrap;">bool IsWorkshopSubscribed(ModID& id);</pre>
 
<pre style="white-space: pre-wrap;">void LeaveTelemetryZone();</pre>
 
<pre style="white-space: pre-wrap;">void LoadEditorLevel();</pre>
 
<pre style="white-space: pre-wrap;">void LoadLevel(string level_path);</pre>
 
<pre style="white-space: pre-wrap;">void LoadLevelID(string id);</pre>
 
<pre style="white-space: pre-wrap;">void Log( LogType level, const string &in str );</pre>
 
<pre style="white-space: pre-wrap;">uint32 MakeParticle(string path, vec3 pos, vec3 vel);</pre>
 
<pre style="white-space: pre-wrap;">uint32 MakeParticle(string path, vec3 pos, vec3 vel, vec3 color);</pre>
 
<pre style="white-space: pre-wrap;">mat3 Mat3FromQuaternion(const quaternion &in);  // Convert a quaternion to its corresponding 3x3 rotation matrix</pre>
 
<pre style="white-space: pre-wrap;">mat4 Mat4FromQuaternion(const quaternion &in);  // Convert a quaternion to its corresponding 4x4 rotation matrix</pre>
 
<pre style="white-space: pre-wrap;">bool MediaMode();</pre>
 
 
<pre style="white-space: pre-wrap;">bool ModActivation(ModID& sid, bool active);</pre>
 
<pre style="white-space: pre-wrap;">bool ModActivation(ModID& sid, bool active);</pre>
 
<pre style="white-space: pre-wrap;">bool ModCanActivate(ModID& id);</pre>
 
<pre style="white-space: pre-wrap;">bool ModCanActivate(ModID& id);</pre>
Line 352: Line 537:
 
<pre style="white-space: pre-wrap;">bool ModIsValid(ModID& id);</pre>
 
<pre style="white-space: pre-wrap;">bool ModIsValid(ModID& id);</pre>
 
<pre style="white-space: pre-wrap;">bool ModNeedsRestart(ModID& id);</pre>
 
<pre style="white-space: pre-wrap;">bool ModNeedsRestart(ModID& id);</pre>
<pre style="white-space: pre-wrap;">bool MovementObjectExists(int id);</pre>
 
<pre style="white-space: pre-wrap;">vec3 Mult(quaternion, vec3);  // Applies a quaternion rotation to a vector</pre>
 
<pre style="white-space: pre-wrap;">bool ObjectExists();</pre>
 
<pre style="white-space: pre-wrap;">bool ObjectExists(int id);</pre>
 
<pre style="white-space: pre-wrap;">void OpenModAuthorWorkshopPage(ModID& id);</pre>
 
<pre style="white-space: pre-wrap;">void OpenModWorkshopPage(ModID& id);</pre>
 
<pre style="white-space: pre-wrap;">void OpenWorkshop();</pre>
 
<pre style="white-space: pre-wrap;">void PlaySegment(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">void PlaySong(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySound(string path);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySound(string path, vec3 position);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path, float gain);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path, vec3 position);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path, vec3 position, float gain);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySoundGroup(string path, vec3 position, int priority);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySoundLoop(const string &in path, float gain);</pre>
 
<pre style="white-space: pre-wrap;">int PlaySoundLoopAtLocation(const string &in path, vec3 pos, float gain);</pre>
 
<pre style="white-space: pre-wrap;">void PrintCallstack();</pre>
 
<pre style="white-space: pre-wrap;">quaternion QuaternionFromMat4(const mat4 &in);  // Convert a 4x4 matrix to its corresponding quaternion</pre>
 
<pre style="white-space: pre-wrap;">void QueueDeleteObjectID(int);</pre>
 
<pre style="white-space: pre-wrap;">void QueueSegment(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">float RangedRandomFloat(float min, float max);</pre>
 
<pre style="white-space: pre-wrap;">MovementObject@ ReadCharacter(int index);  // e.g. first character in scene</pre>
 
<pre style="white-space: pre-wrap;">MovementObject@ ReadCharacterID(int id);  // e.g. character with object ID 39</pre>
 
<pre style="white-space: pre-wrap;">EnvObject@ ReadEnvObjectID(int id);</pre>
 
<pre style="white-space: pre-wrap;">Hotspot@ ReadHotspot(int index);</pre>
 
<pre style="white-space: pre-wrap;">ItemObject@ ReadItem(int index);</pre>
 
<pre style="white-space: pre-wrap;">ItemObject@ ReadItemID(int id);</pre>
 
<pre style="white-space: pre-wrap;">Object@ ReadObjectFromID(int);</pre>
 
 
<pre style="white-space: pre-wrap;">void ReloadMods();</pre>
 
<pre style="white-space: pre-wrap;">void ReloadMods();</pre>
<pre style="white-space: pre-wrap;">void ReloadStaticValues();</pre>
 
<pre style="white-space: pre-wrap;">bool RemoveMusic(const string &in);</pre>
 
 
<pre style="white-space: pre-wrap;">void RequestModSetFavorite(ModID& id, bool fav);</pre>
 
<pre style="white-space: pre-wrap;">void RequestModSetFavorite(ModID& id, bool fav);</pre>
 
<pre style="white-space: pre-wrap;">void RequestModSetUserVote(ModID& id, bool voteup);</pre>
 
<pre style="white-space: pre-wrap;">void RequestModSetUserVote(ModID& id, bool voteup);</pre>
<pre style="white-space: pre-wrap;">void RequestWorkshopSubscribe(ModID& id);</pre>
+
=== Editor Manipulation Functions ===
<pre style="white-space: pre-wrap;">void RequestWorkshopUnSubscribe(ModID& id);</pre>
+
<pre style="white-space: pre-wrap;">bool CheckSaveLevelChanges();</pre>
<pre style="white-space: pre-wrap;">void ResetBinding(string binding_category, string binding);</pre>
+
<pre style="white-space: pre-wrap;">void ClearUndoHistory();</pre>
<pre style="white-space: pre-wrap;">void ResetLevel();</pre>
+
<pre style="white-space: pre-wrap;">void DeselectAll();</pre>
 +
<pre style="white-space: pre-wrap;">bool EditorEnabled();</pre>
 +
<pre style="white-space: pre-wrap;">bool EditorModeActive();</pre>
 +
<pre style="white-space: pre-wrap;">void LoadEditorLevel();</pre>
 +
<pre style="white-space: pre-wrap;">void LoadLevel(string level_path);</pre>
 +
<pre style="white-space: pre-wrap;">void LoadLevelID(string id);</pre>
 +
<pre style="white-space: pre-wrap;">bool MediaMode();</pre>
 
<pre style="white-space: pre-wrap;">void RibbonItemFlash(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">void RibbonItemFlash(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">void RibbonItemSetEnabled(const string &in, bool);</pre>
 
<pre style="white-space: pre-wrap;">void RibbonItemSetEnabled(const string &in, bool);</pre>
 
<pre style="white-space: pre-wrap;">void RibbonItemSetToggled(const string &in, bool);</pre>
 
<pre style="white-space: pre-wrap;">void RibbonItemSetToggled(const string &in, bool);</pre>
<pre style="white-space: pre-wrap;">string SaveConfig();</pre>
 
<pre style="white-space: pre-wrap;">void SendGlobalMessage(string msg);</pre>
 
<pre style="white-space: pre-wrap;">void SendMessage(int target, int type, vec3 vec_a, vec3 vec_b);</pre>
 
<pre style="white-space: pre-wrap;">void SendMessage(int type, string msg);</pre>
 
<pre style="white-space: pre-wrap;">void SetAirWhoosh(float volume, float pitch);</pre>
 
<pre style="white-space: pre-wrap;">void SetBindingValue(string binding_category, string binding, string value);</pre>
 
<pre style="white-space: pre-wrap;">void SetCampaignID(string id);</pre>
 
<pre style="white-space: pre-wrap;">void SetConfigValueBool(string key, bool value);</pre>
 
<pre style="white-space: pre-wrap;">void SetConfigValueFloat(string key, float value);</pre>
 
<pre style="white-space: pre-wrap;">void SetConfigValueInt(string key, int value);</pre>
 
<pre style="white-space: pre-wrap;">void SetConfigValueString(string key, string value);</pre>
 
<pre style="white-space: pre-wrap;">void SetFlareDiffuse(float);</pre>
 
<pre style="white-space: pre-wrap;">void SetGrabMouse(bool);</pre>
 
<pre style="white-space: pre-wrap;">void SetHDRBlackPoint(float);</pre>
 
<pre style="white-space: pre-wrap;">void SetHDRBloomMult(float);</pre>
 
<pre style="white-space: pre-wrap;">void SetHDRWhitePoint(float);</pre>
 
<pre style="white-space: pre-wrap;">void SetInterlevelData(const string &in, const string &in);</pre>
 
<pre style="white-space: pre-wrap;">void SetKeyboardBindingValue(string binding_category, string binding, uint32 scancode);</pre>
 
<pre style="white-space: pre-wrap;">void SetLayerGain(const string &in layer, float gain);</pre>
 
 
<pre style="white-space: pre-wrap;">void SetMediaMode(bool);</pre>
 
<pre style="white-space: pre-wrap;">void SetMediaMode(bool);</pre>
<pre style="white-space: pre-wrap;">void SetPaused(bool paused);</pre>
 
<pre style="white-space: pre-wrap;">void SetSegment(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">void SetSkyTint(vec3);</pre>
 
<pre style="white-space: pre-wrap;">void SetSong(const string &in);</pre>
 
<pre style="white-space: pre-wrap;">void SetSoundGain(int handle, float gain);</pre>
 
<pre style="white-space: pre-wrap;">void SetSoundPitch(int handle, float pitch);</pre>
 
<pre style="white-space: pre-wrap;">void SetSoundPosition(int handle, vec3 pos);</pre>
 
<pre style="white-space: pre-wrap;">void SetSunAmbient(float);</pre>
 
<pre style="white-space: pre-wrap;">void SetSunColor(vec3);</pre>
 
<pre style="white-space: pre-wrap;">void SetSunPosition(vec3);</pre>
 
<pre style="white-space: pre-wrap;">void StartStopwatch();</pre>
 
<pre style="white-space: pre-wrap;">void StartTextInput();</pre>
 
<pre style="white-space: pre-wrap;">uint64 StopAndReportStopwatch();</pre>
 
<pre style="white-space: pre-wrap;">void StopSound(int handle);</pre>
 
<pre style="white-space: pre-wrap;">void StopTextInput();</pre>
 
 
<pre style="white-space: pre-wrap;">int StorageGetInt32(string index);</pre>
 
<pre style="white-space: pre-wrap;">int StorageGetInt32(string index);</pre>
 
<pre style="white-space: pre-wrap;">string StorageGetString(string index);</pre>
 
<pre style="white-space: pre-wrap;">string StorageGetString(string index);</pre>
Line 435: Line 560:
 
<pre style="white-space: pre-wrap;">void StorageSetInt32(string index, int value);</pre>
 
<pre style="white-space: pre-wrap;">void StorageSetInt32(string index, int value);</pre>
 
<pre style="white-space: pre-wrap;">void StorageSetString(string index, string value);</pre>
 
<pre style="white-space: pre-wrap;">void StorageSetString(string index, string value);</pre>
<pre style="white-space: pre-wrap;">void TimedSlowMotion(float target_time_scale, float how_long, float delay); // Used to trigger brief periods of slow motion</pre>
+
=== Input Functions ===
<pre style="white-space: pre-wrap;">void TintParticle(uint32 id, const vec3 &in color);</pre>
+
<pre style="white-space: pre-wrap;">array<string>@ GetAvailableBindingCategories();</pre>
<pre style="white-space: pre-wrap;">string ToUpper(string &in);</pre>
+
<pre style="white-space: pre-wrap;">array<string>@ GetAvailableBindings(const string &in);</pre>
<pre style="white-space: pre-wrap;">void UpdateListener(vec3 pos, vec3 vel, vec3 facing, vec3 up);</pre>
+
<pre style="white-space: pre-wrap;">string GetBindingValue(string binding_category, string binding);</pre>
 +
<pre style="white-space: pre-wrap;">bool GetInputDown(int controller_id, const string &in input_label);</pre>
 +
<pre style="white-space: pre-wrap;">bool GetInputDownFiltered(int controller_id, const string &in input_label, uint filter);</pre>
 +
<pre style="white-space: pre-wrap;">uint GetInputMode();</pre>
 +
<pre style="white-space: pre-wrap;">bool GetInputPressed(int controller_id, const string &in input_label);</pre>
 +
<pre style="white-space: pre-wrap;">bool GetInputPressedFiltered(int controller_id, const string &in input_label, uint filter);</pre>
 +
<pre style="white-space: pre-wrap;">string GetLocaleStringForScancode(int scancode);</pre>
 +
<pre style="white-space: pre-wrap;">float GetLookXAxis(int controller_id);</pre>
 +
<pre style="white-space: pre-wrap;">float GetLookYAxis(int controller_id);</pre>
 +
<pre style="white-space: pre-wrap;">float GetMoveXAxis(int controller_id);</pre>
 +
<pre style="white-space: pre-wrap;">float GetMoveYAxis(int controller_id);</pre>
 +
<pre style="white-space: pre-wrap;">string GetStringDescriptionForBinding( const string &in, const string &in );</pre>
 +
<pre style="white-space: pre-wrap;">void ResetBinding(string binding_category, string binding);</pre>
 +
<pre style="white-space: pre-wrap;">void SetBindingValue(string binding_category, string binding, string value);</pre>
 +
<pre style="white-space: pre-wrap;">void SetGrabMouse(bool);</pre>
 +
<pre style="white-space: pre-wrap;">void StartTextInput();</pre>
 +
<pre style="white-space: pre-wrap;">void StopTextInput();</pre>
 +
=== Keyboard Raw Access Functions ===
 +
These functions are for doing low level interfacing with the keyboard.
 +
<pre style="white-space: pre-wrap;">array<KeyboardPress>@ GetRawKeyboardInputs();  // Get a list of all the current keyboard events</pre>
 +
<pre style="white-space: pre-wrap;">bool DebugKeysEnabled();  // Find out if the debug keys are enabled</pre>
 +
<pre style="white-space: pre-wrap;">bool IsKeyDown(int key_code);  // Find out if a key with the specified scan code is currently pressed</pre>
 +
<pre style="white-space: pre-wrap;">int GetCodeForKey(string key_name);  // Get the scan code for a key, by a friendly name - TODO: Add list of mappings</pre>
 +
<pre style="white-space: pre-wrap;">void ActivateKeyboardEvents();  // Start listening for keyboard events in this script</pre>
 +
<pre style="white-space: pre-wrap;">void DeactivateKeyboardEvents(); // Stop listening for keyboard events in this script</pre>
 +
<pre style="white-space: pre-wrap;">void SetKeyboardBindingValue(string binding_category, string binding, uint32 scancode);
 +
// Set an input binding for the given key. Pass "key" for binding_category, and the action name for binding</pre>
 +
=== File Access Functions ===
 +
<pre style="white-space: pre-wrap;">bool FileExists(string &in);  // Does a file with the given path exist</pre>
 +
=== Display Access Functions ===
 +
<pre style="white-space: pre-wrap;">array<vec2>@ GetPossibleResolutions();</pre>
 +
<pre style="white-space: pre-wrap;">int GetScreenHeight();</pre>
 +
<pre style="white-space: pre-wrap;">int GetScreenWidth();</pre>
 +
<pre style="white-space: pre-wrap;">bool GetSplitscreen();</pre>
 +
=== Steam Workshop Functions ===
 +
<pre style="white-space: pre-wrap;">bool IsWorkshopAvailable();</pre>
 +
<pre style="white-space: pre-wrap;">bool IsWorkshopMod(ModID& id);</pre>
 +
<pre style="white-space: pre-wrap;">bool IsWorkshopSubscribed(ModID& id);</pre>
 +
<pre style="white-space: pre-wrap;">float WorkshopTotalDownloadProgress();</pre>
 +
<pre style="white-space: pre-wrap;">uint WorkshopDownloadingCount();</pre>
 
<pre style="white-space: pre-wrap;">uint WorkshopDownloadPendingCount();</pre>
 
<pre style="white-space: pre-wrap;">uint WorkshopDownloadPendingCount();</pre>
<pre style="white-space: pre-wrap;">uint WorkshopDownloadingCount();</pre>
 
 
<pre style="white-space: pre-wrap;">uint WorkshopNeedsUpdateCount();</pre>
 
<pre style="white-space: pre-wrap;">uint WorkshopNeedsUpdateCount();</pre>
 
<pre style="white-space: pre-wrap;">uint WorkshopSubscribedNotInstalledCount();</pre>
 
<pre style="white-space: pre-wrap;">uint WorkshopSubscribedNotInstalledCount();</pre>
<pre style="white-space: pre-wrap;">float WorkshopTotalDownloadProgress();</pre>
+
<pre style="white-space: pre-wrap;">void OpenModAuthorWorkshopPage(ModID& id);</pre>
 +
<pre style="white-space: pre-wrap;">void OpenModWorkshopPage(ModID& id);</pre>
 +
<pre style="white-space: pre-wrap;">void OpenWorkshop();</pre>
 +
<pre style="white-space: pre-wrap;">void RequestWorkshopSubscribe(ModID& id);</pre>
 +
<pre style="white-space: pre-wrap;">void RequestWorkshopUnSubscribe(ModID& id);</pre>
  
 
== Classes ==
 
== Classes ==
Line 638: Line 805:
  
 
'''methods'''
 
'''methods'''
<pre style="white-space: pre-wrap;">void PrintGlobalVars();  // Print the global variables in this script context</pre>
+
<pre style="white-space: pre-wrap;">void PrintGlobalVars();  // Print the global variables in this script context in the console</pre>
  
 
'''related global variables'''
 
'''related global variables'''

Latest revision as of 01:04, 11 December 2017

This is a list of the external code that is available inside all scripts - variables, functions, and classes that "magically" exist.

To see a list of external code that is available only in specific scripts, please see the corresponding page:

Note: The editor camera script cannot use some of the data and functions defined below - read this page carefully to see what code doesn't apply!

This list is pulled from the ~/Documents/Wolfire/Overgrowth/ directory, from the aschar_docs.h and aslevel_docs.h files, which are automatically generated by the game.

See this page to find the location for the Wolfire/Overgrowth folder on each OS - How to clear the game's cache

TODO: Finish documenting the rest of the classes, and lists of related global functions

TODO: It's possible some of these might not work in hotspot scripts. If you find that to be the case, please copy a function to level scripts/character scripts and remove it from here.

TODO: Missing TokenIterator definition - note, cannot be used from the editor camera script, but can from level scripts, movement object scripts, hotspot scripts

Global Variables

Camera camera;
CharacterScriptGetter character_getter;
ASContext context;  // The context for the currently running script, whether that is the menu script, level script, character script, or hotspot script
float last_controller_event_time;  // The time the last game controller input event occurred
float last_keyboard_event_time;  // The time the last keyboard input event occurred
float last_mouse_event_time;  // The time the last mouse input event occurred
Level level;
Physics physics;
uint UINT32MAX;

Constants

Types in this section that specify the base type for the enum aren't actually exposed via enums. They are defined as const instances of the base type.

Functions that take those parameters will take the base type instead. E.g. _delete_on_draw is actually defined in your script as an "const int _delete_on_draw".

enum AttachmentType {
    _at_attachment,
    _at_grip,
    _at_sheathe,
    _at_unspecified,
};
enum CameraFlags {
    kEditorCamera,
    kPreviewCamera,
};

DebugDrawLifespanType enum

enum DebugDrawLifespanType : int {
    _delete_on_draw,
    _delete_on_update,
    _fade,
    _persistent,
};

Used for specifying how long a debug draw object that you create should stick around. Usually the last argument to one of those calls.

Different lifespans are useful for different scenarios:

  • _delete_on_draw - The engine will automatically delete this debug draw object the next time Draw gets called. Recommended if your debug draw object gets created every time inside a Draw function, e.g. DrawGui. You might choose to use this instead of _delete_on_update so you can get smooth per-frame interpolation of the positions for the line you are drawing.
  • _delete_on_update - The engine will automatically delete this debug draw object the next time Update gets called. Recommended if your debug draw object gets created every time inside Update. You might choose to use this instead of _delete_on_draw inside an enemy character script so you have less code running less frequently (since update is called at 30hz for enemy control scripts).
  • _fade - The engine will automatically delete this debug draw object after a few frames, and make it fade out. Recommended if your debug draw object is triggered sporadically, rather than every frame or every update, and you want the results to stick around on screen for a few updates/frames.
  • _persistent - The engine will automatically delete this debug draw object when you leave the level. This tells the engine that you would prefer to delete this object manually. If you use this value, then make sure to hold onto the return value from the call to DebugDraw*. Recommended if you want to draw a line that shows up while in-game, isn't moving around a lot (unless you're using the editor to move the object), and isn't conditional. If the display should be conditional, or the line is expected to move around quite frequently (every update or every frame), then one of the other values might make more sense, unless you're trying to conserve CPU time in your Update or Draw* function.
enum EngineState {
    kEngineNoState,
    kEngineLevelState,
    kEngineEditorLevelState,
    kEngineEngineScriptableUIState,
    kEngineCampaignState,
};
enum EntityType {
    _env_object,
    _decal_object,
    _item_object,
    _movement_object,
    _hotspot_object,
    _placeholder_object,
    _path_point_object,
    _dynamic_light_object,
};
enum ItemType : int {
    _collectable,
    _item_no_type,
    _misc,
    _weapon,
};
enum JsonValueType {
    JSONnullValue,
    JSONintValue,
    JSONuintValue,
    JSONrealValue,
    JSONstringValue,
    JSONbooleanValue,
    JSONarrayValue,
    JSONobjectValue,
};
enum KeyboardInputModeFlag {
    KIMF_NO,
    KIMF_MENU,
    KIMF_PLAYING,
    KIMF_LEVEL_EDITOR_GENERAL,
    KIMF_LEVEL_EDITOR_DIALOGUE_EDITOR,
    KIMF_GUI_GENERAL,
    KIMF_ANY,
};
enum KnockedOutType : int {
    _awake,
    _dead,
    _unconscious,
};
enum LogType {
    fatal,
    error,
    warning,
    info,
    debug,
    spam,
};
enum MessageType : int {  // Note, not available in the editor camera script
    _editor_msg;
    _plant_movement_msg;
};
enum SDLNumeric {
    K_ENTER,
    KP_ENTER,
    K_BACKSPACE,
    K_0,
    K_1,
    K_2,
    K_3,
    K_4,
    K_5,
    K_6,
    K_7,
    K_8,
    K_9,
    KP_0,
    KP_1,
    KP_2,
    KP_3,
    KP_4,
    KP_5,
    KP_6,
    KP_7,
    KP_8,
    KP_9,
};
enum SoundGroupPriorityType : int {
    _sound_priority_high,
    _sound_priority_low,
    _sound_priority_max,
    _sound_priority_med,
    _sound_priority_very_high,
};
enum TextAtlasFlags {
    kSmallLowercase,
};
enum UserVote {
    k_VoteUnknown,
    k_VoteNone,
    k_VoteUp,
    k_VoteDown,
};

Global Functions

Math Functions

float abs(float);
float acos(float);
float asin(float);
void assert(bool val);
float atan(float);
float atan2(float, float);
float atof(const string &in str);  // Note, not callable from the editor camera script
int atoi(const string &in str);  // Note, not callable from the editor camera script
float ceil(float);
float cos(float);
vec3 cross(const vec3 &in, const vec3 &in);  // Calculate the cross-product between two vec3 values - https://en.wikipedia.org/wiki/Cross_product
float distance(const vec2 &in, const vec2 &in);  // Get the distance between two vec2 values
float distance(const vec3 &in, const vec3 &in);  // Get the distance between two vec3 values
float distance_squared(const vec2 &in, const vec2 &in);  // Get the squared distance between two vec2 values (faster than distance function, no square-root done)
float distance_squared(const vec3 &in, const vec3 &in);  // Get the squared distance between two vec3 values (faster than distance function, no square-root done)
float dot(const vec2 &in, const vec2 &in);  // Calculate the dot-product between two vec2 values - https://en.wikipedia.org/wiki/Dot_product
float dot(const vec3 &in, const vec3 &in);  // Calculate the dot-product between two vec3 values - https://en.wikipedia.org/wiki/Dot_product
float floor(float);
double fpFromIEEE(uint64);
float fpFromIEEE(uint);
uint fpToIEEE(float);
uint64 fpToIEEE(double);
BoneTransform mix(const BoneTransform &in a, const BoneTransform &in b, float alpha);  // Linear interpolation between two bone transform matrices
float mix(float a, float b, float amount);  // Linear interpolation between two float values
mat4 mix(const mat4 &in a, const mat4 &in b, float alpha);  // Linear interpolation between two 4x4 matrices
quaternion mix(const quaternion &in a, const quaternion &in b, float alpha);  // Linear interpolation between two quaternions
vec2 mix(vec2 a, vec2 b, float alpha);  // Linear interpolation between two vec2 values
vec3 mix(vec3 a, vec3 b, float alpha);  // Linear interpolation between two vec3 values
vec4 mix(vec4 a, vec4 b, float alpha);  // Linear interpolation between two vec4 values (including alpha)
vec2 normalize(const vec2 &in);  // Shrink or grow a vec2 value to be unit length, with the same direction
vec3 normalize(const vec3 &in);  // Shrink or grow a vec3 value to be unit length, with the same direction
float pow(float val, float exponent);
int rand();
vec2 reflect(const vec2 &in vec, const vec2 &in normal);
// Calculate the reflection of a vec2, relative to the surface with the given normal - https://en.wikipedia.org/wiki/Reflection_(mathematics)
vec3 reflect(const vec3 &in vec, const vec3 &in normal);
// Calculate the reflection of a vec3, relative to the surface with the given normal - https://en.wikipedia.org/wiki/Reflection_(mathematics)
float sin(float angle_in_radians);
float sqrt(float angle_in_radians);
float tan(float angle_in_radians);
mat4 transpose(mat4);  // Get the mathematical transpose of this 4x4 matrix - https://en.wikipedia.org/wiki/Transpose
float xz_distance(const vec3 &in, const vec3 &in);  // Get the distance on the x/z plane between two vec3 values (flat)
float xz_distance_squared(const vec3 &in, const vec3 &in);
// Get the squared distance on the x/z plane between two vec3 values (flat. faster than xz_distance function, no square-root done)
void GetRotationBetweenVectors(const vec3 &in start, const vec3 &in end, quaternion &out rotation);  // Get a relative rotation from one direction vector to another
mat3 Mat3FromQuaternion(const quaternion &in);  // Convert a quaternion to its corresponding 3x3 rotation matrix
mat4 Mat4FromQuaternion(const quaternion &in);  // Convert a quaternion to its corresponding 4x4 rotation matrix
vec3 Mult(quaternion, vec3);  // Applies a quaternion rotation to a vector
quaternion QuaternionFromMat4(const mat4 &in);  // Convert a 4x4 matrix to its corresponding quaternion
float RangedRandomFloat(float min, float max);

String Functions

string FloatString(float val, int digits);
uint GetCodepointCount( const string &in );
string ToUpper(string &in);

Game Object Functions

int CreateObject(const string &in path);
int CreateObject(const string &in path, bool exclude_from_save);
int DebugSetPosition(int id, vec3 pos);
void DeleteObjectID(int);
bool DoesItemFitInItem(int item_id, int holster_item_id);
int DuplicateObject(Object@ obj);
int FindFirstCharacterInGroup(int id);
void GetCharacters(array<int>@ id_array);
int GetNumCharacters();
int GetNumHotspots();
int GetNumItems();
array<int>@ GetObjectIDs();
array<int>@ GetObjectIDsType(int type);
bool IsGroupDerived(int id);
bool MovementObjectExists(int id);
bool ObjectExists();
bool ObjectExists(int id);
void QueueDeleteObjectID(int);
MovementObject@ ReadCharacter(int index);  // e.g. first character in scene
MovementObject@ ReadCharacterID(int id);  // e.g. character with object ID 39
EnvObject@ ReadEnvObjectID(int id);
Hotspot@ ReadHotspot(int index);
ItemObject@ ReadItem(int index);
ItemObject@ ReadItemID(int id);
Object@ ReadObjectFromID(int);

Physics Functions

void CreateCustomHull(const string &in key, const array<vec3> &vertices);
void GetCharactersInHull(string model_path, mat4, array<int>@ id_array);
void GetCharactersInSphere(vec3 position, float radius, array<int>@ id_array);
float GetFriction(const vec3 &in position);
void GetObjectsInHull(string model_path, mat4, array<int>@ id_array);

Script Message Functions

void SendGlobalMessage(string msg);  // Note, not callable from the editor camera script
void SendMessage(int target, int type, vec3 vec_a, vec3 vec_b);  // Note, not callable from the editor camera script
void SendMessage(int type, string msg);  // Note, not callable from the editor camera script

Particle and Decal Functions

void ClearTemporaryDecals();  // Like blood splats and footprints
void ConnectParticles(uint32 id_a, uint32 id_b);  // Used for ribbon particles, like throat-cut blood
int GetBloodLevel();
const vec3& GetBloodTint();
uint32 MakeParticle(string path, vec3 pos, vec3 vel);
uint32 MakeParticle(string path, vec3 pos, vec3 vel, vec3 color);
void TintParticle(uint32 id, const vec3 &in color);

Scene Access Functions

vec3 GetBaseSkyTint();
float GetHDRBlackPoint(void);
float GetHDRBloomMult(void);
float GetHDRWhitePoint(void);
vec3 GetSkyTint();
float GetSunAmbient();
vec3 GetSunColor();
vec3 GetSunPosition();
void SetFlareDiffuse(float);
void SetHDRBlackPoint(float);
void SetHDRBloomMult(float);
void SetHDRWhitePoint(float);
void SetSkyTint(vec3);
void SetSunAmbient(float);
void SetSunColor(vec3);
void SetSunPosition(vec3);

Text Drawing Functions

void DrawTextAtlas(const string &in path, int pixel_height, int flags, const string &in txt, int x, int y, vec4 color);
void DrawTextAtlas2(const string &in path, int pixel_height, int flags, const string &in txt, int x, int y, vec4 color, uint char_limit);
void DisposeTextAtlases();
int GetFontFaceID(const string &in path, int pixel_height);
uint GetLengthInBytesForNCodepoints( const string &in, uint codepoint_index );
TextMetrics GetTextAtlasMetrics(const string &in path, int pixel_height, int flags, const string &in txt );
TextMetrics GetTextAtlasMetrics2(const string &in path, int pixel_height, int flags, const string &in txt, uint char_limit );

Sound and Music Functions

bool AddMusic(const string &in);
float GetLayerGain(const string &in layer);
array<string>@ GetLayerNames();
string GetSegment();
string GetSong();
void PlaySegment(const string &in);
void PlaySong(const string &in);
int PlaySound(string path);
int PlaySound(string path, vec3 position);
int PlaySoundGroup(string path);
int PlaySoundGroup(string path, float gain);
int PlaySoundGroup(string path, vec3 position);
int PlaySoundGroup(string path, vec3 position, float gain);
int PlaySoundGroup(string path, vec3 position, int priority);
int PlaySoundLoop(const string &in path, float gain);
int PlaySoundLoopAtLocation(const string &in path, vec3 pos, float gain);
void QueueSegment(const string &in);
bool RemoveMusic(const string &in);
void SetAirWhoosh(float volume, float pitch);
void SetLayerGain(const string &in layer, float gain);
void SetSegment(const string &in);
void SetSong(const string &in);
void SetSoundGain(int handle, float gain);
void SetSoundPitch(int handle, float pitch);
void SetSoundPosition(int handle, vec3 pos);
void StopSound(int handle);
void UpdateListener(vec3 pos, vec3 vel, vec3 facing, vec3 up);

Gameplay State Functions

bool GetMenuPaused();  // Is game paused by a menu
void ResetLevel();  // Queue a level reset, including respawns, such as after a death

Time Manipulation Functions

void TimedSlowMotion(float target_time_scale, float how_long, float delay);  // Used to trigger brief periods of slow motion
void SetPaused(bool paused);

Config Access Functions

bool GetConfigValueBool(string index);
float GetConfigValueFloat(string index);
int GetConfigValueInt(string key);
array<string>@ GetConfigValueOptions(string index);
string GetConfigValueString(string index);
void ReloadStaticValues();
string SaveConfig();
void SetConfigValueBool(string key, bool value);
void SetConfigValueFloat(string key, float value);
void SetConfigValueInt(string key, int value);
void SetConfigValueString(string key, string value);

Debug Functions

These functions allow you to create artifacts to help you debug scripts and game beahvior.

With them you can write to the logfile, print to the debug window, draw in-game (and/or in-editor) 3D objects, do basic profiling of scripts, and get build information.

void AddDebugDrawRibbonPoint(int which, vec3 pos, vec4 color, float width);
void Breakpoint(int);

DebugDrawBillboard function

int DebugDrawBillboard(const string &in path, vec3 center, float scale, vec4 color, DebugDrawLifespanType lifespan);

Draw an image that exists in the 3D world space (as opposed to being a 2D HUD overlay image). This image is rotated to face the camera, and will scale when you get closer to it (since it lives in 3D).

The return value is an id that you can pass to DebugDrawRemove to delete the object at a future time.

Parameters:

  • path - The path to the file that contains this image. Should be specified relative to the game install directory (e.g. Data/Textures/ui/stealth_debug/exclamation.tga)
  • center - The origin of the billboard image in 3D space. The center of the image will sit on this point.
  • scale - The relative size of the image. Set to 1.0 to start with, and change it from there if need be. WARNING: The scale parameter might not do anything right now. (TODO: Verify, and remove this warning if you find out that the scale parameter actually does work, or remove this todo if it doesn't work)
  • color - The RGBA tint you want to apply to the object. You can use this to make the object transparent if you set the value to vec4(1.0, 1.0, 1.0, alpha_value_between_0_and_1).
  • lifespan - How long you would like this billboard to stick around before it automatically gets deleted by the engine. See DebugDrawLifespanType for the values you can pass here.
    Note that you can't move billboards around, so you might need to set a lifetime lower that _persistent, and call draw repeatedly, depending on how often you expect your object to move.

DebugDrawCircle function

int DebugDrawCircle(mat4 transform, vec4 color, DebugDrawLifespanType lifespan);

Draw a circle that exists in the 3D world space (as opposed to being a 2D HUD overlay circle shape).

The return value is an id that you can pass to DebugDrawRemove to delete the object at a future time.

Parameters:

  • transform - The transformation matrix describing the translation, rotation, and scale of the circle. TODO: What shape is the circle if the identity matrix is passed? Where its origin (center of the cirlce?), and which plane will it lie on?
  • color - The color to draw the entire circle. You can specify transparency using an alpha value between 0.0 (fully transparent, and thus invisible) and 1.0 (fully opaque).
  • lifespan - How long you would like this circle to stick around before it automatically gets deleted by the engine. See DebugDrawLifespanType for the values you can pass here.
    Note that you can't move debug draw circles around, so you might need to set a lifetime lower that _persistent, and call draw repeatedly, depending on how often you expect your object to move.

DebugDrawLine function

int DebugDrawLine(vec3 start, vec3 end, vec3 color, DebugDrawLifespanType lifespan);

Draw a line that exists in the 3D world space (as opposed to being a 2D HUD overlay line). This line will be opaque, and will only have a single color over the entire span of the line.

The return value is an id that you can pass to DebugDrawRemove to delete the object at a future time.

Parameters:

  • start - The point in 3D space of the beginning of the line. The line will begin at this point. (If you're confused about start/end, then don't worry about it. There isn't really a distinction between the two points).
  • end - The point in 3D space of the end of the line. The line will end at this point. (If you're confused about start/end, then don't worry about it. There isn't really a distinction between the two points).
  • lifespan - How long you would like this line to stick around before it automatically gets deleted by the engine. See DebugDrawLifespanType for the values you can pass here.
    Note that you can't move lines around, so you might need to set a lifetime lower that _persistent, and call draw repeatedly, depending on how often you expect your object to move.

DebugDrawLine function (multiple colors)

int DebugDrawLine(vec3 start, vec3 end, vec3 start_color, vec3 end_color, DebugDrawLifespanType lifespan);

Draw a line that exists in the 3D world space (as opposed to being a 2D HUD overlay line). This line will be opaque, and will have a color gradient between the start and end of the line.

The return value is an id that you can pass to DebugDrawRemove to delete the object at a future time.

Parameters:

  • start - The point in 3D space of the beginning of the line. The line will begin at this point. The start_color will be applied to this point.
  • end - The point in 3D space of the end of the line. The line will end at this point. The end_color will be applied to this point.
  • start_color - The color to draw the beginning of the line. The line will begin with this color, and will be blended to the value at the end of the line. This will be an opaque color.
    If you want to draw a line that has transparency, see the DebugDrawLine overload that supports transparency.
  • end_color - The color to draw the end of the line. The line will end with this color, and will be blended to the value at the beginning of the line. This will be an opaque color.
    If you want to draw a line that has transparency, see the DebugDrawLine overload that supports transparency.
  • lifespan - How long you would like this line to stick around before it automatically gets deleted by the engine. See DebugDrawLifespanType for the values you can pass here.
    Note that you can't move lines around, so you might need to set a lifetime lower that _persistent, and call draw repeatedly, depending on how often you expect your object to move.

DebugDrawLine function (transparent)

int DebugDrawLine(vec3 start, vec3 end, vec4 start_color, vec4 end_color, DebugDrawLifespanType lifespan);

Draw a line that exists in the 3D world space (as opposed to being a 2D HUD overlay line). This line can be transparent, and will have a color gradient between the start and end of the line.

The return value is an id that you can pass to DebugDrawRemove to delete the object at a future time.

Parameters:

  • start - The point in 3D space of the beginning of the line. The line will begin at this point. The start_color will be applied to this point.
  • end - The point in 3D space of the end of the line. The line will end at this point. The end_color will be applied to this point.
  • start_color - The color to draw the beginning of the line. The line will begin with this color, and will be blended to the value at the end of the line.
    You can specify transparency using an alpha value between 0.0 (fully transparent, and thus invisible) and 1.0 (fully opaque).
  • end_color - The color to draw the end of the line. The line will end with this color, and will be blended to the value at the beginning of the line.
    You can specify transparency using an alpha value between 0.0 (fully transparent, and thus invisible) and 1.0 (fully opaque).
  • lifespan - How long you would like this line to stick around before it automatically gets deleted by the engine. See DebugDrawLifespanType for the values you can pass here.
    Note that you can't move lines around, so you might need to set a lifetime lower that _persistent, and call draw repeatedly, depending on how often you expect your object to move.

DebugDrawLines function

int DebugDrawLines(const array<vec3> &vertices, vec4 color, DebugDrawLifespanType lifespan);

Draw multiple lines that exists in the 3D world space (as opposed to being 2D HUD overlay lines). These lines can be transparent, and will have a single color that applies to all the lines.

The return value is an id that you can pass to DebugDrawRemove to delete the object at a future time.

Parameters:

  • vertices - A list of points in 3D space of the beginning and ends of the lines. TODO: Are the lines automatically connected, or do you specify start/end pairs?
  • color - The color to draw all the lines. You can specify transparency using an alpha value between 0.0 (fully transparent, and thus invisible) and 1.0 (fully opaque).
  • lifespan - How long you would like these lines to stick around before it automatically gets deleted by the engine. See DebugDrawLifespanType for the values you can pass here.
    Note that you can't move the lines around, so you might need to set a lifetime lower that _persistent, and call draw repeatedly, depending on how often you expect your object to move.

DebugDrawPoint function

int DebugDrawPoint(vec3 pos, vec4 color, DebugDrawLifespanType lifespan);

Draw a point that exists in the 3D world space (as opposed to being a 2D HUD overlay point).

The return value is an id that you can pass to DebugDrawRemove to delete the object at a future time.

Parameters:

  • pos - The origin of the point in 3D space. The point will be drawn here.
  • color - The color to draw the point. You can specify transparency using an alpha value between 0.0 (fully transparent, and thus invisible) and 1.0 (fully opaque).
  • lifespan - How long you would like this point to stick around before it automatically gets deleted by the engine. See DebugDrawLifespanType for the values you can pass here.
    Note that you can't move debug draw points around, so you might need to set a lifetime lower that _persistent, and call draw repeatedly, depending on how often you expect your object to move.

DebugDrawRemove function

void DebugDrawRemove(int debug_draw_id);

Delete a debug draw object that you previously created.

Parameters:

  • debug_draw_id - The debug draw id returned from a previously called DebugDraw* function, that you now want to delete.
int DebugDrawRibbon(DebugDrawLifespanType lifespan);
int DebugDrawRibbon(vec3 start, vec3 end, vec4 start_color, vec4 end_color, float start_width, float end_width, DebugDrawLifespanType lifespan);
int DebugDrawText(vec3 pos, string text, float scale, bool screen_space, DebugDrawLifespanType lifespan);
int DebugDrawWireBox(vec3 pos, vec3 dimensions, vec3 color, DebugDrawLifespanType lifespan);
int DebugDrawWireCylinder(vec3 pos, float radius, float height, vec3 color, DebugDrawLifespanType lifespan);
int DebugDrawWireMesh(string path, mat4 transform, vec4 color, DebugDrawLifespanType lifespan);
int DebugDrawWireScaledSphere(vec3 pos, float radius, vec3 scale, vec3 color, DebugDrawLifespanType lifespan);
int DebugDrawWireScaledSphere(vec3 pos, float radius, vec3 scale, vec4 color, DebugDrawLifespanType lifespan);
int DebugDrawWireSphere(vec3 pos, float radius, vec3 color, DebugDrawLifespanType lifespan);

DebugText function

void DebugText(string key, string display_text, float lifetime_in_seconds);

Write a line of text in the debug window, that will stick around for a short period of time.

You must pass a long value for lifetime_in_seconds (not recommended) or keep calling this function (recommended) if you want this text to remain in the debug window.

The debug window is accessible via Top Bar -> Windows -> Debug, and only visible if the editor is active (F1 key to activate).

Parameters:

  • key - The virtual "slot" that this debug text should reside in. If you call DebugText again with the same key value, it will overwrite the previous value.
    Make sure to make this unique if you don't want overwriting to happen (use a random unique value, and/or append an index to the key if you're calling this inside a loop).
  • display_text - The text you want to display. If you want to display a non-text value, one trick is to concatenate the value to a string: "" + value
  • lifetime_in_seconds - The number of seconds you want the text to stick around for. The engine will automatically remove the debug text after this time has elapsed.
    You may want to call this function repeatedly if you want text to stick around, instead of using an extraordinarily long value for lifetime_in_seconds (say, longer than 5.0 or 10.0 seconds). That way you can be sure that your debug values are actually fresh.
void DisplayError(const string &in title, const string &in contents);
void EnterTelemetryZone(const string &in name);
string GetBuildTimestamp( );
string GetBuildVersionFull( );
string GetBuildVersionShort( );
uint64 GetPerformanceCounter();  // Get high precision time info for profiling
uint64 GetPerformanceFrequency();  // Used to convert PerformanceCounter into seconds
void LeaveTelemetryZone();
void Log( LogType level, const string &in str );
void PrintCallstack();
void StartStopwatch();
uint64 StopAndReportStopwatch();

Level and Campaign Data Access Functions

Campaign GetCampaign(string& campaign_id);
array<Campaign>@ GetCampaigns();
string GetCurrCampaignID();
string GetCurrLevel();
string GetCurrLevelAbsPath();
string GetCurrLevelID();
string GetCurrLevelName();
string GetCurrLevelRelPath();
string GetInterlevelData(const string &in);
string GetLevelName(const string& path);
void SetCampaignID(string id);
void SetInterlevelData(const string &in, const string &in);

Mod Access Functions

void DeactivateAllMods();
array<ModID>@ GetActiveModSids();
string GetCurrentLevelModsourceID();
string GetCurrentMenuModsourceID();
array<ModID>@ GetModSids();
bool ModActivation(ModID& sid, bool active);
bool ModCanActivate(ModID& id);
string ModGetAuthor(ModID& id);
array<ModLevel>@ ModGetCampaignLevels(ModID& sid);
string ModGetDescription(ModID& id);
string ModGetID(ModID& id);
array<MenuItem>@ ModGetMenuItems(ModID& sid);
string ModGetName(ModID& id);
string ModGetPath(ModID& sid);
array<ModLevel>@ ModGetSingleLevels(ModID& sid);
int ModGetSource(ModID& id);
string ModGetTags(ModID& id);
string ModGetThumbnail(ModID& sid);
UserVote ModGetUserVote(ModID& sid);
string ModGetValidityString(ModID& sid);
string ModGetVersion(ModID& id);
bool ModIsActive(ModID& id);
bool ModIsCore(ModID& id);
bool ModIsFavorite(ModID& id);
bool ModIsValid(ModID& id);
bool ModNeedsRestart(ModID& id);
void ReloadMods();
void RequestModSetFavorite(ModID& id, bool fav);
void RequestModSetUserVote(ModID& id, bool voteup);

Editor Manipulation Functions

bool CheckSaveLevelChanges();
void ClearUndoHistory();
void DeselectAll();
bool EditorEnabled();
bool EditorModeActive();
void LoadEditorLevel();
void LoadLevel(string level_path);
void LoadLevelID(string id);
bool MediaMode();
void RibbonItemFlash(const string &in);
void RibbonItemSetEnabled(const string &in, bool);
void RibbonItemSetToggled(const string &in, bool);
void SetMediaMode(bool);
int StorageGetInt32(string index);
string StorageGetString(string index);
bool StorageHasInt32(string index);
bool StorageHasString(string index);
void StorageSetInt32(string index, int value);
void StorageSetString(string index, string value);

Input Functions

array<string>@ GetAvailableBindingCategories();
array<string>@ GetAvailableBindings(const string &in);
string GetBindingValue(string binding_category, string binding);
bool GetInputDown(int controller_id, const string &in input_label);
bool GetInputDownFiltered(int controller_id, const string &in input_label, uint filter);
uint GetInputMode();
bool GetInputPressed(int controller_id, const string &in input_label);
bool GetInputPressedFiltered(int controller_id, const string &in input_label, uint filter);
string GetLocaleStringForScancode(int scancode);
float GetLookXAxis(int controller_id);
float GetLookYAxis(int controller_id);
float GetMoveXAxis(int controller_id);
float GetMoveYAxis(int controller_id);
string GetStringDescriptionForBinding( const string &in, const string &in );
void ResetBinding(string binding_category, string binding);
void SetBindingValue(string binding_category, string binding, string value);
void SetGrabMouse(bool);
void StartTextInput();
void StopTextInput();

Keyboard Raw Access Functions

These functions are for doing low level interfacing with the keyboard.

array<KeyboardPress>@ GetRawKeyboardInputs();  // Get a list of all the current keyboard events
bool DebugKeysEnabled();  // Find out if the debug keys are enabled
bool IsKeyDown(int key_code);  // Find out if a key with the specified scan code is currently pressed
int GetCodeForKey(string key_name);  // Get the scan code for a key, by a friendly name - TODO: Add list of mappings
void ActivateKeyboardEvents();  // Start listening for keyboard events in this script
void DeactivateKeyboardEvents();  // Stop listening for keyboard events in this script
void SetKeyboardBindingValue(string binding_category, string binding, uint32 scancode);
// Set an input binding for the given key. Pass "key" for binding_category, and the action name for binding

File Access Functions

bool FileExists(string &in);  // Does a file with the given path exist

Display Access Functions

array<vec2>@ GetPossibleResolutions();
int GetScreenHeight();
int GetScreenWidth();
bool GetSplitscreen();

Steam Workshop Functions

bool IsWorkshopAvailable();
bool IsWorkshopMod(ModID& id);
bool IsWorkshopSubscribed(ModID& id);
float WorkshopTotalDownloadProgress();
uint WorkshopDownloadingCount();
uint WorkshopDownloadPendingCount();
uint WorkshopNeedsUpdateCount();
uint WorkshopSubscribedNotInstalledCount();
void OpenModAuthorWorkshopPage(ModID& id);
void OpenModWorkshopPage(ModID& id);
void OpenWorkshop();
void RequestWorkshopSubscribe(ModID& id);
void RequestWorkshopUnSubscribe(ModID& id);

Classes

array class

class array<T>;

A generic array for holding indexable lists of values of the same type.

See this page for documentation on this class: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_datatypes_arrays.html


mat3 class

class mat3;

A 3x3 matrix for doing linear algebra (transformations on objects)

methods

mat3()  // Default constructor. Does no initialization
mat3(const mat3 &in)  // Copy constructor

operators

float& opIndex(uint index)  // Index operator
const float& opIndex(uint index) const  // Const index operator
vec3 opMul(const vec3 &in) const  // Multiply operator (mat3 * vec3)

related functions

mat3 Mat3FromQuaternion(const quaternion &in);  // Convert a quaternion to its corresponding 3x3 rotation matrix

mat4 class

class mat4;

A 4x4 matrix for doing linear algebra (transformations on objects)

methods

mat4();  // Default constructor. Does no initialization
mat4(const mat4 &in);  // Copy constructor
void SetTranslationPart(vec3);  // Set the translation components of the matrix
vec3 GetTranslationPart() const;  // Get the translation components of the matrix
void SetRotationPart(mat4);  // Set (only) the rotation components of the matrix (also overwriting all scale components)
mat4 GetRotationPart() const;  // Get a copy of the matrix, preserving only the rotation (and scale) components
void SetRotationX(float angle_in_radians);  // Set the x rotation components (also overwriting y/z scale components)
void SetRotationY(float angle_in_radians);  // Set the y rotation components (also overwriting x/z scale components)
void SetRotationZ(float angle_in_radians);  // Set the z rotation components (also overwriting x/y scale components)
void SetColumn(int, vec3);  // Set the first three values in a column of the matrix
vec3 GetColumn(int);  // Get the first three values from a column of the matrix

operators

float &opIndex(uint);  //Index operator
const float &opIndex(uint) const;  // Const index operator
mat4 opMul(mat4) const;  // Multiply operator (mat4 * mat4)
vec3 opMul(vec3) const;  // Multiply operator (mat4 * vec3)
vec3 opMul(vec4) const;  // Multiply operator (mat4 * vec4)

related functions

mat4 mix(const mat4 &in a, const mat4 &in b, float alpha);  // Linear interpolation between two 4x4 matrices
mat4 transpose(mat4);  // Get the mathematical transpose of this 4x4 matrix - https://en.wikipedia.org/wiki/Transpose
mat4 Mat4FromQuaternion(const quaternion &in);  // Convert a quaternion to its corresponding 4x4 rotation matrix
quaternion QuaternionFromMat4(const mat4 &in);  // Convert a 4x4 matrix to its corresponding quaternion

quaternion class

class quaternion;

A quaternion for doing linear algebra (rotations on objects)

properties

float x;
float y;
float z;
float w;

methods

quaternion();  // Default constructor. Sets to identity. Same result as quaternion(0.0f, 0.0f, 0.0f, 1.0f);
quaternion(const quaternion &in);  // Copy constructor
quaternion(float, float, float, float);  // Construct from components
quaternion(vec4); // Constructor from rotation, in axis-angle form (axis.x, axis.y, axis.z, angle_in_radians)

operators

quaternion& opAssign(const quaternion &in);  // Assignment operator (quaternion = quaternion) - by value, not by reference
quaternion& opAddAssign(const quaternion &in);  // Addition-and-assign operator (quaternion += quaternion)
bool opEquals(const quaternion &in) const;  // Equality operator (quaternion == quaternion)
quaternion opAdd(const quaternion &in) const;  // Addition operator (quaternion + quaternion)
quaternion opMul(const quaternion &in) const;  // Multiplication operator (quaternion * quaternion)
vec3 opMul(const vec3 &in) const;  // Multiply operator (quaternion * vec3)

related functions

mat3 Mat3FromQuaternion(const quaternion &in);  // Convert a quaternion to its corresponding 3x3 rotation matrix
mat4 Mat4FromQuaternion(const quaternion &in);  // Convert a quaternion to its corresponding 4x4 rotation matrix
quaternion mix(const quaternion &in a, const quaternion &in b, float alpha);  // Linear interpolation between two quaternions
quaternion QuaternionFromMat4(const mat4 &in);  // Convert a 4x4 matrix to its corresponding quaternion
vec3 Mult(quaternion, vec3);  // Applies a quaternion rotation to a vector
void GetRotationBetweenVectors(const vec3 &in start, const vec3 &in end, quaternion &out rotation);  // Get a relative rotation from one direction vector to another

vec2 class

class vec2;

A two-dimensional vector, useful for specifying x/y coordinates

properties

float x;
float y;

methods

vec2();  // Default constructor. Same as vec2(0.0f, 0.0f)
vec2(const vec2 &in);  // Copy constructor
vec2(float);  // Single value constructor. Same as vec2(0.0f, 0.0f)
vec2(float, float);  // Construct from components

operators

vec2& opAddAssign(const vec2 &in);  // Add-and-assign operator (vec2 += vec2)
vec2& opSubAssign(const vec2 &in);  // Subtract-and-assign operator (vec2 -= vec2)
vec2& opMulAssign(float);  // Multiply-and-assign operator (vec2 *= float)
vec2& opDivAssign(float);  // Divide-and-assign operator (vec2 /= float)
bool opEquals(const vec2 &in) const;  // Equality operator (vec2 == vec2)
vec2 opAdd(const vec2 &in) const;  // Add operator (vec2 + vec2)
vec2 opSub(const vec2 &in) const;  // Subtract operator (vec2 - vec2)
vec2 opMul(float) const;  // Scalar multiply operator (vec2 * float)
vec2 opMul_r(float) const;  // Scalar multiply operator (float * vec2)
vec2 opDiv(float) const;  // Scalar divide operator (vec2 / float)

related functions

float distance(const vec2 &in, const vec2 &in);  // Get the distance between two vec2 values
float distance_squared(const vec2 &in, const vec2 &in);  // Get the squared distance between two vec2 values (faster than distance function, no square-root done)
float dot(const vec2 &in, const vec2 &in);  // Calculate the dot-product between two vec2 values - https://en.wikipedia.org/wiki/Dot_product
vec2 mix(vec2 a, vec2 b, float alpha);  // Linear interpolation between two vec2 values
vec2 normalize(const vec2 &in);  // Shrink or grow a vec2 value to be unit length, with the same direction
vec2 reflect(const vec2 &in vec, const vec2 &in normal);
// Calculate the reflection of a vector, relative to the surface with the given normal - https://en.wikipedia.org/wiki/Reflection_(mathematics)

vec3 class

class vec3;

A three-dimensional vector, useful for specifying x/y/z coordinates

properties

float x;
float y;
float z;

methods

vec3();  // Default constructor. Same as vec3(0.0f, 0.0f, 0.0f)
vec3(const vec3 &in);  // Copy constructor
vec3(float value);  // Single value constructor. Same as vec3(value, value, value)
vec3(float x, float y, float z);  // Construct from components

operators

vec3& opAddAssign(const vec3 &in);  // Add-and-assign operator (vec3 += vec3)
vec3& opSubAssign(const vec3 &in);  // Subtract-and-assign operator (vec3 -= vec3)
vec3& opMulAssign(float);  // Multiply-and-assign operator (vec3 *= float)
vec3& opDivAssign(float);  // Divide-and-assign operator (vec3 /= float)
bool opEquals(const vec3 &in) const;  // Equality operator (vec3 == vec3)
vec3 opAdd(const vec3 &in) const;  // Add operator (vec3 + vec3)
vec3 opSub(const vec3 &in) const;  // Subtract operator (vec3 - vec3)
vec3 opMul(float) const;  // Scalar multiply operator (vec3 * float)
vec3 opMul_r(float) const;  // Scalar multiply operator (float * vec3)
vec3 opDiv(float) const;  // Scalar divide operator (vec3 / float)
float& opIndex(int index);  // Access vector components by index

related functions

float distance(const vec3 &in, const vec3 &in);  // Get the distance between two vec3 values
float distance_squared(const vec3 &in, const vec3 &in);  // Get the squared distance between two vec3 values (faster than distance function, no square-root done)
float dot(const vec3 &in, const vec3 &in);  // Calculate the dot-product between two vec3 values - https://en.wikipedia.org/wiki/Dot_product
float xz_distance(const vec3 &in, const vec3 &in);  // Get the distance on the x/z plane between two vec3 values (flat)
float xz_distance_squared(const vec3 &in, const vec3 &in);
// Get the squared distance on the x/z plane between two vec3 values (flat. faster than xz_distance function, no square-root done)
vec3 cross(const vec3 &in, const vec3 &in);  // Calculate the cross-product between two vec3 values - https://en.wikipedia.org/wiki/Cross_product
vec3 mix(vec3 a, vec3 b, float alpha);  // Linear interpolation between two vec3 values
vec3 Mult(quaternion, vec3);  // Applies a quaternion rotation to a vector
vec3 normalize(const vec3 &in);  // Shrink or grow a vec3 value to be unit length, with the same direction
vec3 reflect(const vec3 &in vec, const vec3 &in normal);
// Calculate the reflection of a vec3, relative to the surface with the given normal - https://en.wikipedia.org/wiki/Reflection_(mathematics)
void GetRotationBetweenVectors(const vec3 &in start, const vec3 &in end, quaternion &out rotation);  // Get a relative rotation from one direction vector to another

vec4 class

class vec4;

A four-dimensional vector, useful for specifying r/g/b/alpha colors

properties

float x;
float y;
float z;
float a;

methods

vec4();  // Default constructor. Same as vec4(0.0f, 0.0f, 0.0f, 1.0f)
vec4(const vec4 &in);  // Copy constructor
vec4(const vec3 &in, float a);  // Copy constructor, with custom alpha
vec4(float value);  // Single value constructor. Same as vec4(value, value, value, value)
vec4(float x, float y, float z, float a);  // Construct from components

related functions

vec4 mix(vec4 a, vec4 b, float alpha);  // Linear interpolation between two vec4 values (including alpha)

ASContext class

class ASContext;

A helper class that lets you print the global variables from a running angel script context

methods

void PrintGlobalVars();  // Print the global variables in this script context in the console

related global variables

ASContext context;  // The context for the currently running script, whether that is the menu script, level script, character script, or hotspot script

class AnimationClient;  // A game object component on a RiggedObject that lets you modify animations
class BoneTransform;  // An efficient way to define an unscaled transformation
class Camera;  // A camera object, either bound to the editor camera or the player camera
class Campaign;  // A helper class that helps you retrieve data about a campaign ("story")
class CharacterScriptGetter;  // A helper class that lets you load a character XML and provide access to its data
class EnvObject;  // An environmental game object, such as a plant or rock
class Hotspot;  // A game object that supports custom per-object logic, and possibly supports enter/exit events
class ItemObject;  // An item game object, such as a weapon or an inert object you can pick up
class JSON;  // A JSON object, for reading and writing JSON files
class JSONValue;  // An individual value (variable or array) inside a JSON object
class KeyboardPress;
class Level;
// An instance of the currently running level, which gives you access to parameters and send global "level" messages
class LevelDetails;  // A helper class providing details (just Name for now) for a ModLevel (not actually just mods)
class MenuItem;  // A helper class to retrieve data about a main menu/play menu entry added by a mod
class ModID;  // A helper class used to access mods and to query if a mod is "valid"
class ModLevel;  // A helper class to retrieve data about a level (not just mod levels)
class MovementObject;  // A character game object
class Object;  // The base class for all game objects, for accessing common behavior
class PathPointObject;
class Physics;
class RiggedObject;  // A game object component that is attached to a MovementObject, that supports skeletal rigging
class ScriptParams;  // A class that lets you access level or game object script parameters
class Skeleton;  // A game object component on a RiggedObject that handles skeletal rigging
class TextCanvasTexture;
class TextMetrics;
class TextStyle;