Entity API
Entity represents the owning structure for a block (ship, station, etc).
Typical usage
local entity = console.getBlock().getEntity()
print(entity.getName(), entity.getEntityType())
local reactor = entity.getReactor()
print("Reactor HP:", reactor.getHP(), "/", reactor.getMaxHP())
Identity and location
getId()Returns the numeric entity ID.getName()Returns the entity’s display name.setName(name: String)Sets the entity’s display name.getPos()Returns current world position asLuaVec3f.getBoundingBox()Returns the entity’s local-spaceBoundingBoxsnapshot from the game’s internalSegmentController.getBoundingBox()method.getSector()Returns current sector coordinates asLuaVec3i.getSystem()Returns current solar system coordinates asLuaVec3i.
BoundingBox exposes:
getMin()Returns the local-space minimum corner asLuaVec3f.getMax()Returns the local-space maximum corner asLuaVec3f.getCenter()Returns the midpoint betweenminandmaxasLuaVec3f.getDimensions()Returns the local-space size(max - min)asLuaVec3f.getEntityType()Returns the entity type string:"SHIP"or"SPACE_STATION".
World access and nearby entities
getBlockAt(position: LuaVec3i)Returns theBlockat the given local block position, ornil.getNearbyEntities()ReturnsRemoteEntity[]for all non-cloaked, non-jammed entities in adjacent sectors (within 1 sector radius).getNearbyEntities(radius: Integer)ReturnsRemoteEntity[]withinradiussectors.radiusis clamped to a maximum of 3.
Faction and diplomacy
getFaction()Returns theFactionthis entity belongs to.getSystemOwner()Returns theFactionthat owns the current solar system, ornilwhen unowned.
Systems and modules
hasReactor()Returnstruewhen a reactor is installed.getReactor()Returns theReactorwrapper.getMaxReactorHP()Returns the reactor’s maximum HP.getReactorHP()Returns the reactor’s current HP.getThrust()Returns theThrustwrapper.getShieldSystem()Returns theShieldSystemwrapper.getShipyards()Returns allShipyard[]wrappers on this entity.
Docking and rails
getTurrets()ReturnsEntity[]of turrets currently docked to this entity.getDocked()ReturnsEntity[]of all entities currently docked to this entity.getDockedEntities()Alias ofgetDocked(). ReturnsEntity[]of all entities currently docked to this entity.getParent()Returns the parentEntitythis entity is docked to, ornilif this entity has no parent.getRoot()Returns the rootEntityfor this entity’s current rail docking chain.isEntityDocked(entity: RemoteEntity)Returnstruewhenentityis docked to this entity.undockEntity(entity: RemoteEntity)Disconnectsentityfrom this entity’s rail system.undockAll()Releases all docked entities.dockTo(station: RemoteEntity, railDockerBlock: Block)Automatically finds the nearest compatible rail block onstationand connectsrailDockerBlockto it. Docking checks sector validity and server-configured docking permissions, and uses a server-configured snap radius.dockTo(station: RemoteEntity, railDockerBlock: Block, dockPos: LuaVec3i)DocksrailDockerBlockto the specific rail block at local positiondockPosonstationwhen within the server-configured snap radius and permission rules.dockToNearestLoadDock(station: RemoteEntity, railDockerBlock: Block)Dock to the nearestRAIL_LOADblock onstation. For cargo pickup.dockToNearestUnloadDock(station: RemoteEntity, railDockerBlock: Block)Dock to the nearestRAIL_UNLOADblock onstation. For cargo delivery.dockToNearestBasicRail(station: RemoteEntity, railDockerBlock: Block)Dock to the nearestRAIL_BLOCK_BASICblock onstation.dockToNearestDockerRail(station: RemoteEntity, railDockerBlock: Block)Dock to the nearestRAIL_BLOCK_DOCKERblock onstation.dockToNearestPickupArea(station: RemoteEntity, railDockerBlock: Block)Dock to the nearestPICKUP_AREAblock onstation. Used for carrier launch/recovery.dockToNearestPickupRail(station: RemoteEntity, railDockerBlock: Block)Dock to the nearestPICKUP_RAILblock onstation.dockToNearestExitShootRail(station: RemoteEntity, railDockerBlock: Block)Dock to the nearestEXIT_SHOOT_RAILblock onstation.
AI / status
getAI()Returns theEntityAIwrapper for this entity.getSpeed()Returns current speed in blocks/s as aDouble.getHeading()Returns normalized forward heading asLuaVec3f.getUp()Returns normalized up vector asLuaVec3f.getRoll()Returns the current roll angle in radians relative to galactic up (world Y axis). Returns0when pointing straight up or down.getMass()Returns total mass as aDouble.isJamming()/canJam()/activateJamming(active: Boolean)Jamming state query and control.isCloaking()/canCloak()/activateCloaking(active: Boolean)Cloaking state query and control.
Inventory / fleet
getNamedInventory(name: String)Returns theInventorywhose custom name matchesname, ornilwhen not found.getPilot()Returns the pilot’s player name, ornilwhen unoccupied.isInFleet()Returnstruewhen this entity is assigned to a fleet.getFleet()Returns theFleetwrapper, ornilwhen not in a fleet.