This allows us to upgrade or change the behavior of our calculator program without recompiling it. The calculator function will not care as long as the functions have the same names and take the same inputs. Since the calculator finds the math functions every time it runs, we can create a new DLL with the same function names but better implementations and substitute it for the old DLL. If we know that the math functions are likely to change, we can put them into a DLL and have the calculator program find these functions when it runs. If we simply compile the math functions into our program, then when we change the math programs (for example, to make them faster or more accurate), we have to recompile our whole program. Consider the case of a set of math functions for a calculator.
But the exported functions in the DLL can then call the internal functions.ĭLLs are powerful because the program that uses the DLL finds and runs the code in the DLL when it is executed, not when it is compiled. A program can only directly call the exported functions in a DLL, because it must find these functions through the directory. Not all of the functions in the DLL are exported functions that are not exported are said to be internal. The functions in this directory are known as the exported functions because the DLL is said to “export” them to other programs. Other applications can read that directory to find the function they are looking for. Instead the DLL contains lots of functions, and another program uses the DLL by calling these functions.Ī DLL contains a directory of the functions inside. A DLL does not contain a “main” function that is run once to run the entire program. DLLs are different from normal programs in a few key ways. About DLLsĪ dynamically linked library (DLL) is a set of compiled functions or procedures and their associated variables. Plugins are DLLs an understanding of DLLs is necessary to understand how plugins work. For example, there is an API to program the simulator’s Flight Management System. Other subsystems require more complex interaction and have specific APIs. For example, to set the elevation of the cloud bases, we simply set that variable in the sim.
Some parts of the simulator are controlled simply by writing data to the simulator. (These APIs are discussed in more detail below.) Control various subsystems of the simulator.For example, a plugin can create popup windows with instruments or dialog boxes. For example, a plugin can change the aircraft’s position, or replace the simulator’s flight model entirely. Modify data in the simulator, changing its actions or behavior.
For example, a plugin can continually read the values of the flight instruments and send them over the network. For example, a plugin can run constantly inside the simulator and log data to a file. Run code from inside the simulator, either continually (for example, once per flight cycle) or in response to events inside the simulator.
But since plugins are not full programs, they have limitations that normal programs do not. Because plugins run “inside” the simulator, they can accomplish things that a standalone program might not be able to. Plugins are different from conventional programs in that they are not complete programs in themselves, but rather program fragments that get added to X-Plane while it runs. Plugins allow you to extend the flight simulator’s capabilities or to gain access to the simulator’s data. Plugins are executable code that are run inside X-Plane. You may not need a plugin for what you are trying to accomplish, and a plugin may not be able to accomplish what you are trying to do.
What a Plugin is and What Plugins Can Doīefore discussing how to write a plugin, we will describe to some extent what it can do. If you have not done modular programming using DLLs, we introduce the concepts and also provide step-by-step examples of writing a very basic plugin. If you are an experienced programmer, you may already be familiar with some of the material presented here. This article describes the basics of what a plugin is, how it works, and describes how we write one. Plugins are modular, allowing developers to extend the simulator without having to have the source code to the simulator. A plugin is executable code that runs inside X-Plane, extending what X-Plane does.