Sending several commands in X-Plane
Sending several commands in X-Plane
Hey,
I am using the main monitor for displaying the 3D-cockpit and sometimes just the outside view. The outside view requires me to call the "zoom_in"-command 15 times, so it looks halfway realistic. I could set the default viewing angle in X-Plane to match either the internal, or external view. So the default angle is set to the 3D-cockpit.
So when I use the 2nd G1000 screen and show the external world on the the big screen, I need to send those commands. Easy, I thought, just send it 15 times in a row when pressing a button via Arduino.
But no, only one command arrives at X-Plane, the other 14 get lost. Afaik a timer in X-Plane is not possible.
So how to solve this? Wait for next frame generation and send single commands, until 15frames/commands are finished?
Or is there a better way of doing this?
Thanks, Olli
I am using the main monitor for displaying the 3D-cockpit and sometimes just the outside view. The outside view requires me to call the "zoom_in"-command 15 times, so it looks halfway realistic. I could set the default viewing angle in X-Plane to match either the internal, or external view. So the default angle is set to the 3D-cockpit.
So when I use the 2nd G1000 screen and show the external world on the the big screen, I need to send those commands. Easy, I thought, just send it 15 times in a row when pressing a button via Arduino.
But no, only one command arrives at X-Plane, the other 14 get lost. Afaik a timer in X-Plane is not possible.
So how to solve this? Wait for next frame generation and send single commands, until 15frames/commands are finished?
Or is there a better way of doing this?
Thanks, Olli
Re: Sending several commands in X-Plane
Isn't there a dataref for this to set? Sounds much easier and accurate.
- Keith Baxter
- Posts: 4962
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Gauteng
Re: Sending several commands in X-Plane
Hi,frumpy wrote: ↑Tue Mar 25, 2025 1:32 pm Hey,
I am using the main monitor for displaying the 3D-cockpit and sometimes just the outside view. The outside view requires me to call the "zoom_in"-command 15 times, so it looks halfway realistic. I could set the default viewing angle in X-Plane to match either the internal, or external view. So the default angle is set to the 3D-cockpit.
So when I use the 2nd G1000 screen and show the external world on the the big screen, I need to send those commands. Easy, I thought, just send it 15 times in a row when pressing a button via Arduino.
But no, only one command arrives at X-Plane, the other 14 get lost. Afaik a timer in X-Plane is not possible.
So how to solve this? Wait for next frame generation and send single commands, until 15frames/commands are finished?
Or is there a better way of doing this?
Thanks, Olli
Post some code of what you want to do, Remember to include any images if used.
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Sending several commands in X-Plane
It's a larger gauge for controlling a G1000. I load it up with every plane, as I am able to control course, heading and autopilot stuff also on non G1000 planes. Like a general gauge 
I did not find any dataref on the actual zoom factor.
Also, on my 3440*1440 screen I'd like to set the vertical and horizontal viewing angle manually, but I can't do so via dataref. Setting things up in 3D cockpit view means a distorted picture in outside view with 15x zoom pressed (and vise versa).

I did not find any dataref on the actual zoom factor.
Also, on my 3440*1440 screen I'd like to set the vertical and horizontal viewing angle manually, but I can't do so via dataref. Setting things up in 3D cockpit view means a distorted picture in outside view with 15x zoom pressed (and vise versa).
- Keith Baxter
- Posts: 4962
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Gauteng
Re: Sending several commands in X-Plane
Hi,
You going to learn something else new today.
Just a few lines does what you want, You can use the fast or slow option. Anyway here are some options. you can play with them to get your desired result.
Keith
You going to learn something else new today.

