Hello! Black Falcon here, and I will be giving a guide as to how to build a more realistic engine in XML.
Mods Required
On the mods side, the only mod you need for optimal realism, unless you intend to use whatever coding interface you use to mod XML, is the 
Parts
What you will need is a more immersive cockpit. What usually works well for me is to build a figure(I will provide one soon in a pack based on what configuration you're looking to use). The next thing you need is a piston-propeller engine, a Blade T-1000 or T-2000.
What you next need is at least two switches. Grab a switch, put it in the cockpit, and have that switch be the battery switch. Personally, I use the "Battery" label, but you can use "Batt" or even "B." if you so desire. Then, set its interaction type to toggle. Next, clone the switch and set its input name to be what you will for the magneto switch. I put multiple magneto switches per engine, so with a twin engine aircraft, I like to put "Mag1A" and "Mag1B", "Mag2A" and "Mag2B," but again, use what you will to name your magneto switches.
The next thing you need at minimum is a button set to toggle for fuel control. However, for more realism, you can use a Simple Throttle part for fuel mixture. Should you use the Simple Throttle approach, whatever input variable you use for the fuel mixture control, you'll need to repeat it in the variables section.
For an engine starter, you'd only need to have a simple button, its interaction type would not need to be changed. just set the starter button's input name, repeat that in the variables menu, then set the priority of the variables menu version to a negative number.
The Code
After all that, the next thing you'd need is an "Engine Running" variable. Best use any combination of non-spaced letters and numbers of your choice as long as you can repeat them easily, and a "Throttle" variable. Put the throttle variable in the propeller, and you have a more realistic piston engine.
NOTE: It is best to put a number if you intend to use "Throttle" or else the game would get confused.
The following will be the code example used for said engine realism on a single engine aircraft, with certain context beforehand:
Inputs
Fuel Mixture:FM
Left Magneto:MagA
Right Magneto:MagB
Starter:Starter
Variable Outputs
Propeller RPM:RPM
Variables
Eng
:RPM>150&FM>0?FuelMix*max(MagA,MagB):0
Thr
:Eng=1?max(Throttle*FuelMix,1-pow(RPM/300,5)):0
FM
:FM
Starter
:0[Priority=0]
FuelMix
:.8+(FM*0.1)
On the Propeller Side
Now, where you set the starter input is up to you, but in the propeller, you would put, courtesy of Funky Trees:
Propeller Input
:'Thr+(Eng=0?Starter*Battery:0)'
Combat Realism, Damage Models
If you are interested in building a combat aircraft, you can get damage models for "oil coolers" in one of two ways:
The Glass Block-Rotator Method
This is the simplest way to give a damage model, code wise. It works by the rotator's rotating end being connected to a glass block. When the glass block is shot, the rotator stops turning as it falls off. All you need to do is connect the rotator to the glass block, set the rotator's input(in funky trees), to
sum(true)
disable the rotator's collisions, then set the variable for the rotator's current angle, and in the XML variables editor, get an indication of if that rotator is rotating or not in the form of
abs(rate([INSERT ROTATOR ANGLE NAME HERE]))>0?1:0
come up with a way to indicate the time it has until the engine dies. For example, O is the rotator angle for the oil cooler, the rest is given in these lines of code:
'Oi':'abs(rate(O))>0?1:0'
'OC':'10-smooth(Oi=0?10:0,Oi=1?1:1/OLT)'
'Oil':'Clamp01(OC)'
If you are looking at a water-cooled engine, you can do the same with the water to incorporate into the engine variables, but whatever you do, you would add that value to the aforementioned throttle variable, like this, with the other example of a starter function also down below:
Thr
:Eng=1?max(Throttle*FuelMix,1-pow(RPM/300,5))*Oil:smooth(pow(Starter,2),1/10)
The Falling Cockpit Method
Now, a more complex but quieter method of computing damage modeling would be the cockpit-coordinate method. When the same glass block is shot, the cockpit piece falls away, and once it reaches a set distance from the master cockpit, the game indicates that the system is damaged. Attach a scaled to tiny scale cockpit block to the glass block alone. To use this method, it is best to put a cockpit on the opposite side(If you intend to put the damage model in the wings or some point to the left or right of the main cockpit). I like to use X for longitude, Y for altitude, and Z for latitude. Then, set the damage model cockpit's coordinates in a likewise fashion. Oi
in this case becomes the distance between the primary cockpit and the damage model cockpit:
Oi
:`sqrt(pow(X-OX,2)+pow(Y-OY,2)+pow(Z-OZ,2))'
'OC':'Oi<ChooseDistance?1:0'
In this instance, ChooseDistance is any maximum distance you want, but preferably within the spatial dimension of the aircraft(in meters).
And there you have it! A basic tutorial on a more realistic engine behavior.
holy damn this is useful
huh.