PDA

View Full Version : Need Help with Eject Script



Perfect_Form
4th May 2009, 08:14 PM
Hello,
I'm trying to use the fail safe ejection script I found on here with DCS: Black Shark. If you are unfamiliar with the script, it just waits for js2.b2, js2.b3, and js3.b4 to all be held down, then hits eject. The problem I have is that either before or after all the buttons are pressed, their is input from the functions assigned to each button.

Basically, I'm not sure if I should put a delay on the 3 buttons or if I need to add to the script something that would nullify the buttons' function if more than one of them is pressed.

Thanks,
Perfect_Form

CMS

script
SEQUENCE
WAIT( JS2.B2 AND JS2.B3 AND JS2.B4 );
DELAY( 10 );
CMS.B1 = TRUE;
DELAY( 10 );
CMS.B1 = FALSE;
DELAY( 10 );
ENDSEQUENCE
endScript

Bob Church
4th May 2009, 10:00 PM
Hi Perfect_Form,

There's no real way to avoid that. I guess the assumption is the things a piece of falling junk at that point, the other functions aren't likely to be doing anything that matters.

You could use a delay, but the delay would have to be applied to the singular function to delay those a little so you had time to get them all pressed before anything happened, but the way it's set up the individual function would have to be delayed and that might not be workable.

You might try other buttons, maybe some that don't really matter. Hats are good, since at worst your just looking and that wouldn't probable matter. It's not really going to matter which way you're looking anywhere anyway.going to need them anyway.

Another possibility that might be usable is to use a combination that requires both hands, Hat 1 up and Hat 2 down, something that you're not going to be doing in normal flight, or perhaps a shifted function that your not using and then a fairly long time delay before the bail out so that you won't hit it by mistake, e.g. a shifted hat up that didn't do anything unless is was held for a couple of seconds held for 1 or 2 seconds. before it bailed. You just need to find some combination that you won't hit be mistake.

Best regards,

- Bob

The StickWorks
http://StickWorks.com

Perfect_Form
4th May 2009, 10:32 PM
Hey Bob,

I suppose you are right about it not mattering, because I'm bailing out. It is a minor issue, but I was hoping it might have a simple solution. I have js2.b3 and js2.b4 assigned to cockpit illumination and collective brake, respectively. I'm not even sure what the collective brake is used for at this point. So, I think I may just add a delay to those two buttons. If that doesn't work out, I always have the thumb-stick button, which I have yet to use effectively for anything, so it is currently unassigned.

Thanks,
Perfect_Form

Bob Church
5th May 2009, 03:00 AM
Hi Perfect Form,

There is another possibility. If you can find a button that has no shift function tied to it already, you could require that the shift button be held and the button be pressed 4 times or so in rapid succession to send the bail out command. So long as you didn't shift it, the button could do normal duty, and even if you did have the shift down, you'd still have to feed it the four rapid clicks to send the bail-out comand. Not hard to script that if you think it might be an improvement.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Perfect_Form
5th May 2009, 03:15 PM
Hi Bob,

Right now, I have only one assignment for each of the 3 buttons in question. Button 2 is SHIFT, while Button 3 & 4 only have a shifted function, unless all buttons are pressed, in which case, it ejects. However, I think I like your idea better.

I'm a scripting novice, so what might such a script, with multiple inputs in succession, look like?

Thanks,
Perfect_Form

Bob Church
6th May 2009, 11:48 AM
Hi Perfect Form,

This seems to do what you need. It's based on a script I did sometime back and just uses two button, js1.b2 and js1.b3. Other buttons could be used as well. You basically have to hold down js1.b2 and then click js1.b3 4 times and it will generate an output on cms.b1. I assigned cms.b1 to CM Device 1, Button 17, then cleared the normal assignments for js1.b2 and js1.b3 (set them to NONE and NONE) so they wouldn't respond and just watched Button 17 in the test screen. I set some timings up so that it's fairly easy to see it work there, you may want to play with those or the number of clicks. In the end, whatever it takes to send the bailout command can be set on Button 1 on the CMS Controls tab. I documented it in the code, it looks like this:


script

// Set an Off Delay timer to set the time for the 4
// clicks. This is the one that sets the "Shift" side
// and holds the shift for a little while, in this case
// about 1/4 second after js1.b2 is released. It makes
// it a bit stabler.
//
timer( OFFDELAY, d1, 2 ) = js1.b2;

// This generate a pulse when the click button is
// pressed. It's the one that needs to get hit 4 times
// while the js1.b2 is pressed. The CLOCKTICK reference
// stabilizes things a little.
//
pulse( d2 ) = js1.b3 AND CLOCKTICK;

// If the shift OFFDELAY hasn't run out yet (it will hold
// for 1/4 second after js1.b2 is released) then we're
// still counting clicks. If we got a click, run the
// count logic.
//
if( js1.b2 ) then

// If the total number of clicks is less than four
// and the click button was clicked during this scan,
// increment the click count in a1. First check the
// count...
//
if([ a1 < 4 ]) then

// If it hasn't hit 4 yet, increment the value.
//
if( d2 ) then
a1 = a1 + 1;
endIf

else

// There have been 4+ clicks so turn on b1 to flag
// that a bailout is needed and reset the counter.
// The b1 bit will eventually cause the command to
// be sent.
//
a1 = 0;
b1 = TRUE;

endIf

else

// The "Shift" pulse is off so the counter and the b1
// flag are are both reset.
//
a1 = 0;
b1 = FALSE;

endIf

// This sets d3 TRUE to activate the output. You can
// adjust it up or down if you need to. The output
// of the timer is on d3, and is transferred to cms.b1
// for output of the button or string to cause the bailout.
//
timer( PERIOD, d3, 5 ) = b1;
cms.b1 = d3;

// Now clear b1 so it won't fire more than once.
//
b1 = FALSE;

endScript

Give it a try and see how it goes.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com