xpl_command "ONCE" & "PRESS"?

Help creating logic scripts for Air Manager Instruments

Moderators: russ, Ralph

Message
Author
JackZ
Posts: 1992
Joined: Mon Feb 22, 2016 1:02 pm

xpl_command "ONCE" & "PRESS"?

#1 Post by JackZ » Fri Jul 23, 2021 11:02 am

Hi @Corjan
In the wiki page http://siminnovations.com/wiki/index.ph ... pl_command, i can see that
xpl_command() can have additional properties, such as BEGIN and END, but i found out that the commands "ONCE" and "PRESS" can also be sent to XPlane.

I have this particular problem in an instrument, where i can trigger a command via Dataref Editor using the command buttons command press and command once.
I found that the corresponding Dataref (which I cannot modify) correctly toggles from 0 to 1 when using the Command press button, but apparently ther is no such feature in the xpl_command() extra parameters

And ofc the basic xpl_command() without the external parameter doesn't work either.
Using this function without parameters apparently sends the "BEGIN/ONCE/END" sequence, which doesn't work in my case, while the command press apparently sends "BEGIN/ONCE/ONCE/ONCE/END", which as not been implemented in AM

So if it deosn't exist already, having additional parameters to additionnaly send "ONCE" or "BEGIN/ONCE/ONCE/ONCE/END" (for command press) would be apreciated to fully use the Xplane commands

Any input?

Thanks

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

JackZ
Posts: 1992
Joined: Mon Feb 22, 2016 1:02 pm

Re: xpl_command "ONCE" & "PRESS"?

#2 Post by JackZ » Fri Jul 23, 2021 3:31 pm

I answered myself, as I found after LOTS of trial and error a workaround kinda.
When one uses a "BEGIN" with the 1 parameter , AM sends to Xplane "BEGIN" and some "ONCE" (every frame?) as long as it doesn't sends an "END" function (0 parameter).
So to emulate a "COMMAND PRESS" function that is needed with some xpl_commands, one needs to introduce a slight delay after the "BEGIN" to let AM send at least two or more "ONCE", then send an "END" to close the command.
Tricky to say the least, and sheer luck I could find a workaround..

Code: Select all

      
 ---------------------------------
 -- xpl_command COMMAND PRESS trick
 ---------------------------------     
      xpl_command("cjs/texanii/commands/rmu_button_dmeh",1)-- "BEGIN is sent then "ONCE" every frame by AM, until "END" is sent
        timer_start(100,nil,function()
                xpl_command("cjs/texanii/commands/rmu_button_dmeh",0)-- after a slight delay of 100msec (adjust to what is needed) send an "END" command to stop
    end)

Another method without timer() is using the button_add(), but it needs a physical or a virtual button of some sort

Code: Select all

function buttonDMEHpressed()

 xpl_command("cjs/texanii/commands/rmu_button_dmeh",1)-- "BEGIN is sent then "ONCE" every frame by AM, until "END" is sent

end


function buttonDMEHreleased()
                xpl_command("cjs/texanii/commands/rmu_button_dmeh",0)--  sendS an "END" command to stop
end

button_add("button_DMEH_released.png","button_DMEH_pressed.png",257,1244,111,63, buttonDMEHpressed,buttonDMEHreleased)
@Corjan , it would be wonderful if you could revisit the xpl_command(), with and additional parameter to differentiate between a « Command once » and a « Command press ».

Thanks

Jacques
Last edited by JackZ on Sat Jul 24, 2021 11:19 am, edited 1 time in total.
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Keith Baxter
Posts: 2960
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: xpl_command "ONCE" & "PRESS"?

#3 Post by Keith Baxter » Fri Jul 23, 2021 3:52 pm

Jacques,

You want it to be like si_command()
I thought that it used to work with xpl_command(). Maybe I am wrong

http://siminnovations.com/wiki/index.ph ... Si_command


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 

JackZ
Posts: 1992
Joined: Mon Feb 22, 2016 1:02 pm

Re: xpl_command "ONCE" & "PRESS"?

#4 Post by JackZ » Fri Jul 23, 2021 5:30 pm

@Keith Baxter
exactly.

But in xpl_command(), the only two parameters available are 1 for "BEGIN" (and I found out that it continuously fires "ONCE" after the initial "BEGIN"), and 0 for "END" (that fires only "END"). If I try to replace the integer parameter by those string, Lua throws an error
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

JackZ
Posts: 1992
Joined: Mon Feb 22, 2016 1:02 pm

Re: xpl_command "ONCE" & "PRESS"?

#5 Post by JackZ » Sat Jul 24, 2021 11:17 am

@Ralph At least modify the Wiki page with the workaround, as the actual « BEGIN » and « END » example are kinda useless at the moment without an actual way to use them?

Thanks

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Corjan
Posts: 2457
Joined: Thu Nov 19, 2015 9:04 am

Re: xpl_command "ONCE" & "PRESS"?

#6 Post by Corjan » Sat Jul 24, 2021 7:34 pm

Hi,


Will have to look closely how it is implemented exactly, has been a while.

Will get back to you next week,

Corjan

User avatar
Keith Baxter
Posts: 2960
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: xpl_command "ONCE" & "PRESS"?

#7 Post by Keith Baxter » Mon Jul 26, 2021 12:24 pm

@Corjan

Please see what you can do for us.
I am on a different project to Jacques and have the same request.



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 

JackZ
Posts: 1992
Joined: Mon Feb 22, 2016 1:02 pm

Re: xpl_command "ONCE" & "PRESS"?

#8 Post by JackZ » Mon Jul 26, 2021 3:59 pm

@Keith Baxter
You can always use the workaround I exposed in my previous posts, to emulate the Command Pressed effect:
Either:
-a button with a Xpl_command BEGIN on pressed() state and an xpl_command END on the released state
or
- send a BEGIN normally, followed by the use of a timer to trigger the END after a slight delay (200 msec seems to work for me).

Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

User avatar
Keith Baxter
Posts: 2960
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: xpl_command "ONCE" & "PRESS"?

#9 Post by Keith Baxter » Mon Jul 26, 2021 4:17 pm

JackZ wrote:
Mon Jul 26, 2021 3:59 pm
@Keith Baxter
You can always use the workaround I exposed in my previous posts, to emulate the Command Pressed effect:
Either:
-a button with a Xpl_command BEGIN on pressed() state and an xpl_command END on the released state
or
- send a BEGIN normally, followed by the use of a timer to trigger the END after a slight delay (200 msec seems to work for me).

Jacques
Jacques

100s

Not so much of a HACK if the the xpl_command() had a pressed feature.

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 

JackZ
Posts: 1992
Joined: Mon Feb 22, 2016 1:02 pm

Re: xpl_command "ONCE" & "PRESS"?

#10 Post by JackZ » Mon Jul 26, 2021 4:49 pm

Indeed, hence my initial request!
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests