Engine modes

An engine's behavior lives in its modes. A single-mode engine has one. A switchable engine (for example a jet with a wet and dry mode) has several, and the player toggles between them. Each mode carries the full set of engine numbers: thrust, propellant, atmosphere curves, throttle response, and so on.

Data_Engine exposes its modes through a typed helper called engineModes, so you do not have to hand-index the raw array. It is an indexed list keyed by each mode's engineID.

Reaching the modes

You get to engineModes through the usual chain: patch the module, patch the Data_Engine, then work with engine.engineModes.

PM.Parts:Patch("TuneTerrierThrust")
        :Named("engine_1v_methalox_terrier")
        :Do(function(part)
            part:PatchModule("Module_Engine", function(module)
                module:PatchData("Data_Engine", function(engine)
                    engine.engineModes:Patch("Engine", function(mode)
                        mode.maxThrust = 60.0
                    end)
                end)
            end)
        end)

engine.engineModes:Patch("Engine", ...) finds the mode whose engineID is Engine and runs the callback against it. The engineID is the mode's key. Single-mode engines all use the key "Engine": the Terrier, Mainsail, Poodle, Reliant, and so on. Multi-mode engines give each mode a descriptive name, like "Dry" and "Wet" on the Panther, "Air Breathing" and "Closed Cycle" on the Rapier, or "Cruise" and "Reverse" on the Wheesley. When in doubt, read the engine's existing modes from the patch cache to get the exact key.

The methods

engineModes is an indexed list, so it has the lookup-by-name methods:

  • engineModes:Patch(engineID, callback) edits an existing mode.

  • engineModes:Add(engineID, callback) adds a new mode with that id and configures it.

Adding a mode is how you turn a single-mode engine into a multi-mode one, though that also means filling in the full set of fields the new mode needs, which is a lot. Most engine patches use Patch to tune a mode that already exists.

What is in a mode

A mode is where the meaningful engine numbers are. A few of the common ones:

  • maxThrust and minThrust, the thrust in kN at full and zero throttle.

  • engineType, the propulsion category (see the enums reference).

  • atmosphereCurve, the Isp-versus-pressure curve.

  • propellant, the fuel mixture.

Data_Engine and its mode form are the largest single structure in the parts API. This page covers reaching and tuning a mode, not every field. The full per-mode field list, with the game's own descriptions, is in pm-parts.d.lua and your editor's autocomplete once you are inside a mode callback.