LUA関数リファレンス

Last-modified: 2017-03-11 (土) 07:01:45

執筆バージョン:Alpha v1.955

 

 LUA BoxのエディタにあるHelp Docmentationをテキストに書き出したものです。

 

 OCRソフトを使っているため、特有のタイポミスがあると思います。
 Help内の関数名にマウスカーソルを持っていくとポップアップが出現します。その状態でマウスを左クリックすると関数をOSのクリップボードにコピーします。

 

The Basics

The basic code file needs a function called Update that takes an input called I. It should look like this-

function Update(I)

-- put your code here
end

 

'I' is the interface to the game and contains all the function calls you see on these help pages.
The code in Update will be executed every single physics step (the game runs at 40 physics steps per in game second of time)

 

-- creates a comment line so the line '-- put your code here' is never executed by the game. Comments are for explaining how your code functions.
Here is a simple example ofa function that uses one of the interface functions to write 'Hello' to the HUD

function Update(I)
I:Log('Hello')
end

LUA Syntax

String Concatenation
String Concatenation is done with .. i.e 'Hello' .. ' Player' creates 'Hello Player'. Numbers are automatically converted to strings.

 

For loops
For loops (in this example looping from 0 to 10 in increments of 1) use:

 

for ii=0,10,1 do

-- your code here (note that we don't need to define the step size of 1.. 1 is the default anyway)
end

 

Calling functions
The colon (:) is used for calling functions. This is why all calls to the interface start with I: (i.e. I:RequestWaterForwards(5))

 

Comments

-- creates a comment. So this line, in LUA, would be a comment

 

Global variables
Declare a variable outside of your Update function and it will be persistent from call to call, the example below will log the counter to the Log forever (1,2,3,4,5,etc).

 

count = 0 ;
function MyUpdateFunction()
count = count + 1 ;
I:Log(count);

end

 

If Statements
To conditionally execute some code you can use an if statement. In this example we only execute the line if 'a' is greater than 0.:

 

if a>0 then

-- your code here
end

Logging and Messages

I:Log(message)
Inputs: message: [string]|the message you want to write to the log.

 

Outputs: N/A

 

Writes a message to the log. Log is visible when editing the LUA box and appears in the 'Errors/Log' panel. The last 100 log messages are maintained.

 

I:ClearLogs()
Inputs: N/A

 

Outputs: N/A

 

Clears your log. Pretty harmless!

 

I:LogToHud(message)
Inputs: message [string]: the message you want to write to the HUD.

 

Outputs: N/A

 

Writes a message to the HUD. HUD messages are visible during normal play and when on the map.|

 

Libraries

 

Mathf
The Mathf Library is full of functions you can google. Each function is statically called so use Mathf.Min(1,2) rather than Mathf:Min(1,2).

 

Vector3
Unity's Vector3 library is full exposed to you. You can create a new Vector3 with v = Vector3(x,y,z), and call functions such as Vector3.Angle(v1,v2). Google Unity Vector3 for more information on this library

 

Quaternion
Unity's Quaternion library is fully exposed to you also. Google it to find out more

 

Fleet

The Fleet Awareness AP! provides scripts basic information about the fleet the craft is in.

 

I.FleetIndex (read only)

 

Outputs: [int] Position of the ship in the fleet, starting from 0.

 

Returns the index of the ship in the fleet. Starts at 0.

 

I.Fleet (read only)|

 

Outputs: [FleetInfo] Information about the fleet

 

Returns the current state of the fleet.

 

I.IsFlagship (read only)

 

Outputs: [bool] Is the craft the fleet flagship?

 

Used to determine whether the ship is a flagship of a fleet.

 

Freetinfo
ID [int]: Unique ID of the fleet.
Name [string]: Name of the fleet.
Flagship [Friendlyinfo]: Information about the flagship of the fleet.
Members [FriendlyInfo[]]: A table of information regarding the fleet's members. MAY CONTAIN NILS!

 

Resources

Scripts can use the following fields to get information about known resource zones. May change in the future to require a detector.

 

I.ResourceZones (read only)

 

Outputs: [ResourceZoneinfo[]] List of ResourceZones

 

Returns a Lua table containing a list of known resource zones.

 

I.Resources (read only)

 

Outputs: [ResourceInfo] Ship resource data

 

Returns information about a ship's available resources.

 

ResourceZoneinfo
Id [int]: Unique ID of the Resource Zone
Name [string]: Name of the Resource Zone
Position [Vector3]: Position of the Resource Zone
Radius [float]: Radius of the Resource Zone
Resources [ResourceInfo]: Available resources of the Resource Zone

 

ResourceInfo
CrystalTotal [float]: Total Crystal resources.
CrystalMax [float]: Max Crystal resources.
MetalTotal [float]: Total Metal resources.
MetalMax [float]: Max Metal resources.
NaturalTotal [float]: Total Natural resources.
NaturalMax [float]: Max Natural resources.
OilTotal [float]: Total Oil resources.
OilMax [float]: Max Oil resources.
ScrapTotal [float]: Total Scrap resources.
ScrapMax [float]: Max Scrap resources.

 

AI

 

I.AIMode (read only)

 

Outputs: [string] Returns the mode of the AI. Possible modes: off, on, combat, follow, patrol, fleetmove

 

Returns the mode of the AI mainframe.

 

I.ConstructType

 

Outputs: [string] The type of construct.

 

AI's concept of what type at craft this ship is (naval. aerial. fortress. none).

 

Using Propulsion

 

I:TellAiThatWeAreTakingControl()
Inputs:

 

Outputs:

 

Will stop the AI from issuing propulsion commands for the next second, after which it will assume control again. This is exactly what happens when the player presses a control key on an AI controlled vehicle.

 

I:RequestControl(mode,type,drive)
Inputs: mode: Water = O =, Land = 1, Air = 2.
type: YawLeft = 0,YawRight = 1,RollLeft = 2,RollRight = 3,NoseUp = 4,NoseDown = 5,Increase = 6,Decrease = 7,MainPropulsion = 8
drive: -1 to 1 for main propulsion, 0 to 1 for everything else.

 

Outputs: N/A

 

A generic propulsion / turning request. RequestContro(0,8,1) does the same as RequestWaterForwards(1).

 

I:RequestThrustControl(type)
Inputs: type: [int] forwards = 0, backwards = 1, right = 2, left = 3, up = 4, down = 5, rollright = 6, rollleft = 7, yawright = 8, yawleft = 9, noseup = 10, nosedown = 11

 

Outputs: N/A

 

Requests the vehicle's built in thrust controller to perform certain actions. Exactly the same as the player using the ThrustController block. WARNING: this will override the drive fractions of your propulsion systems as it uses these to provide balanced torque less thrust.

 

I:RequestThrustControl(type, scale)
Inputs: type: [int] forwards = O, backwards = 1, right = 2, left = 3, up = A, down = 5, rollright = 6, rollleft = 7, yawright = 8, yawleft = 9, naseup = 10 nosedown = 11 .scale:[float] scale the force between 0 and 1.

 

Outputs: N/A

 

As per the above function but this version otters a scaling factor.

 

I:RequestWaterForwards(drive)
Inputs: drive: a number between -5 and 5. Values outside of this range will be clamped.

 

Outputs: N/A

 

Requests forward propulsion tor propellers and huge propellers for one time-step. Does not actually change 'Water drive'. This is the function Naval AI uses.

 

I:RequestComplexControllerStimulus(stim)
Inputs: stim: none = 0,T = 1,G =2,Y = 3,H = 4,U = 5,J = 6,I = 7,K = 8,O = 9,L = 10,up = 11,down = 12,left = 13,right = 14

 

Outputs: N/A

 

Requests a stimuli as per the complex controller block.

 

I:MoveFortress
Inputs: direction [Vector3]: Direction to move the fortress in. Limited to 1 meter.

 

Outputs: N/A

 

Move fortress in any direction, Limited to 1 meter.

 

Accessing Target Info

 

I:GetNumberOfMainframes()
Inputs: N/A

 

Outputs: The number of mainframes on your vehicle.

 

The mainframe count of your vehicle is useful for requesting targets

 

I:GetNumberOfTargets(mainframeIndex)
Inputs: mainframeIndex: 0 being the first mainframe. Use GetNumberOfMainframes() to find out how many there are.

 

Outputs: The number of targets in this particular mainframe. Returns 0 if such a mainframe does not exist.

 

The target count is important when calling GetTaget(mainframeIndex, targetIndex).

 

I:GetTargetInfo(mainframeIndex, targetIndex)
Inputs: mainframeIndex: 0 being the first mainframe. Use GetNumberOfMainframes() to find out how many there are.
targetIndex. 0 being the first target. If target prioritisation card is in use 0 is the highest priority target.

 

Outputs: A TargetInfo object

 

The TargetInfo object contains many interesting variables relating to the target. Valid will be false if the target has died but the AI has not yet cleared it.

 

TargetInfo
Valid: [bool] true if a target was correctly returned
Priority: [int] 0 is highest priority
Score: [float] high is a good score- taken from target prioritisation card
AimPointPosition: [Vector3] position in game world of aim point (this is the current position of the block that's being aimed for)
Team: [int] team of target
Protected: [bool] is it salvage? Will be false forr salvage.
Position: [Vector3] position in game world of target object.
Velocity: [Vector3] velocity in game world in meters per second
PlayerTargetChoice: [bool] has the player set this as the target?
Id: [int] the unique integer Id of the target.

 

I:GetTargetPositionInfo(mainframeIndex, targetIndex)
Inputs: mainframeIndex 0 being the first mainframe. Use GetNumberOfMainframes() to find out how many there are.
targetIndex: 0 being the first target. If target prioritisation card is in use 0 is the highest priority target.

 

Outputs: A TargetPositionInfo object

 

The TargetPositionInfo object contains many interesting variables relating to the target. Valid will be false if the target has died but the Al has not yet cleared it.

 

I:GetTargetPositionInfoForPosition(mainframeIndex, x,y,z)
Inputs: mainframeIndex: [int] 0 being the first mainframe. Use GetNumberOfMainframes() to find out how many there are.
x: [float] east west in meters.
y: [float] up down in meters (0 is sea level).
z: north south in meters.

 

Outputs: A TargetPositionInfo object for this point in space. Velocity will be 0.

 

The TargetPositionInfo obiect contains many interesting variables relating to the target.

 

TargetPositionInfo
Valid: [bool] true if target position info correctly returned.
Azimuth: [float] degrees off nose of our vehicle where positive is clockwise
Elevation: [float] degrees off nose of our vehicle where positive is downwards. This often has dodgy values
ElevationForAltitudeComponentOnly: [float] the elevation off nose of the target's altitude. Robustly calculated
Range: [float] the range to the target
Direction: [Vector3] the direction to the target (absolute, not normalised)
GroundDistance: [float] the distance along the ground (ignoring vertical component) to the target
AltitudeAboveSeaLevel: [float] in meters.
Position: [Vector3] position of target
Velocity: [Vector3] meters per second

 

Misc Functions

 

I:GetTerrainAltitudeForPosition(x,y,z)
Inputs: x: [float] game world east west position in meters.
y: [float] game world vertical (not important)
z: game world north south position in meters.

 

Outputs: [float] the terrain altitude in meters where 0 is sea level.

 

Returns altitude of the terrain at a position in the world. Can be overloaded with a single Vector3 rather than x,y,z components.

 

I:GetTerrainAltitudeForLocalPosition(x,y,z)
Inputs; x: [float] right offset from construct position in meters.
y: [float] up offset from construct position in meters
z: forwards offset from construct position in meters.

 

Outputs: [float] the terrain altitude in meters where 0 is sea level.

 

Returns altitude of the terrain at a position relative to the construct. Can be overloaded with a single Vector3 rather than x,y,z components.

 

I:GetGravityForAltitude(alt)
Inputs: alt: [float] altitude (0 is sea level)

 

Outputs: [Vector3] gravity vector

 

Returns gravity vector for an altitude. gravity is the component of interest.

 

I:GetTime()
Inputs: N/A

 

Outputs: [float] the time in seconds.

 

Returns time with an arbitrary offset (i.e. the time will seldom be 0).

 

I:GetTimeSinceSpawn()
Inputs: N/A

 

Outputs: [float] the time in seconds since the construct spawned.

 

Returns time since construct spawned in seconds.

 

I:GetGameTime()
Inputs: N/A

 

Outputs: [float] The time since the Instance started in seconds.

 

Returns time since the instance started in seconds.

 

Self awareness

 

I:GetConstructPosition()
Inputs: N/A

 

Outputs: [Vector3] The position (Vector3 has members x, y, and z).

 

Returns the position of the construct. The construct's position is essentially the position of the first ever block placed, or the center of the starting raft that it was built from.

 

I:GetConstructForwardVector()
Inputs: N/A

 

Outputs: [Vector3] The forward pointing vector of the construct (it has length 1)

 

Return the forward pointing vector of the construct

 

I:GetConstructRightVector()
Inputs: N/A

 

Outputs: [Vector3] The right pointing vector of the construct (it has length 1)

 

Return the right pointing vector of the construct

 

I:GetConstructUpVector()
Inputs: N/A

 

Outputs: [Vector3] The up pointing vector of the construct (it has length 1)

 

Return the up pointing vector of the construct

 

I:GetConstructMaxDimensions()
Inputs: N/A

 

Outputs: [Vector3] The size of the vehicle right, up and forwards of its origin

 

Returns the 'positive' size of the vehicle (right,up,forwards) relative to its origin (GetConstructPosition()). The coordinates are in local space. This minus GetConstructMinDimensions() provides the full size of the vehicle.

 

I:GetConstructMinDimensions()
Inputs: N/A

 

Outputs: [Vector3] The size of the vehicle left, down and back of its origin

 

Returns the 'neqative’ size of the vehicle (left,down,back) relative to its origin (GetConstructPosition()). The coordinates are in local space

 

I:GetConstructRoll()
Inputs: N/A

 

Outputs: [float] The roll angle in degrees

 

Return the roll angle in degrees

 

I:GetConstructPitch()
Inputs: N/A

 

Outputs: [float] The pitch angle in degrees

 

Return the Pitch angle in degrees

 

I:GetConstructYaw()
Inputs: N/A

 

Outputs: [float] The yaw angle in degrees

 

Return the yaw angle in degrees

 

I:GetConstructCenterOfMass()
Inputs: N/A

 

Outputs: [Vector3] The position (Vector3 has members x, y, and z).

 

Returns the position of the construct's center of mass in the world

 

I:GetAiPosition(mainframeIndex)
Inputs: mainframeindex: [int] 0 is the first mainflame.

 

Outputs: [Vector3] The position (Vector3 has members x, y, and z).

 

Returns the position of the mainframe in the world. Returns Vector3(0,0,0) it no such mainframe exists.

 

I:GetVelocityMagnitude()
Inputs: N/A

 

Outputs: [float] magnitude of your velocity in meters per second.

 

Returns the magnitude of your velocity in meters per second.

 

I:GetForwardsVelocityMagnitude()
Inputs: N/A

 

Outputs: [float] magnitude of your forwards velocity in meters per second.

 

Returns the magnitude of your velocity in the forwards direction in meters per second. A negative value means you're going predominantly backwards.

 

I:GetVelocityVector()
Inputs: N/A

 

Outputs: [Vector3] Your construct's velocity vector in meters per second

 

Returns your construct's velocity vector in world space in meters per second. x is east west, y is up down and z is north south.

 

I:GetVelocityVectorNormalized()
Inputs: N/A

 

Outputs: [Vector3] Your construct's velocity vector in meters per second- normalized to have a length of 1.

 

Returns your construct's velocity vector in world space in meters per second, x is east west, y is up clown and z is north south. It's normalized to have a length of 1.

 

I:GetAngularVelocity()
Inputs: N/A

 

Outputs: [Vector3] Your construct's angular velocity in world space

 

Returns your angular velocity. x is speed of turn around the east ->'' west axis. y is around the vertical axis and z is around the north south axis. You're probably going to want the next function instead of this one...

 

I:GetLocalAngularVelocity()
Inputs: N/A

 

Outputs: [Vector3] Your construct's angular velocity in local space

 

Returns your angular velocity. x is pitch, y yaw and z roll.

 

I:GetAmmoFraction()
Inputs: N/A

 

Outputs: [float] fraction. 0 to 1. 1 if no ammo storage is available

 

Returns the fraction of ammo your construct has left

 

I:GetFuelFraction()
Inputs: N/A

 

Outputs: [float] fraction. 0 to 1. 1 if no fuel storage is available

 

Returns the fraction of fuel your construct has left

 

I:GetSparesFraction()
Inputs: N/A

 

Outputs: [float] fraction. 0 to 1. 1 if no spares storage is available

 

Returns the fraction of spares your construct has left

 

I:GetHealthFraction()
Inputs: N/A

 

Outputs: [float] fraction. 0 to 1. 1 if full health

 

Returns the fraction of health your construct has (including turrets etc)

 

I:IsDocked()
Inputs: N/A

 

Outputs: [bool] Docked? true for yes.

 

Returns true it the vehicle is docked

 

I:GetHealthFractionDifference(time)
Inputs: time[float]: the time you want the difference measured over. Time will be limited to be between 1 and 30.

 

Outputs: [float] health difference as a fraction (0 to 1)

 

Returns health difference over a specified measurement time

 

Components

 

Types

Component types and their logic.
0 = balloon deployed. boolean true for deployed and false for not deployed
1 = drive maintainer. floating point -5 to 5. Sets the power for the drive the maintainer is controlling (Primary,Secondary,Tertiary).
2 = air pump. floating point 0 to 1 for buoyancy fraction. bool true means 'on (>'' 0)‘ and false means 'off (0)'. Setting bool true sets to 1.
3 = resource gatherer. bool logic false to turn off and true to turn on.
4 = oil drill. bool logic false to turn off and true to turn on
5 = ammo processor. bool logic false to turn off and true to turn on
6 = oil processor. bool logic false to turn off and true to turn on
7 = tractor beams. bool logic true turns it on and bool logic false turns it off
8 = hydrofoils. float logic gets/sets the angle (45 is max up and -45 is max down).
9 = propulsion. float logic gets/sets drive fraction between 0 and 1
10 = shield projector. float logic for power drive, int logic for shield type (off: 0, disrupt = 7, reflect = 2)

 

BlockInfo
Position:[Vector3] position in world (east,up,north)
LocalPosition:[Vector3] position in construct (right,up,forwards)
LocalPositionRelativeToCom:[Vector3] local position relative to the center of mass
Forwards:[Vector3] forwards direction in world(east,up,north)
LocalForwards:[Vector3] forward direction in construct (right,up,forwards)
Rotation:[Quaternion] the rotation of the block in world coordinates
LocalRotation:[Quaternion] the rotation of the block in the vehicle's (or turret's) coordinate system.

 

Interface Functions / Methods

 

I:Component_GetCount(type)
Inputs: type: [int] the type of component you want the count of

 

Outputs: [int] the number of components of this type.

 

Returns the number of components of this type

 

I:Component_GetLocalPosition(type,index)
Inputs: type: [int] the type of component you want the local position of
index [int] the index of the component you want the position of

 

Outputs: [Vector3i] a Vector3i is a Vector3 where .x.y and .z are integers.

 

Retums the local position in the vehicle of this component.

 

I:Component_GetBlockInfo(type,index)
Inputs: type: [int] the type of component you want information on.
index: [int] the index of the component you want block info for..

 
 

Outputs: [BlockInfo] a Blockinfo structure relating to the component.

 

Returns an extensive Blockinfo object tor the component.

 

I:Component_GetBoolLogic(type,index)
Inputs: type: [int] the type ofcomponent you want boolean logic for.
index: [int] the index of the component you want boolean logic for.

 
 

Outputs: [bool] the boolean logic for this component. For a component without boolean logic, or an index that doesn't exist, false is returned.

 

Returns a boolean (true/false) for a component. Depending on the type of this component this means different things (or nothing at all). Default return is false.

 

I:Component_SetBoolLogic(type,index,bool)
Inputs: type: [int] the type of component you want to set boolean logic for.
index: [int] the index of the component you want to set boolean logic for.
bool: [bool] the true/false you want to set.

 

Outputs: N/A

 

Sets the boolean logic for a component. Depending on the type of this component this means different things (or nothing at all).

 

I:Component_GetFloatLogic(type,index)
Inputs: type: [int] the type of component you want boolean logic for.
index: [int] the index of the component you want integer logic for.

 
 

Outputs: [float] the floating point logic for this component. For a component without floating point logic, or an index that doesn't exist, 0 is returned.

 

Returns a floating point value for a component. Depending on the type of this component this means different things (or nothing at all). Default return is 0.

 

I:Component_SetFloatLogic(type,index,float)
Inputs: type: [int] the type of component you want to set floating point logic for.
index: [int] the index of the component you want to set floating point logic for.
float: [float] the floating point number you want to set.

 

Outputs: N/A

 

Sets the floating point logic for a component. Depending on the type of this component this means different things (or nothing at all).

 

I:Component_GetIntLogic(type,index)
Inputs: type: [int] the type of component you want boolean logic for.
index: [int] the index of the component you want integer logic for.

 
 

Outputs: [int] the integer logic for this component. For a component without integer logic, or an index that doesn't exist, 0 is returned.

 

Returns an integer value for a component. Depending on the type of this component this means different things (or nothing at all). Default return is 0.

 

I:Component_SetIntLogic(type,index,integer)
Inputs: type: [int] the type of component you want to set integer point logic for.
index: [int] the index of the component you want to set integer point logic for.
int: [int] the integer number you want to set.

 

Outputs: N/A

 

Sets the integer logic for a component. Depending on the type of this component this means different things (or nothing at all).

 

I:Component_SetBoolLogicAll(type, bool)
Inputs: type: [int] the type of component you want to set boolean logic for.ool [bool] the bool (true/false) you want to set.

 

Outputs: N/A

 

Sets the boolean logic for all components of a specific type. Depending on the type of this component this means different things (or nothing at all).

 

I:Component_SetFloatLogicAll(type, float)
Inputs: type: [int] the type of component you want to set floating point logic for.
float [float] the floating point number you want to set.

 

Outputs: N/A

 

Sets the floating point logic for all components of a specific type. Depending on the type of this component this means different things (or nothing at h all).

 

I:Component_SetIntLogicAll(type, int)
Inputs: type: [int] the type of component you want to set integer logic for.
float [int] the integer you want to set.

 

Outputs: N/A

 

Sets the intener ionic for all components of a specific type. Depending on the type of this component this means different things (or nothing at all).

 

Weapons

WeaponSlot [int]: the weapon slot of the weapon itself 0 ->'' 5.
PlayerCurrentlyControllingIt [bool]: true if the player is controlling this weapon at the moment

 

I:GetWeaponCount()
Inputs: N/A

 

Outputs: [int] the number of weapons on the hull- doesn't include weapons on the turrets but does include the turrets themselves.

 

Get the number of weapons on the hull. Knowinq is number is useful for when you want to call GetWeaponInfo(i) to find out weapon information.

 

I:GetWeaponInfo(weaponIndex)
Inputs: weaponIndex: [int] the index of the weapon you want information on. 0 is the first weapon.

 

Outputs: [WeaponInfo] information on the weapon. weaponInfo.Valid is false if you ask for an invalid weaponIndex.

 

Gets weapon information for a specific weapon. Useful to figure out what sort of weapon is present.

 

WeaponInfo
Valid [bool]: false means this WeaponInfo packet is useless. Move onto the next valid one.
LocalPosition [Vector3]: the local position in the vehicle of the weapon. x is right, y is up and z is forwards.
GlobalPosition [Vector3]: the global position of the weapon. x is East, y is Up and Z is North
Speed [float]: the speed in meters per second of the weapon- approximately correct for most weapon types.
CurrentDirection [Vector3]: the direction in global coordinate system that the weapon is facing
WeaponType [int]: the type of the weapon. cannon = 0,missile = 1,laser = 2,harpoon = 3,turret = 4,missilecontrol = 5,fireControlComputer = 6
WeaponSlot [int]: the weapon slot of the weapon itself 0 ->'' 5.
PlayerCurrentlyControllingIt [bool]: true if the player is controlling this weapon at the moment

 

I:AimWeaponInDirection(weaponIndex, x,y,z, weaponSlot)
Inputs: weaponIndex: [int] 0 is the first weapon.
x,y,z: [floats] the world coordinate scheme direction components to point in. They don't need to be normalised
weaponSlot: [int] 0 for all, otherwise 1 to 5.

 

Outputs: [int] the number of weapons that can fire in this direction. 0 for none.

 

Aims a weapon in a specific direction. For a turret this will aim all weapons on the turret as well as the turret itself.

 

I:FireWeapon(weaponIndex, weaponSlot)
Inputs: weaponIndex: [int] 0 is the first weapon.
weaponSlot: [int] 0 will control all weapons

 

Outputs: [bool] has any weapon fired? will be true if so.

 

Fires a specific weapon. lt's important for most weapons that you aim them first as they won't fire it they can't fire in the direction they are aimed.

 

I:GetTurretSpinnerCount()
Inputs: N/A

 

Outputs: [int] the number of turrets and spinners on the construct

 

Returns the number of turrets and spinners on the construct. You'll need this function it you want to control turreted or spin block mounted weapons individually

 

I:GetWeaponCountOnTurretOrSpinner(turretSpinnerIndex)
Inputs: turretSpinnerIndex [int] 0 is the first turret or spinner

 

Outputs: [int] the number of weapons on this turret or spinner, not including the turret itself

 

Return the number of weapons on the turret or spinner. If you wanted to control the turret itself then note that it is treated as a hull mounted weapon.

 

I:GetWeaponInfoOnTurretOrSpinner(turretSpinnerIndex, weaponIndex)
Inputs: turretSpinnerIndex: [int] the index of the turret or spinner. 0 is the first one.
weaponIndex: [int] the index of the weapon. 0 is the first one.

 

Outputs: [WeaponInfo] a WeaponInfo object. See above for the definition of this structure. Note that changes to this structure in LUA do not affect the weapon itself.

 

Get weapon into ot a weapon on a turret or spinner

 

I:AimWeaponInDirectionOnTurretOrSpinner(turretSpinnerIndex,weaponIndex,x,y,z,weaponSlot)
Inputs: First argument is now the turret spinner index, otherwise see 'AimWeaponInDirection'

 

Outputs: as per AimWeaponInDirection

 

Aims a specific weapon on the turret without aiming the turret

 

Missile Warning

 

I:GetNumberOfWarnings(mainframeIndex)
Inputs: mainframeIndex. [int] the index of the mainframe, 0 is the first one.

 

Outputs: [int] the number of missiles being warned on

 

Return the number of missiles a specific mainframe has warnings for

 

I:GetMissileWarning(mainframeIndex, missileIndex)
Inputs: mainframeIndex: [int] the index of the mainframe.
missileIndex [int] the index of the missile

 

Outputs: [MissileWarningInfo] information on the missile. missileWarningInfo.Valid = false if you didn't request an existing missile index (or mainframe)

 

Request information on a specific missile warning

 

MissileWarningInfo
Valid: [bool] false if the warning is junk due to incorrect indices.
Position: [Vector3] the position of the missile
Velocity: [Vector3] the velocity of the missile in meters per second
Range : [float] the distance from centre of mass of your construct to the missile
Azimuth :[float] the azimuth angle between your construct's forward direction and the missile (degrees)
Elevation: [float] the elevation angle between your construct's forward direction and the missile (degrees)
TimeSinceLaunch: [float] the time since missile launch.
Id: [int] the unique Id of the missile

 

Missile Guidance

Connect LUA Transceivers to your missile blocks to allow missiles from those missile blocks to be send LUA Guidance points

 

I:GetLuaTransceiverCount()
Inputs: N/A

 

Outputs: [int] the number of Lua Transceivers

 

Return the number of LuaTransceivers Each transceiver can have a number at missiles which are controllable

 

I:GetLuaControlledMissileCount(luaTransceiverIndex)
Inputs: luaTransceiverIndex: [int] the index of the LuaTransceiver where 0 is the first one

 

Outputs: [int] the number of missiles associated with that LuaTransceiver

 

Retuins the number of missiles which that LuaTransceiver has communications link to

 

I:GetLuaTransceiverInfo(luaTransceiverIndex)
Inputs: luaTransceiverIndex: [int] the index of the LuaTransceiver where 0 is the first one

 

Outputs: [BiockInfo] a BlockInfo object for the LuaTransceiver's Launchpad

 

Returns a BlockInfo obiect for the LuaTransceiver's Launchpad. If no Launch pad exists it'll return it for the LuaTransceiver.

 

See the Components tab for the BlockInfo structure

 

I:GetLuaControlledMissileInfo(luaTransceiverIndex,missileIndex)
Inputs: luaTransceiverIndex: [int] 0 is the first one.
missileIndex: [int] 0 is the first missile.

 

Outputs: [MissileWarningInfo] Get a MissileWarningInfo object for your missile.

 

Returns a MissileWarningInfo structure tor your missile. You can tell where it is and how fast it is going from this

 

See the Missile Warning tab for the MissileWarningInfo structure

 

I:SetLuaControlledMissileAimPoint(luaTransceiverIndex,missileIndex,x,y,z)
Inputs: luaTransceiverIndex: [int] as above.
missileIndex: [int] as above.
x,y,z: [floats] global coordinates of the aim point

 

Outputs: N/A

 

Sets the aim point. No guidance modules will help achieve this aim point so do your own predictive guidance. Needs a lua receiver component ON the missile to work.

 

I:DetonateLuaControlledMissile(luaTransceiverIndex,missileIndex)
Inputs: luaTransceiverIndex [int] as above.
missileIndex: [int] as above.

 

Outputs: N/A

 

Explodes the missile. Needs a lua receiver component ON the missile to work.

 

I:IsLuaControlledMissileAnInterceptor(luaTransceiverIndex,missileIndex)
Inputs: luaTranceiverIndex: [int] 0 is the first one
missileIndex: [int] 0 is the first one

 

Outputs: [bool]: true means the missile has an interceptor module, otherwise false is returned. If the missile has no lua receiver false will be returned.

 

Find out if the missile has an interceptor capability.

 

I:SetLuaControlledMissileInterceptorTarget(luaTransceiverIndex,missileIndex,mainframeIndex, targetIndex)
Inputs: luaTransceiverIndex: [int] 0 is the first one
missileIndex: [int] 0 is the first one
mainframeIndex: [int] 0 is the first one
targetIndex: [int] 0 is the first missile which that mainframe has a warning for

 

Outputs: [N/A]

 

Set the target of an interceptor missile to be a specific missile tor which a warning exists. This is enough to get the interceptor missile to behave normally but it you want to actually guide it yourself use SetLuaControlledMissileInterceptorStandardGuidanceOnOff to turn the guidance oft.

 

I:SetLuaControlledMissileInterceptorStandardGuidanceOnOff(luaTranceiver,missileIndex, onOff)
Inputs: luaTransceiverIndex: [int] 0 is the first one
missileIndex:[int] 0 is the first one
onOff: [bool] true will use standard missile guidance to aim at the interceptors target, false will rely on SetLuaControlledMissileAimPoint for aiming coordinates. Outputs: N/A

 

Turns standard guidance tor the missile on and off. Turn it off it you're doing to guide the missile in yourself.

 

Spinners

Spin blocks have their own interface (rather than sharing the component interface), to allow complete control with a minimum of confusion

 

I:GetSpinnerCount()
Inputs: N/A

 

Outputs: [int] the number of spinners. This includes 'dedicated helispinners', which may be mounted on traditional spin blocks.

 

Returns the number of spin blocks and dedicated helispinners

 

I:GetSpinnerInfo(index)
Inputs: indexr: [int] 0 is the first spin block

 

Outputs: [BlockInfo] a block info object for the spin block.

 

Returns block info for the spinner. For a spin block it will return block info where local positions and rotations are those of the actual spinning assembly. not the block itself.

 

I:SetSpinnerSpeedFactor(index,speedFactor)
Inputs: index: [int] the index of the spinner.
speedFactor: [float] 0 to 1, the fractional power output

 

Outputs: N/A

 

Set the speed factor, In continuous mode spinners this allows some blades to spin slower than others, in insta-spin blades this is related to the speed they are spinning at (1 is max speed. 0 is no speed). and in rotation spinners this does nothing.

 

I:SetSpinnerPowerDrive(index,drive)
Inputs: index: [int] the index of the spinner. 0 is the first.
drive: [float] the relative power use of the spinner (0 to 10).

 

Outputs: N/A

 

Sets the power drive. this allows heliblades to produce more force. Requires engine power. 0 removes engine use. 10 is maximum power use.

 

I:SetSpinnerRotationAngle(index, angle)
Inputs: index: [int] 0 is the first spinner.
angle: [float] angle in degrees to turn to.

 

Outputs: N/A

 

Sets the angle of rotation. Chanqes the spinner into Rotate mode. 'Rotatebackwards' is not available through this interface but you shouldn't need it.

 

I:SetSpinnerContinuousSpeed(index, speed)
Inputs: index: [int] 0 is the first spinner.
speed: [float] speed to rotate at. 30 is the maximum so values from -30 to 30 work.

 

Outputs:

 

Sets the speed of rotation, Changes the spinner into continuous mode. 'ContinuouseReverse' mode is not available through this interface so set the speed neqative to facilitate reverse spinning.

 

I:SetSpinnerInstaSpin(index,magnitudeAndDirection)
Inputs: index: [int] 0 is the first spinner.
magnitudeAndDirection: [float] -1 means spin backwards full speed, 1 is spin forwards full speed

 

Outputs: N/A

 

Spins the blades in a direction and speed determined by magnitudeAndDirection. Will set the spinner into instaspin forwards mode and will affect speed factor variable of the spinner.

 

I:IsSpinnerDedicatedHelispinner(index)
Inputs: index: [int] 0 is the first spinner.

 

Outputs: [boot] true if the spinner is a dedicated spinner.

 

Returns whether the spinner in question is a dedicated helispinner

 

I:IsSpinnerOnHull(index)
Inputs: index: [int] 0 is the first spinner

 

Outputs: [bool] true if on hull

 

Returns whether the spinner is on the hull or on another spin block. This can only be true for dedicated helispinners

 

I:SetDedicatedHelispinnerUpFraction(index,upFraction)
Inputs: index: [int] 0 is the first spinner.
upFraction: [float] 0 to 1.

 

Outputs: N/A

 

Only works for dedicated helispinners. Sets the fraction of the force that will be applied directly upwards. reqardless of blade orientation.

 

Friendlies

The following API will provide you with the positions of friendly vehicles- in the same manner as

 

I:GetFriendlyCount()
Inputs: N/A

 

Outputs: [int] the number of friendlies spawned into the world

 

Returns the number of lriencllv constructs

 

I:GetFriendlyInfo(index)
Inputs: index: [int] 0 is the first construct

 

Outputs: [FriendlyInfo] the FriendlyInfo object

 

Returns a friendly info obiect for a friendly vehicle

 

I:GetFriendlyInfoById(Id)
Inputs: Id: [int] the Id you want

 

Outputs: [FriendlyInfo] the FriendlyInfo object

 

Returns a friendly info obiect for an Id

 

FriendlyInfo
Valid:[bool] false if the Friendly Info could not be retrieved
Rotation:[Quatemion] the rotation of the friendly construct
ReferencePosition: [Vector3] the position of the construct (world East Up North frame) from which PositiveSize and Negative size are referenced
PositiveSize: [Vector3] the extent of the construct in the right,up,forwards direction relative to ReferencePosition
NegativeSize: [Vector3] the extent of the construct in the left,down,back direction relative to ReferencePosition
CenterOfMass: [Vector3] the centre of mass of the construct in world East Up North frame
Velocity: [Vector3] the velocity of the construct in world East Up North frame
UpVector: [Vector3] The up vector in world East Up North frame
RightVector: [Vector3] The up vector in world East Up North frame
ForwardVector: [Vector3] The forward vector in world East Up North frame
HealthFraction: [float] the fraction of health (including turrets etc)
SparesFraction: [float] the spores fraction. Returns 1 if no spares storage present
AmmoFraction: [float] the ammo fraction. Returns 1 if no spares storage present
FuelFraction: [float] the fuel fraction. Returns 1 if no spares storage present
AxisAlignedBoundingBoxMinimum: [Vector3] the world East Up North minimum extent of the construct
AxisAlignedBoundingBoxMaximum: [Vector3] the world East Up North maximum extent of the construct
BlueprintName: [string] the name
Id: [int] the unique Id of the construct

 

コメント