From From the Depths Wiki
Jump to: navigation, search
LUA Box.png
Health 150
Armour Class 5
Structural No
Weight 15
Relative Buoyancy +22.8
Size 1x1x1
Material Cost 90

Allows writing and running of LUA code- which you can use to control aspects of the vehicle. A very versatile block. The Lua library is supported for Windows 32 and 64 bit, Osx 32 and 64 bit and Linux 64 bit. See the link below for an external source of working Lua functions and troubleshooting information. The Lua Box is powered by uLua, a Unity Asset Store asset.
~ In-game description

This article may need updating to the game's current version. Use information provided here with care.
Please help improve this if you can. The Discussion page may contain suggestions.


Mechanics[edit | edit source]

If a LUA Box is destroyed, execution is suspended until it is repaired. The box will keep its previous state.

Lua code is stopped when the vehicle is pulled out of play. The code is restarted anew when a vehicle is put into play.

Basic Tutorial of From the Depths Lua[edit | edit source]

The interface may seem confusing and un-intuitive at first, but after a bit of practice, you will be able to create large scripts in order to accomplish various things.

Glossary of Technical Terms[edit | edit source]

Values:[edit | edit source]

Variable[edit | edit source]
  • Something that can be changed, or can be thought of as somewhere were one can store values
Integer[edit | edit source]
  • A value that is any whole number, from negative infinity to positive infinity.
String[edit | edit source]
  • A value that is a string of text
Float[edit | edit source]
Bool[edit | edit source]
  • Short for Boolean. Simply stores a value as true or false.
Array[edit | edit source]
  • Stores similar values as a list.

Logical Operators and Loops:[edit | edit source]

For loop[edit | edit source]
  • A form of loop that allows one to easily iterate through the contents of a array or or do things a certain amount of times.
While loop[edit | edit source]
  • A form of loop that repeats a set of statements while a certain condition is met
Logical Operator[edit | edit source]
  • In Lua, logical operators are not limited to boolean values, instead, they consider anything that is either false or nil as false, and anything else as true
Not[edit | edit source]
  • A logical operator that takes in a singular value, and if it is equivalent to false, it will return true, and if it is equivalent to true, it will return true.


Or[edit | edit source]
  • A logical operator that takes in two values, and returns its first input when said input is equivalent to true, and its second input otherwise.
And[edit | edit source]
  • A logical operator that takes in two values, and returns its first input if said input is equivalent to false, and its second input otherwise.

Functions[edit | edit source]

Logging/Debugging[edit | edit source]

I:Log(Message)[edit | edit source]

  • Takes in a string for a log and writes it to the log. These logs will be shown in the "Errors/Logs" panel within the Lua Box. The last 100 of these messages will be maintained.
    • Useful for debugging algorithms by printing out values, execution errors, etc.

I:ClearLogs()[edit | edit source]

  • Clears all current logs.

I:LogToHud(Message)[edit | edit source]

  • Takes in a string message and displays said message as a pop up on the user's HUD, no matter where they are.

Fleet Awareness[edit | edit source]

I.FleetIndex[edit | edit source]

  • the read only integer that describes the position of the ship in the fleet, starting from zero.

I.isFlagship[edit | edit source]

  • the read only boolean that tells Lua whether the ship is the flagship of its fleet or not.

Fleetinfo[edit | edit source]

  • ID
    • Integer ID of the fleet.
  • Name
    • String name of the fleet.
  • Flagship
    • FriendlyInfo object of the flagship.
  • Members
    • FirendlyInfo object array that consists of the ships within a fleet.

Resources[edit | edit source]

I.ResourceZones[edit | edit source]

I.Resources[edit | edit source]

  • A ResourceInfo object that describes a vehicle's available resources.

ResourceZoneInfo[edit | edit source]

  • Id
    • Integer ID of resource zone.
  • Name
    • String name of resource zone.
  • Position
    • Vector3 object that describes location of resource zone.
  • Radius
    • floating-point value that describes the radius of the resource zone, i.e. how big the "ring" is.
  • Resources
    • ResourceInfo object that describes resources available to the resource zone.

ResourceInfo[edit | edit source]

  • CrystalTotal
    • The floating-point value that describes the total amount of Crystal resources.
  • CrystalMax
    • The floating-point value that describes the max amount of Crystal resources.
  • MetalTotal
    • The floating-point value that describes the total amount of Metal resources.
  • MetalMax
    • The floating-point value that describes the max amount of Metal resources.
  • OilTotal
    • The floating-point value that describes the total amount of Oil resources.
  • OilMax
    • The floating-point value that describes the max amount of Oil resources.
  • ScrapTotal
    • The floating-point value that describes the total amount of Scrap resources.
  • ScrapMax
    • The floating-point value that describes the max amount of Scrap resources.

AI[edit | edit source]

I:GetAIMovementMode(index)[edit | edit source]

  • Takes in the integer index of the AI mainframe to get movement mode from.
    • Returns the string name of the AI movement mode. Possibilities: "Off", "Manual", "Automatic", "Fleet".

I:GetAIMovementMode(index)[edit | edit source]

  • Takes in the integer index of the AI mainframe to get movement mode from.
    • Returns the string name of the AI firing mode. Possibilities: "Off", "On".

I.AIMode - Deprecated[edit | edit source]

I.ConstructType - Deprecated[edit | edit source]

Propulsion[edit | edit source]

I:TellAiThatWeAreTakingControl()[edit | edit source]

  • This will stop the AI from moving the ship. Basically does the same thing as what happens when the user presses a key when by a controller.

I:RequestControl(mode,type,drive)[edit | edit source]

  • This takes in an enumerated integer for mode (0 for water mode, 1 for land mode, and 2 for air mode), another one for type (0 for left yaw, 1 for right yaw, 2 for left roll, 3 for roll right, 4 for pitch up, 5 for pitch down, 6 for "increase", 7 for "decrease", 8 for primary drives) and any number from 0 to 1 for the non-main-propulsion drives, and -1 to 1 for primary propulsion drives.
    • This serves as a way to effect the ship's drives, similarly to how one controls a ship manually, in a more general fashion compared to the other methods.

I:RequestThrustControl(type)[edit | edit source]

  • This takes in an enumerated integer for the control type (0 for forwards, 1 for backwards, 2 for right, 3 for left, 4 for up, 5 for down, 6 for roll right, 7 for roll left, 8 for yaw right, 9 for yaw left, 10 for nose up, 11 for nose down)
    • This will request the built in thrust control to perform the action given by the control type. Does the same thing as a manually-controlled thrust controller.
    • Warning: this will override other propulsion systems in order to provide torque-free thrust.

I:RequestThrustControl(type, scale)[edit | edit source]

I:RequestWaterForwards(drive)[edit | edit source]

  • Takes in a numerical value clamped in between 5 or -5.
    • This will request propellers set to the main drive to push forwards for a singular time step, based on the drive value. This is what the Naval AI uses.

I:RequestComplexControllerStimulus(stim)[edit | edit source]

  • Takes in an enumerated integer for the requested stimulus. (0 for none, 1 for T, 2 for G, 3 for Y, 4 for H, 5 for U, 6 for J, 7 for I, 8 for K, 9 for O, 10 for L, 11 for up, 12 for down, 13 for left, 14 for right)


  • Takes in an enumerated integer for the drive fraction to be returned. (0 for water, 1 for air, 2 for primary, 3 for secondary, and 4 for tertiary)
    • Returns the current main drive fraction for the selected drive.

I:GetInput(mode, type)

I:MoveFortress[edit | edit source]

  • Takes in a Vector3, but us limited to one meter.
    • Moves the fortress in any direction.

Target Info[edit | edit source]

I:GetNumberOfMainframes()[edit | edit source]

I:GetNumberOfTargets(mainframeIndex)[edit | edit source]

