# Avorion Script API Documentation

Home Functions Search
Search:

PlanPart PlanPart
Properties
allrounders
features
numBlocks
othersPaddingBox
paddingBox
selfPaddingBox
symmetries
transformationFeatures
Member Functions
block
connector
erase
getBlock
getBlocks
getConnectors
getPlan
merge
mirror
resize
rotate
scale
setConnectorFlags
setPlan
transform

# PlanPart

function PlanPart()

Returns

A new instance of PlanPart

property int... allrounders |

Indices of all blocks that can be used as allrounders by the generator. Allrounder blocks can be changed to other types by the generator to ensure that a ship has enough energy or can fly

property int... features |

All features that this particular part supports. Note: Will be set (and possibly overridden) by generator.lua

property int numBlocks | [read-only]

property Box othersPaddingBox |

A padding box around the part that, after placement of the part, will remain mostly unoccupied by other parts

property Box paddingBox | [write-only]

A padding box around the part that is to remain free. Internally sets othersPaddingBox and selfPaddingBox

property Box selfPaddingBox |

A padding box around the part that, during placement of the part, must not be occupied too much by other parts

property var... symmetries |

All symmetry axes of the part. These will not get verified in any way, so make sure they're correct! Note: Will be set (and possibly overridden) by generator.lua

property TransformationFeature... transformationFeatures |

All transformation features that this particular part supports. Note: Will be set (and possibly overridden) by generator.lua

function int block(int parentIndex, var directionOrPosition, int blockType, vec3 [or nil] size, var color, Matrix [or nil] orientation, var secondaryColor)

Adds a new block to the part.

Parameters

parentIndex The index of the block this one is attached to
directionOrPosition Direction the block is attached in. Can be a vec3 or a direction. A position must be passed as a vec3 and will be clamped so the new block and parent block touch each other. A direction can be passed as a string ("x", "-x", "px", "nx", "+x" etc.), an ivec3, or an int (-x = 0, +x = 1, -y = 2, +y = 3, -z = 4, +z = 5)
blockType The BlockType of the new block
size The size of the new block. If nil, the size of the parent will be used
color The color of the new block. Can be passed as a Color type, a table with HSV values {h=1, s=1, v=1}, a table with RGB values {r=1, g=1, b=1}, a vec4 (will be interpreted as RGBA), a vec3 (will be interpreted as RGB), or as a number (will be interpreted as a hex int). If nil, color of the parent block will be used.
orientation A matrix containing the orientation of the block. If nil, the identity matrix will be used.
secondaryColor The color of the new block. Similar to color. If nil, ColorNone() will be used.

Returns

The index of the new block

function var connector(int blockIndex, var direction, table_t flags)

Adds a new connector to the part. Connectors are used to attach parts during the generation process. Connectors are always in the middle of a block. No 2 connectors in the same direction can exist on the same block.

Parameters

blockIndex The index of the block the connector is attached to
direction Direction of the connector. A direction can be passed as a string ("x", "-x", "px", "nx", "+x" etc.), an ivec3, or an int (-x = 0, +x = 1, -y = 2, +y = 3, -z = 4, +z = 5)
flags Optional table with flags: {mirror = "x", repeatable = true, featureWhitelist = {...}, featureBlacklist = {...}, out = true, in = true}
flags.mirror: Direction that connector should mirror in. All subsequent parts added to this connector will have the same mirror direction.
flags.out: Counterpart to "inOnly". Mutually exclusive. Connector is only used when the part was already attached to the plan. It cannot be used to attach the part itself to the plan.
flags.inOnly: Counterpart to "out". Mutually exclusive. Connector is only used to attach the part to the plan. It cannot be used to other, subsequent parts to this part.
flags.repeatable: Allows the part to repeat itself at this connector. See PlanGenerationStage docs for more details.
flags.featureWhitelist: An array-style table containing features. Only parts with the herein defined features can be added to this connector.
flags.featureBlacklist: An array-style table containing features. Only parts without the herein defined features can be added to this connector.

Returns

nothing

function var erase(int blockIndex, var direction)

Erases a block or connector

Parameters

blockIndex The index of the block
direction Optional. If set, tries to erase a connector from the block into the direction. If nil, the block is erased.

Returns

nothing

function BlockPlanBlock getBlock(int index)

Finds a block.

Parameters

index The index of the block

Returns

BlockPlanBlock The block, or nil if not found

function int... getBlocks(int... types)

