Static Port

A Static Port is an opening that measures ambient static air pressure. It is usually placed on a flat area of the fuselage, away from airflow disturbances — it feels only the atmospheric pressure, not the ram pressure of the oncoming air.
The static port and the pitot tube together form the "pitot-static system" — icing or blockage of this system has been a factor in several aviation accidents, which is why modern airliners treat its redundancy and anti-icing design so seriously.
The Static Port (ccpe:static_port) is an attachable pressure-sensor block. When installed on a physics body (Sable sub-level), CC:Tweaked computers on that body can read the pressure and altitude at the static port's own position via ccpe.sensor_system.
Reading reference point
ccpe.sensor_system reads at the static port's own position (not the physics body origin):
- Each static port: project its plot position to world → altitude (world Y) and pressure (Sable
DimensionPhysicsData, same formula assimulated:altitude_sensor; sea level = 1.0) at that point. - A body can have multiple static ports, each with its own independent readings.
Lua API
A computer on the same physics body (including constraint chains) uses require("ccpe.sensor_system"):
| Method | Returns | Description |
|---|---|---|
isOnBody() |
boolean | Whether the computer is on a physics body |
getBodyId() |
string / nil | UUID of the containing physics body |
getSensors() |
table | Snapshot of all sensors (same tick): {type, pos={x,y,z}, pos_rel={x,y,z}, altitude, pressure}; pos is relative to the physics body origin, pos_rel is relative to the current computer (recommended for telling ports apart) |
getAltitude() |
number / nil | Altitude (world Y) of the most recently placed static port |
getPressure() |
number / nil | Pressure of the most recently placed static port (atmosphere fraction, sea level = 1.0) |
getAverageAltitude() |
number / nil | Simple average altitude over all static ports |
getAveragePressure() |
number / nil | Simple average pressure over all static ports |
getWeightedAltitude() |
number / nil | Distance-weighted average altitude (weight = 1/distance from the body origin, IDW) |
getWeightedPressure() |
number / nil | Distance-weighted average pressure (weight = 1/distance from the body origin, IDW) |
- With no static port on the body,
getAltitude()/getPressure()returnnilandgetSensors()returns an empty array; the average / weighted-average methods also returnnil. - Readings refresh once per tick (at most 1 tick stale); Lua reads perform zero main-thread scheduling, so high-frequency calls are effectively free.
- Weighted-average edge cases: a port exactly at the body origin (distance ≈ 0) has infinite weight, so its reading is returned directly; with a single port, the average / weighted average equal that port's reading.
local ss = require("ccpe.sensor_system")
print("onBody:", ss.isOnBody())
print("bodyId:", ss.getBodyId())
local sensors = ss.getSensors()
for i, s in ipairs(sensors) do
print(i, s.type,
"pos:", s.pos.x, s.pos.y, s.pos.z,
"pos_rel:", s.pos_rel.x, s.pos_rel.y, s.pos_rel.z,
s.altitude, s.pressure)
end
-- Convenience: most recently placed static port
print("alt:", ss.getAltitude(), "press:", ss.getPressure())
-- Averages / distance-weighted averages (weight = 1/distance from body origin)
print("avg alt:", ss.getAverageAltitude(), "avg press:", ss.getAveragePressure())
print("wavg alt:", ss.getWeightedAltitude(), "wavg press:", ss.getWeightedPressure())
Multiple static ports
A body can carry several static ports, each with independent altitude/pressure readings (same-tick snapshot, e.g. for differential-pressure math):
local sensors = ss.getSensors()
if #sensors >= 2 then
print("pressure difference:", sensors[1].pressure - sensors[2].pressure)
end
After a server restart, getAltitude()/getPressure() may point at a different static port
If the body has only one static port, this warning does not apply.
getAltitude()/getPressure() return data from the most recently placed static port, determined by registration order (= placement order), which is only valid within the current session. After a server restart, static ports re-register in chunk-load order, so these two methods may point at a different static port, and the target may differ between restarts.
If your script must reliably read a specific port, use getSensors() and identify it by pos_rel (position relative to the current computer) — pos (relative to the body origin) drifts when blocks are added to or removed from the body, since the origin (center of mass) moves: