The Dataref.set()
sets the value of a dataref. The new value is provided to the dataref's owner, which may or may not change the value of this dataref.
new_value
new_value
is the new value for the dataref. It should be a Number
, String
, or an Array
of Number
s, depending on the type of the dataref.This function has no return value.
TypeError
will be thrown if the wrong type is provided when setting a dataref.Error
is thrown when trying to write a dataref that isn't writable.> dataref = "laminar/c172/fuel/fuel_tank_selector"
Dataref
> 1
undefined
> "banana"
Uncaught TypeError: Invalid value type
> dataref = "sim/version/xplane_internal_version"
Dataref
> 121000
Uncaught Error: Not writable
Number
values are set using: XPLMSetDatad
for doubleXPLMSetDataf
for floatXPLMSetDatai
for intArray
values are set using: XPLMSetDatavf
for float arraysXPLMSetDatavi
for int arraysString
values are set using XPLMGetDatab
; the string is encoded in UTF8.datarefs
can be used as normal variablesset