Dataref.value Event

The valuechange event fires when the value of a dataref changes. Detecting changed dataref values and acting on them is generally more efficient than setting a new value every frame, as many Lua plugins do.

Event type

The event uses the ValueChangeEvent object.

Example

> dataref = simulator.findDataref("laminar/c172/fuel/fuel_tank_selector")
Dataref{ name: "laminar/c172/fuel/fuel_tank_selector" }
> dataref.addEventListener("valuechange", (event) => { console.log(`Fuel tank selector changed from {event.last_value} to {event.value}`)})
undefined
Fuel tank selector changed from 1 to 2
Fuel tank selector changed from 2 to 1

References

I'm not aware of any other framework implementing similar functionality for X-Plane.