Gathers all blocks of certain types.

Parameters

types The types of the blocks

Returns

A table containing the found blocks.

function table_t... getConnectors()

Returns

Returns a table with all connectors of the part

function BlockPlan getPlan()

returns the internal plan of the part

function int... merge(int... blocks)

Merges blocks, similar to the building mode command.

Parameters

blocks An array-style table containing all block indices that are to be merged

Returns

multiple return values: All block indices that remain of the blocks passed into the function

function var mirror(var axis)

Mirrors the entire part along an axis.

Parameters

axis Direction around which axis the part should be rotated. A direction can be passed as a string ("x", "-x", "px", "nx", "+x" etc.), an ivec3, or an int (-x = 0, +x = 1, -y = 2, +y = 3, -z = 4, +z = 5)

Returns

nothing

function var resize(int blockIndex, var x, var y, var z)

Resizes a block

Parameters

blockIndex The index of the modified block
x The x scale factor
y The y scale factor
z The z scale factor

Returns

nothing

function var rotate(var axis, int times)

Rotates the entire part around an axis X times by 90 degrees.

Parameters

axis Direction around which axis the part should be rotated. A direction can be passed as a string ("x", "-x", "px", "nx", "+x" etc.), an ivec3, or an int (-x = 0, +x = 1, -y = 2, +y = 3, -z = 4, +z = 5)
times The amount of times the part should be rotated. Can be -2, -1, 1, 2

Returns

nothing

function var scale(vec3 factor)

Scales the entire part.

Parameters

factor vec3 containing the scale factors

Returns

nothing

function var setConnectorFlags(int blockIndex, var direction, table_t flags)

Sets the flags of a connector. Note: internally calls erase() and then connector()

Parameters

blockIndex The index of the block the connector is coming from
direction The direction of the connector
flags The new flags of the connector. See connector() function for details on those

Returns

nothing

function var setPlan(BlockPlan plan)

Sets the entire plan of the part.

Parameters

plan The used plan

Returns

nothing

function var transform(int blockIndex, table_t flags)

Changes some properties of the given block.

Parameters

blockIndex The index of the block
flags Flags table containing the changes of the block. If nil, this property of the part isn't changed: {type = BlockType.Hull, lower = vec3(...), upper = vec3(...), position = vec3(...), size = vec3(...), color = ..., orientation = Matrix()}
flags.type: The new type of the part
flags.lower, flags.upper: vec3s containing the new lower, upper dimensions of the block. Do not use together with position, size
flags.position, flags.size: vec3s containing the new position, size dimensions of the block. Do not use together with lower, upper
flags.color: The new color of the block. See block() for details on how to pass colors
flags.orientation: Matrix containing the new orientation of the block

Returns

nothing

