Space Engineers

Space Engineers

Not enough ratings
O.I.S. Ship Main Computer
By Elfi Wolfe
Guide for how to set up ships and use the Orbital Industrial Services Ships Main Program

Does airpressure, airlocks, hangerbay(one), power readings, orbital holding, autolevel, landing, take offs.
   
Award
Favorite
Favorited
Unfavorite
General Purpose.
Hello,
This is a general purpose program. It covers:
Airlocks
Airpressure
Holding airtanks between two states of fill, giving space for depressurization.
Filling H2 tanks. if this runs it will fill the o2 tanks as well.
1 or unlimitedHanger Bay
Giving a basic power reading
Locking landing gear if a connector is locked
Turns lights green or white if a landing gear is locked
Auto level in gravity field.
Orbit holding code (can be used to launch from surface of planet)
Can use GravDrive in orbit.
Sun chaser (can be use in orbit to get under sun)
(can be use to align toward sun in orbit)
(can be used to align a ship front/side/top towards sun in space)


Example ship
http://steamcommunity.com/sharedfiles/filedetails/?id=824316746


Customization Options.
This section deals with the various sub programs that can be turned off or off.
As well as the default states of each.

runAirGenerator (defalt on) turns on and off O2 generators in order to keep O2 tanks between settings defined in the ship settings section.
runH2Generator (default on) turns on and off O2 generators in order to keep H2 tanks between settings defined in the ship settings section. Right now this will override the O2 settings, set to fill h2 tanks to 100%.
runShowPower (default on) displays basic power in LCD.
runStopShip (default on) turns on dampener if the ship if not piloted by pilot or remote control.
runHangerBay2Control (default off) runs a pressurized hanger bay with two control lights.
runAirlocks (default on) runs the airlock control software.
runAirPressure (default on) runs the airpressure control
runLandingLock (default on) runs the landing pad lock. Locks the landing gear when the connector is locked.
bool runLandingLight (default on) runs the landing pad lights. Turns the light colors depending on if the landing gear is locked to the ship at that connector.
runAutoGyro (default off) runs auto leveling in natural Gravity. Turns the bottom of RC toward natural Gravity.
rocketGyro (default off) used with runAutoGyrofalse if RC bottom towards gravity, true if RC back toward gravity
runOrbital (default off) says ship is orbital around natural gravity. Runs added information in the LCD as well as fires emergency thrusters if the craft goes below the g set in ship settings.
runSunChaser (default off) chase sun. By not having top and bottom panels, will only turn in yaw. By not have or turning off the front panel it will not use thrusters.
runSolarTracking (default off) single axis solar tracking by zone. Can be made to 2+ axis by [zones]
runGravDrive (default off) orbit with gravity drive doing dynamic thrust.
User Customization
Here is where you can set the LCD name if you want to change it from the default of [ShipStatus].
It is at line xxx.
Arguments.
Arguments to run the program with:

"" default argument = does a zone build on start and uses it from there on.

realtime = This is how the older code ran. It would dynamic adjust to zones on each run. Good for ships that are being built or under heavy damage.

hardcoded = To put the zones into a list in the ship customization. This is good for mother ships or stations. Only works on the zones that are hard coded in ship customization.

autolevel = turns on/off the autolevel feature

sunchaser = turns on/off the sunchaser feature

orbit = turns on/off the dynamic orbit.
Note: the engines will still be on override. need to set override to 0 to return control of engines to cockpit.

orbitaltitude = switches between g and m for orbit holding

gravdrive = turns on/off the gravdrive setting.

selectorbitg = change the current desired orbit.
Note: currently 0.5g to 0g. Waiting on update of some api to increase these.
if selectorbitg is set to 0 it goes back to the default orbit in code.

selectorbita = changes the current desired orbit.
Note:currently greater than 15000m. Waiting on update of some api to increase these.
if selectorbita is set to 0 it goes back to the default orbit in code.

solartrack = turns on/off the solar array tracking


Ship customization
Do not edit: bool airZoneNamesHardCode = false;

This is the hard code zones for Air Pressure zones: List<string> airZoneNames = new List<string> {"[HangerFloor]","[ComputerRoom]","[AftStarboard]","[MidStarLiving]","[AftMidLiving]",
"[ForeStarLiving]","[Bridge]","[DroneControlRoom]","[Bridge2]","[InnerWalk]","[MidStar]","[Top]","[Fore Under]",
"[Aft Upper]","[Aft Lower]","[Aft Under]","[Fore Lower]","[MidPort]","[Fore Upper]","[View]"};

Do not edit: bool airLockNamesHardCode = false;

This is the hard code zones for AirLocks zones: List<string> airLockNames = new List<string> {"[Bridge]","[MidStar]","[Top]","[Fore Under]","[Aft Upper]","[Aft Lower]","[Aft Under]",
"[Fore Lower]","[MidPort]","[Fore Upper]"};//

