-
Notifications
You must be signed in to change notification settings - Fork 1
Functions
This page contains documentation for the primary Extra Utilities functions.
Key:
function ExampleFunction(parameter: [param type]) -> [return type]These are functions related to the camera in game and it's attributes.
function GetCameraOrigins() -> tableGets the values of the camera origins that can be useful for computing perspective transformations. See the table here.
function GetCameraTransformMatrix() -> matrixGets the transform matrix of the current camera.
function GetCameraViewMatrix() -> matrixGets the view matrix of the current camera.
function GetCameraMaxZoom() -> numberGets the maximum zoom factor for all cameras.
function SetCameraMaxZoom(zoom: number) -> nilSets the maximum zoom factor for all cameras.
function GetCameraMinZoom() -> numberGets the minimum zoom factor for all cameras.
function SetCameraMinZoom(zoom: number) -> nilSets the minimum zoom factor for all cameras.
function GetCameraView() -> numberGets the current camera view mode. See the camera enum for options.
function SetCameraView(view: number) -> nilSets the current camera view mode. I highly recommend using the provided constants as opposed to the raw number indices.
function GetCameraZoom(camera: number) -> numberGets the zoom factor of the given camera. See the camera enum for options.
function SetCameraZoom(camera: number, zoom: number) -> nilSets the zoom factor of the given camera.
Note this will override the min/max zoom until the player tries to zoom with -+.
These functions control the selection that is handled through the control panel.
function SelectAdd(h: handle) -> nilAdds the given unit to the local player's selection.
function SelectNone() -> nilClears the local player's selection (equivalent to pressing tab with stock keybinds).
function SelectOne(h: handle) -> nilSets the local player's selection to the given handle and de-selects everything else.
These functions can query and modify attributes about the environment like gravity and lighting.
function GetFog() -> FogReturns a table with the current map fog parameters.
function SetFog(r: number, g: number, b: number, start: number, ending: number) -> nil
function SetFog(newFog: Fog) -> nilSets the current map fog parameters. Can take either five number parameters or a fog table.
function GetGravity() -> vectorGets the current value of the local player's gravity velocity vector.
function SetGravity(x: number, y: number, z: number) -> nil
function SetGravity(v: vector) -> nilSets the local player's current gravity velocity vector. This affects all units owned by the local player. Can take either three number parameters or a bz vector userdata. Multiplayer note: must be manually synced between clients, not doing so may result in things like ai and ordnance becoming nondeterministic.
function GetSunAmbient() -> ColorReturns a table with the current sun ambient parameters.
function SetSunAmbient(r: number, g: number, b: number) -> nil
function SetSunAmbient(newColor: Color) -> nilSets the current map sun ambient parameters. Can take either three number parameters or a color table.
function GetSunDiffuse() -> ColorReturns a table with the current sun diffuse parameters.
function SetSunDiffuse(r: number, g: number, b: number) -> nil
function SetSunDiffuse(newColor: Color) -> nilSets the current map sun diffuse parameters. Can take either three number parameters or a color table.
function GetSunSpecular() -> ColorReturns a table with the current sun specular parameters.
function SetSunSpecular(r: number, g: number, b: number) -> nil
function SetSunSpecular(newColor: Color) -> nilSets the current map sun specular parameters. Can take either three number parameters or a color table.
These functions act on game objects (handles) to query and modify various attributes.
function SetAsUser(h: handle) -> nilSets the local player's user ship to the given handle.
function IsCommTowerPowered(h: handle) -> booleanGets if the given comm tower is powered or not, throws an error if the handle is not a comm tower.
function GetHandle(obj: GameObject*) -> intConverts a GameObject* into a handle that can be used in lua.
function SetHeadlightDiffuse(h: handle, r: number, g: number, b: number) -> nilSets the diffuse color of the headlight of the given object (if it exists).
function SetHeadlightSpecular(h: handle, r: number, g: number, b: number) -> nilSets the specular color of the headlight of the given object (if it exists).
function SetHeadlightRange(h: handle, innerAngle: number, outerAngle: number, falloff: number) -> nilSets the range parameters of the headlight of the given object (if it exists). From the Ogre documentation: "Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them." 1.0 falloff is linear, <0 is slower and >0 is faster. Angles measured in radians.
function SetHeadlightVisible(visible: bool) -> nilSets whether or not a headlight is visible or hidden.
function GetMass(h: handle) -> numberGets the mass of the given object (most ships default to 1750 KG afaik).
function SetMass(h: handle) -> nilSets the mass of the given object. This affects collisions and knockback.
function GetObj(h: handle) -> GameObject*Converts a handle into a GameObject* that can be used in patching and debugging.
function GetRadarPeriod(h: handle) -> numberGets the radar scan period for the given object (if it has a radar).
function SetRadarPeriod(h: handle, period: number) -> nilSets the radar scan period for the given object.
function GetRadarRange(h: handle) -> numberGets the radar range of the given object (if it has a radar).
function SetRadarRange(h: handle, range: number) -> nilSets the radar range of the given object.
function GetVelocJam(h: handle) -> numberGets the velocjam value for the given object (in m/s).
function SetVelocJam(h: handle) -> nilSets the velocjam value for the given object.
function GetFullscreen() -> boolGets if the game is currently in fullscreen.
function GetGameResolution() -> integer, integerGets the actual resolution of the game, returns two values for X and Y pixel count.
function GetUIScaling() -> integerGets the current UI scaling factor (1, 2, 3, etc).
These functions handle input/output that the stock game doesn't provide.
function GetGameKey(key: string) -> boolGets whether or not a key is held.
A full list of keys can be found here.
These functions work exclusively in multiplayer to help with various things.
function BuildAsyncObject(...) -> handleFunctions the same as BuildObject except the resulting object is always asynchronous regardless of hosting status.
function BuildSyncObject(...) -> handleFunctions the same as BuildObject except the resulting object is always synchronized regardless of hosting status.
function GetLives() -> numberGets the local player's life count.
function SetLives(lives: number) -> nilSets the local player's life count. This must be called during or after Start(), otherwise lives are not initialized in the map yet.
function GetMyNetID() -> numberGets the net ID of the local player (the parameter that would appear in CreatePlayer())
function GetShowScoreboard() -> boolGets if the multiplayer scoreboard is visible.
function SetShowScoreboard(state: bool) -> nilSets the state of the multiplayer scoreboard. (Default toggle key M).
function DisableStartingRecycler() -> nilPrevents the starting recycler from spawning in strategy and MPI missions. CALL LOOSE IN THE SCRIPT PRE-START!
These functions modify the behavior of ordnance.
function BuildOrdnance(odf: string, transform: matrix, owner: handle) -> Ordnance*Builds an ordnance of the given odf (omit the .odf extension like with BuildObject) at the given transform matrix. You must also provide an owner handle since the game appears to require this. Passing in GetPlayerHandle() should be sufficient unless you want to utilize the ownership for something else. Returns a handle to the ordnance object that can be used in GetOrdnanceAttribute(). Ordnances are short lived, DO NOT access this value for longer than it's lifespan. If you need to hold on to a handle you should verify it still exists by checking current time minus it's init time (from GetOrdnanceAttribute) is less than the lifespan defined in the odf. You can also use the exu.BulletHit callback to detect if the value is no longer valid, however this does not account for ordnance despawning or being destroyed through other means.
Multiplayer Note: You should not Send() another player a local ordnance handle, they are likely client side and I haven't rigorously tested it in MP.
function GetOrdnanceAttribute(ordnanceHandle: Ordnance*, attribute: AttributeCode) -> anyQueries an ordnance handle for certain values. See the valid attribute codes.
function GetCoeffBallistic() -> numberGets the global ballistic coefficient (how much mortars drop, default 4.9f).
function SetCoeffBallistic(coeff: number) -> nilSets the global ballistic coefficient. Multiplayer note: must be manually synced, otherwise ordnance may behave nondeterministically.
These functions can get various information from the operating system (windows only).
function GetScreenResolution() -> number, numberGets the screen resolution for the local user. First value in the multi-return is the width in pixels, second is the height.
function MessageBox(message: string) -> nilDisplays an application modal windows message box with the given message, useful for debugging.
These functions control various patches to modify game behavior.
function AddScrapSilent(team, amount) -> numberWrapper for AddScrap that does not trigger the exu.AddScrap callback.
function GetGlobalTurbo() -> boolGets whether or not the global turbo mode patch is enabled (default false).
function SetGlobalTurbo(state: bool) -> nilSets the state of the global turbo mode patch.
function GetUnitTurbo(h: handle) -> boolGets whether a unit has turbo enabled (off by default).
function SetUnitTurbo(h: handle, state: bool) -> nilSets turbo for an individual unit that overrides the global setting.
function GetOrdnanceVelocInheritance() -> boolGets the state of the ordnance velocity inheritance patch (see below).
function SetOrdnanceVelocInheritance(state: bool) -> nilMakes projectiles inherit the velocity of the shooter, and patches the TLI for both the player and AI to account for this, currently does NOT work in multiplayer, and the TLI on mortars is not accurate.
function GetShotConvergence() -> boolReturns whether or not the hovercraft shot convergence patch is enabled.
function SetShotConvergence(enabled: bool) -> nilSets the hovercraft shot convergence patch true or false (default false).
These functions query and modify certain options in the stock options menu.
Reminder, just because you can change these settings via script doesn't mean you should - these have accessibility implications and forcing TLI off for example can make the game frustrating to play.
function GetDifficulty() -> numberGets the local player's difficulty setting.
function SetDifficulty(difficulty: number) -> nilSets the local player's difficulty setting. See the difficulty enum for options.
Note that it won't change what it says in the menu, but it will in fact change in-game. It also won't work in multiplayer where the difficulty is locked to very hard.
function GetAutoLevel() -> boolGets the local player's automatic leveling setting.
function SetAutoLevel(newAL: bool) -> nilSets the local player's automatic leveling setting.
function GetTLI() -> boolGets the local player's target lead indicator setting.
function SetTLI(newTLI: bool) -> nilSets the local player's target lead indicator setting.
function GetReverseMouse() -> boolGets the local player's reverse mouse setting.
function SetReverseMouse(newMouse: bool) -> nilSets the local player's reverse mouse setting.
These functions can query and modify the in game radar.
function GetRadarState() -> numberGets the state of the radar. See the radar enum for options. 0 = minimap 1 = radar
function SetRadarState(state: number) -> nilSets the current radar state.
These functions can query various information about the smart reticle.
function GetReticleMatrix() -> matrixGets the transform matrix of the reticle.
function GetReticleObject() -> handleGets the handle of the object under the local user's reticle, as well as the satellite cursor.
(The object that appears next to "SPACE No Action (object)" in the command interface).
The object must be within smart reticle range in order to be detected.
function GetReticlePos() -> vectorGets the location on terrain of the player's reticle.
Must be within smart reticle range, otherwise it will return the last known value.
Additionally, while looking at an object or into the sky it will return the last known value.
function GetReticleRange() -> floatGets the current range of the smart cursor (default 200m).
function SetReticleRange(range: number) -> nilSets the current range of the smart cursor.
These functions can query various information about the satellite view.
function GetSatCameraPos() -> vectorGets the current position of the player's camera in satellite view.
The Y coordinate becomes static when you pan the camera, otherwise it follows the player's Y coordinate.
function GetSatClickPos() -> vectorGets the last position the player clicked in satellite view.
Persists after satellite is closed so be sure to handle this case.
function GetSatCursorPos() -> vectorGets the current position of the cursor in satellite view.
If satellite is disabled it will return the last known position of the cursor.
function GetSatMaxZoom() -> numberGets the maximum zoom level of satellite view.
Default = 8
function SetSatMaxZoom(zoom: float) -> nilSets the maximum zoom level of satellite view.
Default = 8
function GetSatMinZoom() -> numberGets the minimum zoom level of satellite view.
Default = 2
function SetSatMinZoom(zoom: number) -> nilSets the minimum zoom level of satellite view.
Default = 2
function GetSatPanSpeed() -> numberGets the current pan speed of satellite view.
Default = 1250
function SetSatPanSpeed(speed: number) -> nilSets the current pan speed of satellite view.
Default = 1250
function GetSatState() -> boolGets the satellite state of the local player. See the satellite enum for options.
1 = enabled
0 = disabled
function GetSatZoom() -> numberGets the current zoom level of satellite view.
Default = 4
function SetSatZoom(zoom: number) -> nilSets the current zoom level of satellite view.
Make sure to stay within the boundaries defined by min and max zoom, otherwise it'll cause issues.
This function can get information from steam.
function GetSteam64() -> stringGets the Steam 64 ID of the local player.
These functions can query information about the stock sound bar settings.
function GetMusicVolume() -> numberGets the value of the music slider from 0-10.
function GetEffectsVolume() -> numberGets the value of the effects slider from 0-10.
function SetEffectsVolume(volume: number) -> nilSets the value of the effects slider from 0-10.
function GetVoiceVolume() -> numberGets the value of the voice slider from 0-10.
function SetVoiceVolume(volume: number) -> nilSets the value of the voice slider from 0-10.
These functions are either existing in game but unbound in stock lua, or are in stock lua but were removed.
function DoString(code: tostring) -> nilInterprets the given string as lua code and executes it.
function MatrixInverse(mat: matrix) -> matrixReturns the inverse of the given matrix.
function ScreenToWorld(screenX: integer, screenY: integer) -> vectorTransforms the given screen coordinates in pixels to a position in the world. Returns a unit vector that originates at your camera and points into the world in the direction that matches the position of the given coordinates on screen. Note that if you want something to appear at a consistent place on the screen regardless of resolution, you should use a ratio of the current resolution like (currentScreenWidth * 0.5) rather than a hardcoded pixel value.
function VectorUnrotate(v: vector, m: matrix) -> vectorTransforms the given vector by the inverse of the matrix. Equivalent to