Overview
Home Functions Search
Search:
Callbacks
Callbacks Alliance [Client] Callbacks Alliance [Server] Callbacks Alliance [Server] Callbacks Entity Callbacks Galaxy Callbacks Player Callbacks Player [Client] Callbacks Sector Callbacks Server Callbacks
Predefined Functions & Example Scripts
Command Entity FactionDatabase PlanGenerator Player Sector Server UsableInventoryItem
Common Components
Boarding BspTree CargoBay CargoLoot ControlUnit CrewComponent DeletionTimer DirectFlightPhysics DockingClamps DockingParent DockingPositions Durability EnergySystem Engine FighterAI Hangar HyperspaceEngine InteractionText InventoryItemLoot Owner Physics Plan ReadOnlyBoarding ReadOnlyBspTree ReadOnlyCargoBay ReadOnlyControlUnit ReadOnlyCrew ReadOnlyDeletionTimer ReadOnlyEnergySystem ReadOnlyEngine ReadOnlyFighterAI ReadOnlyHangar ReadOnlyHyperspaceEngine ReadOnlyInteractionText ReadOnlyOwner ReadOnlyPhysics ReadOnlyPlan ReadOnlyShipAI ReadOnlyShipSystem ReadOnlyTorpedoAI [Server] [Client] [Server] [Client] ReadOnlyTorpedoAI [Server] [Client] [Server] [Client] ReadOnlyTorpedoLauncher ReadOnlyTurretBases ReadOnlyVelocity ReadOnlyWeapons ReadOnlyWormHole Shield ShipAI ShipSystem StructuralIntegrity SystemUpgradeLoot Thrusters Torpedo TorpedoAI TorpedoLauncher Turret TurretAI TurretBases Velocity Weapons WormHole
Common Objects
AllianceMember AllianceRank BlockPlan BlockPlanBlock BlockStatistics Box Captain Color ControlUnitSeat CraftDesign CraftStatsOverview Crew CrewMan CrewProfession DebugInfo dvec2 dvec3 dvec4 Entity EntityDescriptor FighterTemplate Format GameSettings Group HighResolutionTimer Inventory InventoryTurret ivec2 ivec3 ivec4 Language Mail Material Matrix ModManager NamedFormat PlanBspTree PlanetSpecifics PlanGenerationStage PlanPart PlanStyle PlayerId PluralForm Profiler QuadTree Random Rarity Ray ReadOnlyEntity Rect Relation Scenario SectorView Seed Sphere Squad SystemUpgradeTemplate Timer Tooltip TooltipLine TorpedoShaft TorpedoTemplate TradingGood TurretDesign TurretDesignPart TurretTemplate UsableInventoryItem Uuid VanillaInventoryItem vec2 vec3 vec4 Version Weapon
Client Components
EntityIcon EntityTooltip PlanMesh ReadOnlyIcon ReadOnlyPlanMesh ReadOnlyScriptUI ReadOnlyTooltip ScriptUI
Client Objects
Achievements Alliance [Client] CameraKeyFrame CaptainSelectionItem Client ClientSettings ColorSelectionItem CraftDesignSelectionItem Faction [Client] Galaxy [Client] GalaxyMap GameInput GlowFX IconSelectionItem InputWindow InventoryReferenceSelectionItem InventorySelectionItem Keyboard LaserFX Mouse Music PixelIconSelectionItem Planet Player [Client] PlayerWindow RefractionFX Sector [Client] SelectionItem ShipDatabaseEntry [Client] SoundSource StrategyState TargetIndicator TooltipRenderer TurretDesignSelectionItem
Client UI Objects
AllianceEmblem AllianceTab ArrowLine Button [Client] [Client] Button [Client] [Client] CaptainIcon CaptainProfile CheckBox ComboBox ContextMenu CraftPortrait CrewBar Frame Hud InventorySelection Label Line ListBox ListBoxEx MapArrowLine MapIcon MultiLineTextBox NumbersBar Picture PlanDisplayer ProgressBar SavedDesignsSelection ScrollFrame Selection ShipWindow Slider StatisticsBar Tab TabbedWindow TextBox TextField TooltipDisplayer Tree UIArbitraryHorizontalSplitter UIArbitraryVerticalSplitter UIContainer UIElement UIGridSplitter UIHorizontalLister UIHorizontalMultiSplitter UIHorizontalSplitter UIOrganizer UIRect UIRenderer UIVerticalLister UIVerticalMultiSplitter UIVerticalSplitter ValueComboBox Window
Server Components
EntityTransferrer FighterController Loot ReadOnlyEntityTransferrer ReadOnlyFighterController ReadOnlyLoot ReadOnlyTurretController ReadOnlyWreckageCreator TurretController WreckageCreator
Server Objects
Alliance [Server] Faction [Server] Galaxy [Server] Player [Server] ReadOnlySector Sector [Server] Server ShipDatabaseEntry [Server]
Enums
AIState AlliancePrivilege BeamShape BlockShading BlockStructure BlockType BlockType2 BoxType BuildError CaptainGenderId ChatChannel ChatMessageType ComponentType ControlAction ControlActionBit ControlStyle CoolingType CraftStatsOverviewStat CrewProfessionType CrewRank DamageSource DamageType DeletionType Difficulty EntityArrivalType EntityType FighterOrders FighterStartError FighterType FontType ImpactParticles InventoryItemType JumpError KeyboardKey ListBoxEntryType MalusReason MaterialType MoonType MouseButton PlanetType PlanTypeFilter PlayerStateType ProjectileShape RarityType RelationStatus SavedDesignType ScenarioType SectorChangeType ShipAvailability SoundType StatsBonuses TargetIndicatorVisuals TransformationFeature TurretAutoFireMode TurretSlotType WeaponAppearance WeaponCategory

This is the official documentation for the scripting API of Avorion. This documentation is automatically generated and not necessarily complete. Depending on the context in which functions exist, some documentation such as descriptions, return values or variable names or types may be missing.

Work in Progress. Documentation of Avorion Version: 2.5.8 a0d3f0b5b065