Do not edit: bool padNamesHardCode = false;

This is the hard code zones for Landing pad zones: List<string> padNames = new List<string> {"[Lower Pad Green]","[Lower Pad Yellow]","[Lower Pad Blue]","[Lower Pad Drone]",
"[Upper Pad Green]","[Upper Pad Yellow]","[Upper Pad Blue]","[Under Drone 1]","[Under Drone 2]",
"[Under Drone 3]","[Under Drone 4]","[LargeDroneUnder]"};//

Do not edit: bool solarNamesHardCode = false;

This is the hard code zones for Solar Arrays: List<string> solarNames = new List<string> { "[SolarArrayPort", "[SolarArrayStar]" };

This is to close doors if there is a loss of pressure: bool closeDoors = true;//To close doors if loss of pressure happens

This is the setting for low air pressure (in o2%): int airPressureWarning = 5;
Earth like at sea level is about 5.7%.

This is the name of the outside vent for airpressure outside the ship: string outsideVent = "outsideVent";
outsideVent will get outside pressure but not show on screen, where as [outsideVent] will show the pressure outside.

This is the list of computer that are allowed to run: List<string> whiteList = new List<string> { "MainComputer", "LCDComputer", "IndustryComputer" };
This is default turned off as computer hacking has been disabled for a while now.

This is the name of the timer that runs the main computer: string timerName = "Timer Block MainComputer";
Optional

This is the thrust of the engines, with name defined below at orbitThruster, in newtons: int normalThrust = 280000;//normal force in newton of Ion engines/Grav
Thrust is kN is at http://www.spaceengineerswiki.com/Thruster. Grav engines have a max of 490,500 N per Artificial Mass.

Type of engine for above: string normalEngine = "Ion";//Hydrogen, Ion, Grav

This is the thrust of the emergency engines as defined below at emergencySystem: int emergencyThrust = 900000;//emergency force in newton
Thrust is kN is at http://www.spaceengineerswiki.com/Thruster.

Type of engine for above: string emergencyEngine = "Hydrogen";//Hydrogen, Ion

Name of the emergencySystems for orbital: string emergencySystem = "[EmergencyThrust]";
Downward facing thrusters for emergency use, Sound system and lights to active when emergency thrust kicks in.

This is how low to go before emergency systems kick in: double gravityLimit = 0.3;//limit of how far down in gravity well
This would be the “orbit low” of O.I.S. orbitals

This is the target orbit to stay at: double targetGravity = 0.25;//target of orbit in gravity well
For Earth-like: 15km = 0.46g, 20km = 0.29g, 25km = 0.19g, 30km = 0.12g

Name for Grav Drive gravity generator: string gravDriveName = "[GravDrive]";

Name for Ion/Hydrogen thruster to maintain orbit: string orbitThruster = "[OrbitThruster]";

Name for parts of the Solar Chaser: string sunChaserName = "[SunChaser]";

How fast the Solar Arrays turn (in rpm): float solarAlign = 0.1f;//

How fast to turn the ship to face the sun: float sunTurn = 0.018f;//

What power setting to put the thrusters at for SunChaser (in %): float sunOverride = 10;//

How much to adjust thrusters for orbit maintaining: float orbitalStep = 1;//

Hanger customizations for pressurized Hanger Bay
All the airlock doors should have this in their name: string hangerDoorName = "Hanger";//all airlock doors touching hanger bay

All the vents to the hanger bay should have this in their name: string hangerVentName = "HangerVent";//all vents to Bay

Sound block to turn on when starting pressure change: string hangerSoundName = "Hanger";//alarm to sound

Lights to turn on/flash that the bay is depressurized or depressurizing: string hangerLightsName = "Door Warning";//lights to warn that bay is depressurized or depressurizing

This is the airtight doors: string bayDoorName = "Bay Door";//Must not have in name: hanger, no zone name ie []

Light to turn off to start depressurization: string hangerControlObject1 = "BayDepressure";// Light to say start depressurize

Light to turn on to start pressurization: string hangerControlObject2 = "BayPressure";// Light to say start pressurize

Sensor to turn on once hanger is depressurized: string hangerSensorName = "Hanger";//
Air Locks
Airlocks:

Airlocks must have:
1 vent
1 light
2 doors

Example Airlock:
Door Outer [Fore Under Airlock]
Door Inner [Fore Under Airlock]
Panel Outer [Fore Under Airlock]
Panel Inner [Fore Under Airlock]
Air Vent [Fore Under Airlock]
Light [Fore Under Airlock] Control
Sensor [Fore Under Airlock]
This is an airlock between space (planet) and the living areas of the ship.
The airlock knows it is doing something when the light with Control in its name is turned off. This can be turned off by the button panel outside, the button panel inside the ship or by a sensor in the airlock, (can use a button panel in airlock instead or in addition).

Example airlock between Hanger bay and Living quarters:
Door Hanger [Fore Under Airlock]
Door Inner [Fore Under Airlock]
Panel Hanger [Fore Under Airlock]
Panel Inner [Fore Under Airlock]
Air Vent [Fore Under Airlock]
Light [Fore Under Airlock] Control
Sensor [Fore Under Airlock]
This is an airlock between the hanger bay and the living areas. When the bay is pressurized both doors will open when light control is turned off. If the hanger is depressurized then it operates as an airlock. If the hanger is told to depressurize, then it will close all doors with hanger in their names.

Example airlock between Hanger bay and space (planet):
Door Hanger [Fore Under Airlock]
Door Outer [Fore Under Airlock]
Panel Ouoter [Fore Under Airlock]
Panel Inner [Fore Under Airlock]
Air Vent [Fore Under Airlock]
Light [Fore Under Airlock] Control
Sensor [Fore Under Airlock]
This is an airlock between the hanger bay and space. When the bay is depressurized both doors will open when light control is turned off. If the hanger is pressurized then it operates as an airlock. If the hanger is told to pressurize, then it will close all doors with hanger in their names.

Air Pressurization

Air Pressurization:
Ship is divided up into zones. A zone is defined with [zone].

Pressurization Zone must have:
Vent[LivingRoom1]
Example zone:
Vent[Bridge]
Light[Bridge]
Door1[Bridge][Hall1]
Door2[Bridge][Airlock2] Inner
This example has the vent; a light that turns red if pressure is lost or O2 is too low, turns white when pressure is good; 2 doors, one is between bridge and hall 1 and either zone could close the door on a pressure loss, other door is an inner airlock door.
Hanger Bay
Hanger bay:

hanger bay must have:
vent [HangerVent]
light BayDepressure
light BayPressure

Example:
HangerVent 1 [HangerFloor]
HangerVent 2
Sound block Hanger
Light 1 Door Warning
Light BayDepressure
Light BayPressure
AirTightDoor 1 Bay Door
AirTightDoor 2 Bay Door
Sensor Hanger
The Vents pressurize and depressurize, the vent with [HangerFloor] is the one the airpressurization method talks to; soundlblock plays what ever is programmed into it when the bay starts to depressurize; the light turns on when the bay starts to depressurize; the lights baydepressure and baypressure start the depressurization and pressurization, Note: if both are turned on the program will reset back to pressurized, can be used to stop a depressurization; the airtightdoor are the outside doors that are opened by the sensor once the bay is depressurized.
Orbital
Orbital:
This maintains the ship/satellite at a target g +- 0.005g. Handles the LCD with orbital information as well as turn on the emergency thrusters if the altitude (measured in g) gets below gravityLimit (defaulted to 0.3g).

needs the normal engines facing downward that are to be used to have the orbitThruster name in them. Emergency Thrusters need the emergencyThruster name.

With arguments in the run program you can:
turn on/off orbit method
turn on/off gravDrive
change desired orbit

Example:
Large Ion Engine [OrbitThruster]
Small Hydrogen Thruster [EmergencyThrust]
Gravity Generator [GravDrive]

Needs the following items set in Ship customization:
double gravityLimit (default 0.3g)
double targetGravity (default 0.25g)
string emergencyThruster = "[EmergencyThrust]";
string gravDriveName = "[GravDrive]";
double vLimit = 10;// m/s
string orbitThruster = "[OrbitThruster]";
Orbital Altitude Based (landing)
Orbital: (Altitude Based)
NOTE: this will only work 1.153 or higher
This maintains the ship/satellite at a target altitude above sealevel +-5m. Handles the LCD with orbital information as well as turn on the emergency thrusters if the altitude gets below altitudeLimit (defaulted to 20000).

Right now with a error in MaxThrust, with atmo and ion engines, this code is limit to stay above 15,000m.
If you have only H2 for orbitalthrusters line 261 and 262 can be changed to:
if (double.TryParse(pieces, out te)) {
newAltitude = te;
}
This will allow arguments to change desired altitude:
examples:
selectorbita -1000
selectorbita 10000
selectorbita 40000

If the ship detects land below it will slow down and settle to the land at -1m/s

needs the normal engines facing downward that are to be used to have the orbitThruster name in them. Emergency Thrusters need the emergencyThruster name.

With arguments in the run program you can:
turn on/off orbit method
turn on/off orbitaltitude (use altitude instead of gravity)
turn on/off gravDrive (not usable below 15000, not recomended below 20,000m)
change desired orbit

Example:
Large Ion Engine [OrbitThruster]
Small Hydrogen Thruster [EmergencyThrust]

