PDA

View Full Version : CMS: Giving a button two functions dependant on time



Cougar_DK
3rd April 2010, 06:59 AM
Hi,

I'm just started to look at CMS scripting even though my first CH sticks is about 6 years old now :)

Is it possible to script a button to send one value if its just pressed and released and another value if its held for some time?

I simple yes or no would be great (want to learn this) :D

Thanks in advance
Mark

L1049HPilot
3rd April 2010, 06:07 PM
Hi,

I'm just started to look at CMS scripting even though my first CH sticks is about 6 years old now :)

Is it possible to script a button to send one value if its just pressed and released and another value if its held for some time?

I simple yes or no would be great (want to learn this) :D

Thanks in advance
Mark

Check out timers in the Help file.

Snappahead
3rd April 2010, 10:08 PM
There's also a good example of this in the "Scripting Examples Forum" - I think its the first on there.

ruggbutt
4th April 2010, 02:00 AM
Yes, it's possible to do that. I have a bunch of that scripted in my game. Paste this code into your CMS profile.


/////////////////////////////////////////////////////////////////////
// Airbrake Toggle/Hold/Release Command
/////////////////////////////////////////////////////////////////////

timer( PERIOD, D1, 4 ) = js2.B16;
cms.B46 = D1 AND NOT js2.B16;
cms.B47 = NOT D1 AND js2.B16;This script lets you "quick click" and send one command, or you can "hold" the button and have another. In the first line js2.B16 refers to Joystick number two (Pro Throttle) button number 16 (the bottom hat when you press it "up". Make sure you have this selected in DX Mode in your CH profile. You can figure out which button is which by looking at the command button side of CH Control Manager (CHCM). Click the button you want to use and it should tell you what button number it is (except for the Coolie hat, and you'll have to do a search on these forums to find that out, I don't recall what they are right now.

Next, cms.B46 refers to button 46 on the CMS tab. Hover your mouse over the buttons and find 46. Uncheck DX mode and the "press/release" windows will show up. Choose whatever command you want for the "quick click" and put it in there. Now you have cms.B47 which is button 47 on the CMS tab. Uncheck DX mode and input your command in the box. Save and "download the profile.

So now that you know how that works, I'll tell you how it works in my game. If I quick click the bottom hat "up" quickly, my airbrake toggles and stays extended. I can quick click again and it closes. Now if you're flying formation sometimes you don't need full extension on the airbrake to tuck in nice and tight. With the second command "where I hold/release" the airbrake extends as long as I have the button held "up". When I release it the airbrake closes. Since the airbrake takes a few seconds to go from closed to full extension you can pop the brakes open a quarter of the travel with this script.

I hope that helps. I owe everything I know about this stuff to Bob Church, Ghost and Ulf.

Cougar_DK
5th April 2010, 04:39 PM
Thanks for the help and inspiration!

ruggbutt
5th April 2010, 10:15 PM
You're welcome. I'm still a n00b at all of this but the aforementioned people really made me want to learn. :)

Jagged
16th April 2010, 01:29 AM
Thanks ruggbutt great working script, currently I'm studing your FC2 profile to understand a little bit about programming... Thanks again..