PDA

View Full Version : Probably very simple, but...


blave
08-01-2005, 02:27 AM
... I am *so* not a programmer and therefore rather than beat my head against the screen for hours, could someone help me out with this?

I have a script that I only want to "happen" in one Mode - the one represented by the red (middle) LED on my Pro Throttle. I would presume I have to encapsulate my script in a "if this_mode then..." or "while this mode, do this...", but a pointer on the general syntax would be appreciated.

Thanks,

Dave Blevins

abe_beson
08-01-2005, 02:38 PM
Originally posted by blave@Jan 8 2005, 01:27 AM
... I am *so* not a programmer and therefore rather than beat my head against the screen for hours, could someone help me out with this?

I have a script that I only want to "happen" in one Mode - the one represented by the red (middle) LED on my Pro Throttle.Â* I would presume I have to encapsulate my script in a "if this_mode then..." or "while this mode, do this...", but a pointer on the general syntax would be appreciated.

Thanks,

Dave Blevins
<div align="right">9690
[/quote]

This might be a little bit harder than it seems, depending on what your script actually does. Could you post the script here so I can have a look at it?

/Abe

blave
11-01-2005, 02:26 AM
Thanks for your reply. My script is at the bottom of this post.

In the meantime I tried to get this to work via CM's "Modes", by assigning the script to CMS buttons only in Mode 2 (which is my helicopter mode - the only place I want this script to work. Mode 2 merely reverses the throttle axis direction). That doesn't seem to work.

Thanks,

dB.


// CMS Script File
//
// Game Title: FS2004, etc.
// Written By: Dave Blevins (based on the Automatic Trim script example found in CM's Help)
// Date: 7-30-2004
//
// Force Trim Release - uses buttons 2 and 4 on the Combat Stick. This emulates functionality
// found in some aircraft, including the Eurocopter AS365 Dauphin twin
// turbine helicopter. This feature allows the pilot to maintain his
// aircraft's attitude without constantly having to hold the cyclic,
// stick, or yoke in the corresponding position - in other words the
// aircraft can be flown "hands off" for short periods of time.
//
// Usage:
//
// With Force Trim Release toggled off with the pinkie (B4) button, the stick behaves
// normally.
//
// Push the pinkie button to engage the Force Trim Release feature. The aircraft will
// maintain whatever attitude it was in when you pressed B4 - assuming that attitude was
// constant. If you were inducing a roll or climb, those actions will increase as if you
// held the stick in that position.
//
// You must press and hold the thumb (B2) button in order to make X/Y control inputs.
//
// Pressing the B4 FTR toggle again returns the stick to its normal behavior.
//
// Force Trim Release is especially useful in FS2004 helicopters, as none have
// any cyclic trim capability, and most do not have an autopilot.
//
//
// Note: the associated map also includes a Pro Throttle axis reverse capability, accessed
// by pressing the microstick button (B1). The first Mode (indicated by the Green LED
// on my PT, although your LED colour arrangement may vary) is for fixed wing
// aircraft. The second Mode (Red LED) reverses the throttle axis, so that it
// more closely emulates the helicopter collective's "pull up and back to go higher"
// behavior.
//
//

SCRIPT

SEQUENCE
WAIT( JS1.B4 ); // pinkie button B4 toggles whether Force Trim Release
B4 = NOT B4; // is in effect
ENDSEQUENCE

IF ( NOT B4 ) THEN // with FTR feature toggled off...
CMS.A1 = JS1.A1; // pass joystick's X and Y input through to Windows
CMS.A2 = JS1.A2; // at all times
ENDIF

IF ( B4 ) THEN // with FTR toggled on...

IF( JS1.B2 ) THEN // If thumb button B2 is pressed then
CMS.A1 = JS1.A1 + A1; // add the X offset to the stick X value
CMS.A2 = JS1.A2 + A2; // and add the Y offset to the stick Y value
ENDIF

SEQUENCE
WAIT( NOT JS1.B2 ); // Wait until Button 2 is released
A1 = JS1.A1 - 128; // Calculate the X offset and save it in A1
A2 = JS1.A2 - 128; // Calculate the Y offset and save it in A2
ENDSEQUENCE

IF ( JS1.B2 ) THEN // pressing B2 again clears the offsets, so that if
A1 = 0; // the stick is centered, the old offsets will not
A2 = 0; // be "flown", which would result in an unexpected
ENDIF // control input.

ENDIF

ENDSCRIPT

abe_beson
11-01-2005, 04:50 PM
Hi again!

I think you are lucky in this script and the if/then construct you proposes should work. As a rule encapsulating sequences in if statements should be avoided however since sequences should all run to their end before aborting them. This is hindered if the condition in the if goes from true to false in the middle of a sequence. In your case your sequences are simple and all sequences will finish in one pass however. This makes it possible to use the if method I think.

The syntax should be like this then:

if([currentMode==MODE2]) then
// your script
else
// do what is needed to do in the other MODEs, or nothing
// perhaps:
CMS.A1 = JS1.A1; // pass joystick's X and Y input through to Windows
CMS.A2 = JS1.A2; // at all times
endif

The currentMode variable actually is an analogue variable thus making the [] necessary, this I have myself missed a number of times! You could also have an else case outputting your axises right away, if necessary.
Good luck,
Abe

Edit: Typo again.... :)

blave
13-01-2005, 06:25 AM
Abe,

Thanks for looking at this. When I get a chance, I'll check it out and report back.

cheers,

dB.