Needs the following items set in Ship customization:
double altitudeLimit = 20000;//limit of how far down in gravity well
double targetAltitude = 25000;//target of orbit in gravity well
string emergencyThruster = "[EmergencyThrust]";
string gravDriveName = "[GravDrive]";
float gravThrust = 0;//Thrust of GravDrive 490500N = 1g per mass
double vLimit = 10;// m/s
string orbitThruster = "[OrbitThruster]";
double heightCockpit = 100;//height of uppermost shipcontroller from landing.
SunChaser
Sun Chaser:
This allows the ship to turn in yaw and pitch and to move towards the sun.
NOTE: this assume the gyro used is facing the front of the ship.
Or the gyro and all the solar panels face the direction you want the sun to be.

Settings:
sunTurn (default of 0.018) : how fast to turn the ship
sunOverride (default of 10): what % of thrust override to put the thruster at
sunChaserName (default of [SunChaser]): name of the blocks used for this feature

Example design:
Solar Panel [SunChaser] Fore
Solar Panel [SunChaser] Aft
Solar Panel [SunChaser] Port
Solar Panel [SunChaser] Starboard
gyroscope [SunChaser]
Small Ion Thruster 3 [SunChaser] Fore
Small Ion Thruster 4 [SunChaser] Aft

If SunChaser is turned on the ship will turn sideways toward the sun and then move forward.
This is used in orbitals for the orbital to stay on the sunny side of the planet. Commonly used with autolevel and OrbitHolder/OrbitalGravDrive. If you turn off the fore solar panel then it will not move forward.

DeepSpace:

Example design:
Solar Panel [SunChaser] Aft (May not be needed if side panels can see sun from rear)
Solar Panel [SunChaser] Port
Solar Panel [SunChaser] Starboard
Solar Panel [SunChaser] Top
Solar Panel [SunChaser] Below
gyroscope [SunChaser]

If SunChaser is turned on the ship will turn sideways and pitch to face the sun.
This is used in deep space to turn the ship to face the sun.
Solar Tracking
Solar Tracking:

This is a 1 axis solar panel tracking.
It can be used to control more than one axis with each axis/rotor being a seperate axis.

Large arrays on a small ship will torque a little when the rotar starts up. If this happens and it cause problem turn down the rotor's torque

Example:
advanced Rotor [solararray1]
Solar panel [SolarArray1]

There is a lite script version of this which autosets up everything.

This can be used to make a 2 axis tracking.
Rotor [solarArrayHoriziontal]
Solar Panel [solarArrayHoriziontal]
then on the end of the rotor
Rotor[solarArrayVertical]
SolarPanel[solarArrayVertical]
Landing Pad/Lights
Landing Pad/Lights:

This set up locks the landing gear to hold the small ship when the connector is locked.
The lights will turn the light white or green if the landing gear is locked.

These can be used together or seperately.

Idea is to use the large landing gear to hold the small ship securely. No longer needed since connectors now hard lock instead of soft lock.

Example:
Landing Gear [YellowPad]
Connector [Yellowpad]
Light [Yellowpad]
15 Comments
Elfi Wolfe  [author] Oct 3, 2018 @ 7:21am 
It has gone through many optimizations. The building of the lists is generally a one time event, but that is the most costly. And the functions are spread out over 6 parts of the second. On my biggest test grid it is about 0.2 ms. The air pressure changes test is this weekend so I'll check the code vs the test systems.
killroy1975 Oct 3, 2018 @ 6:45am 
looks like a very nice script .. question is .. how laggy is it ..
geniusface1234 Aug 3, 2017 @ 4:44pm 
the station i was building is radially asymmetrical, so i was wondering
the gravdrive torque isnt that bad, and autolevel helps a lot
legit script btw, keep forgetting how useful it is
Elfi Wolfe  [author] Aug 3, 2017 @ 4:32pm 
It does not.. but the autolevel will attempt to compensate to keep the station level in gravity. I tend to put the gravity drive inline with Center of Mass of a station
geniusface1234 Aug 3, 2017 @ 11:53am 
does the gravity drive cancel torque?
geniusface1234 Feb 22, 2017 @ 6:22pm 
oh ok
Elfi Wolfe  [author] Feb 22, 2017 @ 6:17pm 
if you select orbit 0.1 then the script will move to and hold orbit 0.09 to 0.11 g
Elfi Wolfe  [author] Feb 22, 2017 @ 6:16pm 
gravDrive works just like ion thrusters. Just lower energy cost.
geniusface1234 Feb 22, 2017 @ 4:54pm 
do i require a gravity drive to use orbit selecting, or does it only use it for orbit holding?
Elfi Wolfe  [author] Feb 22, 2017 @ 4:26pm 
the orbits are +-0.01 from the target orbit. It needs a little bit of slack or it keeps oscillating.