Best way to code a mod/plugin?

Hi, I’m new at the SDK and I was wondering what is the best way/route to
create a plugin/mod that handles the aircraft behavior. I would like to start
with something basic, like starting behavior, engine flood for too much
priming and such things. I’m still reading the SDK Docs but I’m a bit
confused. I’ve seen other projects code and I’ve seen that some uses C++
and/or Rust for creating WASM modules (FBW). But I’ve also seen the
ModelBehaviorDefs XML stuff, which is very confusing to me TBH. Also, if I
have some behaviour code for an Asobo base aircraft, do I need to copy the
whole model into another version of the aircraft? Is there any way to attach
the code to a existing aircraft?

Hello and welcome @ecardona5 Regarding Model Behaviors, check the
documentation here: Model Behaviors

You will need xml behaviors to configure interactions and animations The
advantage of using Model Behavior xml is that you have templates to start
from. You can quickly implement basic logic using simvars and local vars. The
drawback is that when template don’t cover what you want to do, you’ll have to
create your own component and it can be a bit tricky sometimes. If you want to
implement some more advanced logic, WASM can be handy: WebAssembly

You’ll be able to write and read simvars, local vars and send events as well
using the GaugeAPI. You’ll be able to render gauges using GDI+ or NanoVG.
Depending on what you want to do, you might need both. Regarding your last
question, although I’m not sure if you are talking about XML or WASM, yes most
of the code can be applicable to other aircraft. Just make sure the file and
node names are matching the new model in the case of XML. Obviously, some code
is context dependant and jet engine logic will fail if used on a piston
aircraft for example. I hope this helps. There are plenty of aircraft creators
here that will have good advice as well I’m sure. Enjoy your development and
let us know if you encounter any issue. Regards, Sylvain

Just getting started on this myself, and was going to ask the same question.
Is there a starter project for writing a complete standalone WASM custom
flight model that you can hook up to the existing aircraft sample project (for
example)? I can’t find a clear concise pathway to get started on doing this,
and was wondering if I missed it somewhere? Thanks! Paul

Somebody made this: The WT CJ4 FADEC
module used to be around (I can’t seem to find it right now), and was also a
good learning resource. This did everything except setting the flight model
physics, but that part is actually the same data flow anyway.

Thanks. I saw the brick project. Will have a look for WT CJ4 FADEC.

“Is there a starter project for writing a complete standalone WASM custom
flight model” just because the Volocopter has a custom flight model doesn’t
mean it’s possible :slight_smile: I’m not aware of any API that lets you apply any force
to the aircraft, it’s really difficult to guess how many tricks and hacks are
in the Volocopter implementation. I’m guessing they have the MSFS simulation
turned off so are applying micro-adjustments to the planes position and
orientation but the the simconnect/WASM interface isn’t designed for that,
neither is the sim, maybe it’s ok for a drone. Note that the WASM interface
does NOT have the access to the core sim that the native MSFS flight model
has. The simvars updates are in a separate thread and slightly out of sync by
the time you get them in the WASM module. You only notice this when you try
and write truly real-time physics code in MSFS which is a very niche
requirement compared to simply reading simvars and updating a display which is
typically unaffected by the varying latency. I have real-time code in my
gliders (there are instruments that need additional ground-up physics
calculations) and the only practical way to do that has been to place those
calculations in the MODEL XML and pass the results through to Javascript/WASM
via custom variables. There is another clever trick to animating the aircraft
(i.e. you want to control the physics, but have the core engine smoothly move
the SimObject around) which is to put the object into SLEW mode and control
it’s translational and rotational velocities. This is much less vulnerable to
stutter than doing the ‘obvious’ thing and trying to update its position on
each frame. Is any of this documented? No. But it’s pretty unusual programming
also. In summary, if you’re “new at the SDK” then programming a ‘typical’
instrumentation module (such as a FADEC or any panel instrument or even
utility module) is almost certainly a pre-requisite, that type of code is
99.999% of any WASM code out there, and then moving onto a flight model would
position you as one of the global elite MSFS programmers.