LuaMacros can control Xplane as my main motivation is flight simulation. You need to install Xplane plugin to get interface to work. Xplane plugin is currently provided only for Windows platform 64bit version. LuaMacros is windows specific program so there's no sense to provide plugin for other platforms. I believe most of windows users fly with 64bit version so I haven't compiled 32bit version. Installation is easy, in Xplane home go to Resources/plugins directory, create luamacros\64 directories and copy win.xpl to 64 directory. Standard thing, no big deal.
Then you can use Xplane related commands in LuaMacros.
Commands
Code: Select all
lmc_xpl_command('sim/view/still_spot')
Some commands can be "started" and "finished" - typically when you need to hold some button like starter. Then you use separate command for start and end
Code: Select all
lmc_xpl_command_begin('sim/engines/engage_starters')
lmc_xpl_command_end('sim/engines/engage_starters')
You can display text in Xplane e.g. to indicate that some actions were executed, mode has changed etc. Then you can call command
Code: Select all
lmc_xpl_text('From LUA macros')
lmc_xpl_text('From LUA macros', 0.5)
lmc_xpl_text('From LUA macros', 0.7, 10)
- (mandatory) text to be shown
- (optional) y-position as float, 0 is top left corner, 1 is bottom left corner. Default is 0.3
- (optional) timeout in seconds, after this timeout text disappears. With 0 timeout text will stay on the screen
Variables are called datarefs in Xplane (SDK). Available datarefs are listed in Xplane's Resources\plugin directory in file DataRefs.txt. Datarefs can be read and some of them (see txt) can be written to. To read dataref use command
Code: Select all
lmc_get_xpl_variable('sim/cockpit2/radios/actuators/adf1_frequency_hz')
Code: Select all
print(lmc_get_xpl_variable('sim/cockpit2/radios/actuators/adf1_frequency_hz'))
Code: Select all
lmc_set_xpl_variable('sim/cockpit2/radios/actuators/adf1_frequency_hz', 425)
Code: Select all
print(lmc_get_xpl_variable('sim/flightmodel/engine/ENGN_thro', 0)) -- throttle of first engine
lmc_set_xpl_variable('sim/flightmodel/engine/ENGN_thro', 0.3, 1) -- set throttle of second engine
Code: Select all
lmc_on_xpl_var_change('sim/aircraft/view/acf_tailnum', function(value)
print('Have new plane ' .. value)
end)
Code: Select all
varName='sim/cockpit2/radios/actuators/adf1_frequency_hz'
lmc_on_xpl_var_change(varName,
function(value, count)
print(varName .. ' changed to ' .. value .. ' with ' .. count .. ' changes')
end, 1000)
The on-change callback can be also unregistered with function
Code: Select all
lmc_remove_xpl_var_change('sim/cockpit2/radios/actuators/adf1_frequency_hz')
Please note the Xplane interface hasn't been tested much. Report any bugs in this forum. Thanks.