following commit

This commit is contained in:
2026-06-25 04:06:21 -05:00
parent 73a9a6dbdb
commit 173b1d4c48
6 changed files with 117 additions and 58 deletions

105
main.lua
View File

@@ -33,14 +33,37 @@ Thrusters = {
}
} -- Table of thruster tables
ConfigPath = "/config/config.lua"
ThrusterTypes = {
"thruster",
"solid_fuel_thruster",
"ion_thruster",
"vector_thruster",
"liquid_vector_thruster"
}
PropellerTypes = {
"gyroscopic_propeller_bearing",
"propeller",
"propeller_bearing"
}
TransmissionTypes = {
"analog_transmission",
"Create_RotationSpeedController"
}
Config = {}
Config.ConfigPath = "/caero-attitude-control/config/config.txt"
-- Monitor Configuration
Config.Monitors.InstrumentPanelMonitor = nil
Config.Monitors.AutopilotControlMonitor = nil
-- Autopilot
AutopilotEngaged = false -- Is auto-yaw enabled?
AutoForeAft = false -- Is auto-thrust enabled?
AutopilotDesiredSpeed = 0 -- Signed thrust value to compare against VelocityVectors["x"]
AutopilotDesiredHeading = 0 -- If NavTableHasTarget == true this gets ignored in favor of TargetRelativeAngle
Config.Autopilot.AutopilotEngaged = false -- Is auto-yaw enabled?
Config.Autopilot.AutoForeAft = false -- Is auto-thrust enabled?
Config.Autopilot.AutopilotDesiredSpeed = 0 -- Signed thrust value to compare against VelocityVectors["x"]
Config.Autopilot.AutopilotDesiredHeading = 0 -- If NavTableHasTarget == true this gets ignored in favor of TargetRelativeAngle
-- Gimbal Sensor Values
Angles = {
@@ -155,25 +178,15 @@ function ThrottleInit()
end
function PropellerInit()
local propellerTypes = {
"gyroscopic_propeller_bearing",
"propeller",
"propeller_bearing"
}
local transmissionTypes = {
"analog_transmission",
"Create_RotationSpeedController"
}
local transmissions = {}
local propellers = {}
for _, v in ipairs(transmissionTypes) do
for _, v in ipairs(TransmissionTypes) do
table.insert(transmissions, peripheral.find(v))
end
for _, v in ipairs(propellerTypes) do
for _, v in ipairs(PropellerTypes) do
table.insert(propellers, peripheral.find(v))
end
@@ -214,16 +227,10 @@ function PropellerInit()
end
function ThrusterInit()
local thrusterTypes = {
"thruster",
"ion_thruster",
"vector_thruster",
"liquid_vector_thruster"
}
local thrusters = {}
for _, v in ipairs(thrusterTypes) do
for _, v in ipairs(ThrusterTypes) do
table.insert(thrusters, peripheral.find(v))
end
@@ -265,27 +272,15 @@ function Update()
end
local function checkIfThrusterIsIndexed()
local thrusterTypes = {
"thruster",
"ion_thruster",
"vector_thruster",
"liquid_vector_thruster"
}
local thrusters = {}
local unindexedThrusters = {}
for _, v in ipairs(thrusterTypes) do
for _, v in ipairs(ThrusterTypes) do
table.insert(thrusters, peripheral.find(v))
end
local propellerTypes = {
"gyroscopic_propeller_bearing",
"propeller",
"propeller_bearing"
}
for _, v in ipairs(propellerTypes) do
for _, v in ipairs(PropellerTypes) do
table.insert(thrusters, peripheral.find(v))
end
@@ -315,8 +310,10 @@ local function partiallyUpdateThrusters(thrusterList)
"propeller_bearing"
}
-- for every thruster in the input array
-- check if they are one of thrusterTypes
for _, tv in ipairs(thrusterList) do
for _, tt in ipairs(thrusterTypes) do
for _, tt in ipairs(ThrusterTypes) do
if peripheral.getType(tv) == tt then
Thrusters[peripheral.getName(tv)] = {
thruster = tv,
@@ -332,6 +329,34 @@ local function partiallyUpdateThrusters(thrusterList)
}
end
end
for _, pt in ipairs(PropellerTypes) do
if peripheral.getType(tv) == pt then
local thisThruster = {
thruster = tv,
transmission = nil,
type = "rotator"
affectVectors = {
yaw = nil,
roll = nil,
pitch = nil
lateral = nil
},
power = tv.getPower()
}
for _, tt in ipairs(TransmissionTypes) do
local transmissions = peripheral.find(tt)
for _, t in ipairs(transmissions) do
if tv.getSubnetworkAnchorId() == t.getSelfId() then
thisThruster.transmission = t
end
end
end
Thrusters[peripheral.getName(tv)] = thisThruster
end
end
end
end
@@ -475,7 +500,7 @@ function UpdateGlobalThrust()
for _, d in ipairs(thrustDirections) do
for _, t in ipairs(Thrusters) do
if t.affectVectors.lateral == d then
SetThrusterPower(d)
SetThrusterPower(t, d)
end
end
end