I:GetTargetInfo(mainframeIndex, targetIndex)[edit | edit source]

I:GetTargetPositionInfo(mainframeIndex, targetIndex)[edit | edit source]

I:GetTargetPositionInfoForPosition(mainframeIndex, x,y,z)[edit | edit source]

Misc[edit | edit source]

I:GetTerrainAltitudeForPosition(x,y,z)[edit | edit source]

I:GetTerrainAltitudeForLocalPosition(x,y,z)[edit | edit source]

I:GetGravityForAltitude(alt)[edit | edit source]

I:GetTime()[edit | edit source]

I:GetTimeSinceSpawn()[edit | edit source]

I:GetGameTime()[edit | edit source]

Self Awareness[edit | edit source]

I:GetConstructPosition()[edit | edit source]

I:GetConstructForwardVector()[edit | edit source]

I:GetConstructRightVector()[edit | edit source]

I:GetConstructUpVector()[edit | edit source]

I:GetConstructMaxDimensions()[edit | edit source]

I:GetConstructMinDimensions()[edit | edit source]

I:GetConstructRoll()[edit | edit source]

I:GetConstructPitch()[edit | edit source]

This is in degrees between 0 and 360. Note that unlike the HUD indicator, positive represents the nose-down direction.

I:GetConstructYaw()[edit | edit source]

I:GetConstructCenterOfMass()[edit | edit source]

I:GetAiPosition(mainframeIndex)[edit | edit source]

I:GetVelocityMagnitude()[edit | edit source]

I:GetForwardsVelocityMagnitude()[edit | edit source]

I:GetVelocityVector()[edit | edit source]

I:GetVelocityVectorNormalized()[edit | edit source]

I:GetAngularVelocity()[edit | edit source]

I:GetLocalAngularVelocity()[edit | edit source]

I:GetAmmoFraction()[edit | edit source]

I:GetFuelFraction()[edit | edit source]

I:GetSparesFraction()[edit | edit source]

Components[edit | edit source]

Component types are as follows:

  • 0: Balloon deployers
  • 1: Drive maintainers
  • 2: Air pump
  • 3: Resource gatherer
  • 4: Oil drill
  • 5: Ammo processor
  • 6: Oil processor
  • 7: Tractor beam
  • 8: Hydrofoil
  • 9: Propulsion
  • 10: Shield projector

I:Component_GetCount(type)[edit | edit source]

I:Component_GetLocalPosition(type,index)[edit | edit source]

I:Component_GetBlockInfo(type,index)[edit | edit source]

I:Component_GetBoolLogic(type,index)[edit | edit source]

I:Component_SetBoolLogic(type,index,bool)[edit | edit source]

I:Component_GetFloatLogic(type,index)[edit | edit source]

I:Component_SetFloatLogic(type,index,float)[edit | edit source]

I:Component_GetIntLogic(type,index)[edit | edit source]

I:Component_SetIntLogic(type,index,integer)[edit | edit source]

I:Component_SetBoolLogicAll(type, bool)[edit | edit source]

I:Component_SetFloatLogicAll(type, float)[edit | edit source]

I:Component_SetIntLogicAll(type, int)[edit | edit source]

Weapon[edit | edit source]

I:GetWeaponCount()[edit | edit source]

I:GetWeaponInfo(weaponIndex)[edit | edit source]

I:AimWeaponInDirection(weaponIndex, x,y,z, weaponSlot)[edit | edit source]

I:FireWeapon(weaponIndex, weaponSlot)[edit | edit source]

I:GetTurretSpinnerCount()[edit | edit source]

I:GetWeaponCountOnTurretOrSpinner(turretSpinnerIndex)[edit | edit source]

I:GetWeaponInfoOnTurretOrSpinner(turretSpinnerIndex, weaponIndex)[edit | edit source]

I:AimWeaponInDirectionOnTurretOrSpinner(turretSpinnerIndex,weaponIndex,x,y,z,weaponSlot)[edit | edit source]