Just a few lines does what you want, You can use the fast or slow option. Anyway here are some options. you can play with them to get your desired result.
Code: Select all
hw_button_add("Zoom In Button", function()
xpl_command("sim/general/zoom_in_slow", "BEGIN")
end,
function()
xpl_command("sim/general/zoom_in_slow", "END")
end)
--------------------
hw_button_add("Zoom out Button", function()
xpl_command("sim/general/zoom_out_fast", "BEGIN")
end,
function()
xpl_command("sim/general/zoom_out_fast", "END")
end)
-----------------------------
hw_button_add("Zoom In Button2", function()
for i = 0,14 do
xpl_command("sim/general/zoom_in")
end
end)
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Sending several commands in X-Plane
Thanks Keith, I appreciate it! I like LUA. Gets me into a flow to do stuff and try new things. Also with X-Plane, much easier to interface and do tricks than with other sims.
The for..to-loop does not reach X-Plane, only a single command gets there.
The _fast-command works - however, it very much depends on how long I press the button. So depending on my state of being, it turns out a different zoom factor each time.
I want to drive 2 setups with the sim, one for casual flying in standard 3D-cockpits and one for the homecockpit-setup with the external G1000. For each setup I need a certain vertical/horizontal viewing angle plus a zoom factor.
I want it standardized, press a button once and everything will be setup is set up correctly.
What I found, is that there is no dataref for the zoom. But there are two datarefs to drive horizontal and vertical viewing angle:
sim/graphics/view/vertical_field_of_view_deg
sim/graphics/view/field_of_view_deg
Basically by setting vertical and horizontal angles I control viewing ratio and zoom. I found 98/50.5 deg work well for 3D, and 71/35 look good for the homecockpit view on my 21:9 screen.
I'll try more and report
The for..to-loop does not reach X-Plane, only a single command gets there.
The _fast-command works - however, it very much depends on how long I press the button. So depending on my state of being, it turns out a different zoom factor each time.
I want to drive 2 setups with the sim, one for casual flying in standard 3D-cockpits and one for the homecockpit-setup with the external G1000. For each setup I need a certain vertical/horizontal viewing angle plus a zoom factor.
I want it standardized, press a button once and everything will be setup is set up correctly.
What I found, is that there is no dataref for the zoom. But there are two datarefs to drive horizontal and vertical viewing angle:
sim/graphics/view/vertical_field_of_view_deg
sim/graphics/view/field_of_view_deg
Basically by setting vertical and horizontal angles I control viewing ratio and zoom. I found 98/50.5 deg work well for 3D, and 71/35 look good for the homecockpit view on my 21:9 screen.
I'll try more and report

-
- Posts: 5907
- Joined: Thu Jul 27, 2017 12:22 am
Re: Sending several commands in X-Plane
The zoom is handle internally with those read-only datarefs, so nothing we have hands on :
Code: Select all
sim/graphics/view/projection_matrix_3d
sim/graphics/view/world_matrix
- Keith Baxter
- Posts: 4962
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Gauteng
Re: Sending several commands in X-Plane
Hi,frumpy wrote: ↑Wed Mar 26, 2025 8:02 am Thanks Keith, I appreciate it! I like LUA. Gets me into a flow to do stuff and try new things. Also with X-Plane, much easier to interface and do tricks than with other sims.
The for..to-loop does not reach X-Plane, only a single command gets there.
The _fast-command works - however, it very much depends on how long I press the button. So depending on my state of being, it turns out a different zoom factor each time.
I want to drive 2 setups with the sim, one for casual flying in standard 3D-cockpits and one for the homecockpit-setup with the external G1000. For each setup I need a certain vertical/horizontal viewing angle plus a zoom factor.
I want it standardized, press a button once and everything will be setup is set up correctly.
What I found, is that there is no dataref for the zoom. But there are two datarefs to drive horizontal and vertical viewing angle:
sim/graphics/view/vertical_field_of_view_deg
sim/graphics/view/field_of_view_deg
Basically by setting vertical and horizontal angles I control viewing ratio and zoom. I found 98/50.5 deg work well for 3D, and 71/35 look good for the homecockpit view on my 21:9 screen.
I'll try more and report![]()
Yes for loop does send 15 commands and works. However if you have sent a "BEGIN" either in the sim or via AM it will not work. To overcome this issue we send a "END" command before we do the for loop.
You are aware that you can subscribe to a command? So in the code supplied below I have included a subscribe to check if the commands are in fact being sent multiple times.
Try this code and let me know.
Code: Select all
hw_button_add("Zoom In Button2", function()
xpl_command("sim/general/zoom_in","END")
for i = 0,14 do
xpl_command("sim/general/zoom_in")
end
end)
nn=""
xpl_command_subscribe("sim/general/zoom_in",function(n)
nn=n
print(nn)
end))
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Sending several commands in X-Plane
Thanks, I was able to solve the issue in the meantime. So here is what I come up with:
https://youtu.be/dFY8cmTesdk
As for sending the 15 commands, thanks for the code. I stumbled upon the same issue a few years ago, so it might be handy in the future.
https://youtu.be/dFY8cmTesdk
Code: Select all
xpl_dataref_write("sim/graphics/view/field_of_view_deg", "FLOAT", 98.0)
xpl_dataref_write("sim/graphics/view/vertical_field_of_view_deg", "FLOAT", 50.5)