From the Depths Wiki
Advertisement
LUA Box
LUA Box
Attributes
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[ | ]

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[ | ]

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[ | ]

Values:[ | ]

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

Logical Operators and Loops:[ | ]

For loop[ | ]
  • 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[ | ]
  • A form of loop that repeats a set of statements while a certain condition is met
Logical Operator[ | ]
  • 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[ | ]
  • 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 false.

-WARNING. BECAUSE LUA LOGICAL OPERATORS ACCEPT NON-BOOLEAN VALUES, THEY (OTHER THAN NOT) BEHAVE SLIGHTLY DIFFERENTLY TO OTHER PROGRAMMING LANGUAGES, SO BE SURE TO READ WHAT'S AHEAD-

Or[ | ]
  • 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[ | ]
  • 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[ | ]

Logging/Debugging[ | ]

I:Log(Message)[ | ]

  • 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()[ | ]

  • Clears all current logs.

I:LogToHud(Message)[ | ]

  • 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[ | ]

I.FleetIndex[ | ]

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

I.isFlagship[ | ]

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

Fleetinfo[ | ]

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

Resources[ | ]

I.ResourceZones[ | ]

I.Resources[ | ]

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

ResourceZoneInfo[ | ]

  • 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[ | ]

  • 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[ | ]

I:GetAIMovementMode(index)[ | ]

  • 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)[ | ]

  • 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[ | ]

I.ConstructType - Deprecated[ | ]

Propulsion[ | ]

I:TellAiThatWeAreTakingControl()[ | ]

  • 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)[ | ]

  • 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)[ | ]

  • 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)[ | ]

I:RequestWaterForwards(drive)[ | ]

  • 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)[ | ]

  • 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)

I:GetDrive(mode)

  • 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[ | ]

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

Target Info[ | ]

I:GetNumberOfMainframes()[ | ]

I:GetNumberOfTargets(mainframeIndex)[ | ]

I:GetTargetInfo(mainframeIndex, targetIndex)[ | ]

I:GetTargetPositionInfo(mainframeIndex, targetIndex)[ | ]

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

Misc[ | ]

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

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

I:GetGravityForAltitude(alt)[ | ]

I:GetTime()[ | ]

I:GetTimeSinceSpawn()[ | ]

I:GetGameTime()[ | ]

Self Awareness[ | ]

I:GetConstructPosition()[ | ]

I:GetConstructForwardVector()[ | ]

I:GetConstructRightVector()[ | ]

I:GetConstructUpVector()[ | ]

I:GetConstructMaxDimensions()[ | ]

I:GetConstructMinDimensions()[ | ]

I:GetConstructRoll()[ | ]

I:GetConstructPitch()[ | ]

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

I:GetConstructYaw()[ | ]

I:GetConstructCenterOfMass()[ | ]

I:GetAiPosition(mainframeIndex)[ | ]

I:GetVelocityMagnitude()[ | ]

I:GetForwardsVelocityMagnitude()[ | ]

I:GetVelocityVector()[ | ]

I:GetVelocityVectorNormalized()[ | ]

I:GetAngularVelocity()[ | ]

I:GetLocalAngularVelocity()[ | ]

I:GetAmmoFraction()[ | ]

I:GetFuelFraction()[ | ]

I:GetSparesFraction()[ | ]

Components[ | ]

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)[ | ]

I:Component_GetLocalPosition(type,index)[ | ]

I:Component_GetBlockInfo(type,index)[ | ]

I:Component_GetBoolLogic(type,index)[ | ]

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

I:Component_GetFloatLogic(type,index)[ | ]

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

I:Component_GetIntLogic(type,index)[ | ]

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

I:Component_SetBoolLogicAll(type, bool)[ | ]

I:Component_SetFloatLogicAll(type, float)[ | ]

I:Component_SetIntLogicAll(type, int)[ | ]

Weapon[ | ]

I:GetWeaponCount()[ | ]

I:GetWeaponInfo(weaponIndex)[ | ]

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

I:FireWeapon(weaponIndex, weaponSlot)[ | ]

I:GetTurretSpinnerCount()[ | ]

I:GetWeaponCountOnTurretOrSpinner(turretSpinnerIndex)[ | ]

I:GetWeaponInfoOnTurretOrSpinner(turretSpinnerIndex, weaponIndex)[ | ]

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

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

Missile Warning[ | ]

I:GetNumberOfWarnings(mainframeIndex)[ | ]

I:GetMissileWarning(mainframeIndex, missileIndex)[ | ]

Missile Guidance[ | ]

I:GetLuaTransceiverCount()[ | ]

I:GetLuaControlledMissileCount(luaTransceiverIndex)[ | ]

I:GetLuaTransceiverInfo(luaTransceiverIndex)[ | ]

I:GetLuaControlledMissileInfo(luaTransceiverIndex,missileIndex)[ | ]

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

I:DetonateLuaControlledMissile(luaTransceiverIndex,missileIndex)[ | ]

I:IsLuaControlledMissileAnInterceptor(luaTransceiverIndex,missileIndex)[ | ]

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

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

Spin blocks[ | ]

I:GetSpinnerCount()[ | ]

I:GetSpinnerInfo(index)[ | ]

I:SetSpinnerSpeedFactor(index,speedFactor)[ | ]

I:SetSpinnerPowerDrive(index,drive)[ | ]

I:SetSpinnerRotationAngle(index, angle)[ | ]

I:SetSpinnerContinuousSpeed(index, speed)[ | ]

I:SetSpinnerInstaSpin(index,magnitudeAndDirection)[ | ]

I:IsSpinnerDedicatedHelispinner(index)[ | ]

I:IsSpinnerOnHull(index)[ | ]

I:SetDedicatedHelispinnerUpFraction(index,upFraction)[ | ]

Friendlies[ | ]

I:GetFriendlyCount()[ | ]

I:GetFriendlyInfo(index)[ | ]

I:GetFriendlyInfoById(Id)[ | ]

Tables[ | ]

TargetInfo[ | ]

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

TargetPositionInfo[ | ]

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

BlockInfo[ | ]

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

WeaponInfo[ | ]

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

MissileWarningInfo[ | ]

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

FriendlyInfo[ | ]

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