I:FireWeaponOnTurretOrSpinner(turretSpinnerIndex,weaponIndex,weaponSlot)[edit | edit source]

Missile Warning[edit | edit source]

I:GetNumberOfWarnings(mainframeIndex)[edit | edit source]

I:GetMissileWarning(mainframeIndex, missileIndex)[edit | edit source]

Missile Guidance[edit | edit source]

I:GetLuaTransceiverCount()[edit | edit source]

I:GetLuaControlledMissileCount(luaTransceiverIndex)[edit | edit source]

I:GetLuaTransceiverInfo(luaTransceiverIndex)[edit | edit source]

I:GetLuaControlledMissileInfo(luaTransceiverIndex,missileIndex)[edit | edit source]

I:SetLuaControlledMissileAimPoint(luaTransceiverIndex,missileIndex,x,y,z)[edit | edit source]

I:DetonateLuaControlledMissile(luaTransceiverIndex,missileIndex)[edit | edit source]

I:IsLuaControlledMissileAnInterceptor(luaTransceiverIndex,missileIndex)[edit | edit source]

I:SetLuaControlledMissileInterceptorTarget(luaTransceiverIndex,missileIndex,mainframeIndex, targetIndex)[edit | edit source]

I:SetLuaControlledMissileInterceptorStandardGuidanceOnOff(luaTranceiver,missileIndex, onOff)[edit | edit source]

Spin blocks[edit | edit source]

I:GetSpinnerCount()[edit | edit source]

I:GetSpinnerInfo(index)[edit | edit source]

I:SetSpinnerSpeedFactor(index,speedFactor)[edit | edit source]

I:SetSpinnerPowerDrive(index,drive)[edit | edit source]

I:SetSpinnerRotationAngle(index, angle)[edit | edit source]

I:SetSpinnerContinuousSpeed(index, speed)[edit | edit source]

I:SetSpinnerInstaSpin(index,magnitudeAndDirection)[edit | edit source]

I:IsSpinnerDedicatedHelispinner(index)[edit | edit source]

I:IsSpinnerOnHull(index)[edit | edit source]

I:SetDedicatedHelispinnerUpFraction(index,upFraction)[edit | edit source]

Friendlies[edit | edit source]

I:GetFriendlyCount()[edit | edit source]

I:GetFriendlyInfo(index)[edit | edit source]

I:GetFriendlyInfoById(Id)[edit | edit source]

Tables[edit | edit source]

TargetInfo[edit | edit source]

  • Valid
  • Priority
  • Score
  • AimPointPosition
  • Team
  • Protected
  • Position
  • Velocity
  • PlayerTargetChoice
  • Id

TargetPositionInfo[edit | edit source]

  • Valid
  • Azimuth
  • Elevation
  • ElevationForAltitudeComponentOnly
  • Range
  • Direction
  • GroundDistance
  • AltitudeAboveSeaLevel
  • Position
  • Velocity

BlockInfo[edit | edit source]

  • Position
  • LocalPosition
  • LocalPositionRelativeToCom
  • Forwards
  • LocalForwards
  • Rotation
  • LocalRotation

WeaponInfo[edit | edit source]

  • Valid
  • LocalPosition
  • GlobalPosition
  • Speed
  • CurrentDirection
  • WeaponType
  • WeaponSlot
  • PlayerCurrentlyControllingIt

MissileWarningInfo[edit | edit source]

  • Valid
  • Position
  • Velocity
  • Range
  • Azimuth
  • Elevation
  • TimeSinceLaunch
  • Id

FriendlyInfo[edit | edit source]

  • Valid
  • Rotation
  • ReferencePosition
  • PositiveSize
  • NegativeSize
  • CenterOfMass
  • Velocity
  • UpVector
  • RightVector
  • ForwardVector
  • HealthFraction
  • SparesFraction
  • AmmoFraction
  • FuelFraction
  • AxisAlignedBoundingBoxMinimum
  • AxisAlignedBoundingBoxMaximum
  • BlueprintName
  • Id