# Dataref vs. Command: Know Your Copilots

Okay, aviator—before we start wiring buttons to things like flaps, lights, ejector seats (hey, no judgment), we need to understand the two main languages X-Plane speaks: **Datarefs** and **Commands**.

Think of these like your cockpit crew. One tells you what’s going on. The other *makes* things happen.

#### 🎧 Datarefs: The Sim Whisperers

**Datarefs** are like the gauges and readouts in your cockpit. They **tell you the current state** of something in the sim. They’re *informational*. Want to know if the landing gear is down? There’s a dataref for that. Want to see your fuel level? Yep—dataref.

They're like saying:\
📻 *“Hey sim, what’s the current altitude of this bird?”*\
And the sim replies:\
🛩️ *“You’re at 2,700 feet, boss.”*

You **read** datarefs to get info. Some can be **written to** (we’ll get to that), but they don’t *do* anything on their own.

` ✍️`` `` `*`Example:`*\
`sim/cockpit2/switches/landing_lights_on = 1`\
`(This tells you the landing lights are on. Maybe. Sometimes. Depending on the aircraft. Yay, X-Plane!)`

#### 🛎️ Commands: The Doers

**Commands** are the sim’s action-takers. They **make something happen**—like flipping a switch, toggling a light, or yelling “CLEAR PROP!” before engine start (okay, maybe not that last one… yet).

They’re like saying:\
🎙️ *“Hey sim, turn on the landing lights.”*\
And the sim *does it*—no questions asked.

You don’t get a value back, you just send the command and hope the sim complies. (Most of the time, it does. Sometimes it acts like a teenager.)

` ✈️`` `` `*`Example:`*\
`sim/lights/landing_lights_toggle`\
`(This tells the sim: “Toggle the landing lights!”)`

#### So... Which One Do I Use?

* ✅ **Use a command** when you want to make something happen. (Buttons, switches, momentary events)
* ✅ **Use a dataref** when you want to check the state of something. (LEDs, displays, conditions)
* ✅ Sometimes, use **both** if you want to change something *and* confirm it worked.

#### 🧩 Bonus Tip: Not All Aircraft Play Nice

Some aircraft (especially custom ones) love using their own secret datarefs and commands. So if your button doesn’t seem to be doing anything, you may need to do a little detective work using **DataRefTool** to figure out what’s *actually* going on under the hood.

That's it! You've just passed the "Datarefs vs. Commands" ground school exam. No written test required, but feel free to celebrate with a smug throttle push.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.spadnext.com/simulations/x-plane/dataref-vs.-command-know-your-copilots.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
