View Full Version : programming delays
Rasmothius
5th October 2008, 12:36 AM
hi everybody.im taking a break from sims for a bit and am playing a rpg for the time being.i use my mouse on right hand and a ch pro throttle[usb] for my left.most basic movement and spells i have on macros.iwant to beable to have multiple key presses with justone button press.e.g. hat 3 right [b13] iwant to press once have a 2 second delay then the next keypress happens,another 2 second delay then a final keypress happens.that would be the end of it.any help appreciated as im really not that good with cms script!thanks
Bob Church
5th October 2008, 02:35 AM
Hi Rasmothius,
It's kind of difficult to avoid CMS for longer delays like that. There's the CHARDLY character that you can insert in a key macro and it gives a one-character delay time, but it has the disadvantage that it's treated like a character and so the map has to wait while the delay runs. One or two CHARDLYs aren't really noticeable, but two seconds would be about 40 of them and the rest of the map would stop entirely.
The script really isn't that hard to set up. Probably you'd want to use SEQUENCE statements. For example:
>> iwant to beable to have multiple key presses with justone button press.e.g. hat 3 right [b13] iwant to press once have a 2 second delay then the next keypress happens,another 2 second delay then a final keypress happens. <<
You've got one input (B13), I'm going to assume it's on the leftmost controller in the map the one on the tab right next to the "Program Settings" tab. In the script you would reference it as JS1.B13. You have three keypresses 2 seconds apart, I'm going to assume they're three different characters, so you would need to use 3 CMS buttons. The script itself would look like this:
script
sequence
wait( js1.b13 ); // Wait for the button
cms.b1 = TRUE; // Turn on CMS.B1
delay( 1 ); // Wait while it sends the first character
cms.b1 = FALSE; // Turn CMS.B1 off
delay( 40 ); // Wait 2 seconds
cms.b2 = TRUE; // Turn CMS.B2 on
delay( 1 ); // Wait while it sends the second character
cms.b2 = FALSE; // Turn CMS.B2 off
delay( 40 ); // Wait 2 seconds
cms.b3 = TRUE; // Turn on CMS.B3
delay( 1 ); // Wait while it sends the third character
cms.b3 = FALSE; // Turn CMS.B3 off
endSequence
endScript
At the end of the sequence, the three characters will have been sent and it won't do it again until you click JS1.B13 again. Then you'd just need to program the 3 characters to the 3 CMS buttons up in the GUI.
It really takes less time to do it then it does to explain it. If you set up the macros you want, I can set up the script for you and in the end it will be a couple of button clicks to get into the CM Editor, and then a cut 'n paste of the script from the message board.
Without the script, you're pretty much out of luck in most practical situations. CHARDLY is meant to be used when a key need to stay down for a couple of cycles, maybe provide a little delay between characters, but for longer delays like that it causes more difficulties than it eliminates.
If you want to pursue it, let me know what the macros need to be and I'll set the script up. It's really a lot easier than it looks.
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Rasmothius
5th October 2008, 03:07 PM
thanks very much bob!i was hoping it would be you that replied!actually the macros would be [in order] the 6,7 and 8 keys with the 2 second delays in between 6 and 7, and 7 and 8.again thanks for your help.
Rasmothius
5th October 2008, 03:39 PM
hi again bob.sorry just read my response and i need to be more clear.[still waking up] i have used a basic map for my game and it already has an cms script started.i used a script that i found here a while ago that changes the mini joystick to 4 keypresses instead.cms.b1=[js1.a1<96]; so cms buttons 1 through 4 are used already.that is all that is in the script for now.the rest of the map is all macros, just single keypresses.on my throttle hat 3 up is bound to 5[to match up with in game action bar 5], right to 6 ,down to 7 and left to 8.it is the 6 key[b13] where i would like to have the sequence start.press the 6 key[b13] and it fires a single keypress,[in game actionbar 6] 2 second delay then another single keypress [in game action bar 7] 2 second delay then a final single keypress [in game action bar 8]. i apologize for lack of caps bob i type very slow.thanks again for help
Bob Church
5th October 2008, 10:12 PM
Hi Rasmothius,
>> hi again bob.sorry just read my response and i need to be more clear. [still waking up] i have used a basic map for my game and it already has an cms script started.i used a script that i found here a while ago that changes the mini joystick to 4 keypresses instead.cms.b1=[js1.a1<96]; so cms buttons 1 through 4 are used already. <<
Well, you're really about set. You can't use CMS.B1...CMS.B4, but aside from that the script should work fine. It just needs to be merged into the existing CMS file. I'm guessing that the script you're talking about is the one that looks like this:
script
cms.b1 = [ js1.a1 < 96 ];
cms.b2 = [ js1.a2 > 160 ];
cms.b3 = [ js1.a1 > 160 ];
cms.b4 = [ js1.a2 < 96 ];
endScript
Just add the script I posted above into that script and change the CMS.B1..CMS.B3 references to CMS.B5..CMS.B7 so they don't conflict. It would end up looking like this I'd think:
script
// Existing Script
//
cms.b1 = [ js1.a1 < 96 ];
cms.b2 = [ js1.a2 > 160 ];
cms.b3 = [ js1.a1 > 160 ];
cms.b4 = [ js1.a2 < 96 ];
// Macro Script
//
sequence
wait( js1.b13 ); // Wait for the button
cms.b5 = TRUE; // Turn on CMS.B5
delay( 1 ); // Wait while it sends the first character
cms.b5 = FALSE; // Turn CMS.B5 off
delay( 40 ); // Wait 2 seconds
cms.b6 = TRUE; // Turn CMS.B6 on
delay( 1 ); // Wait while it sends the second character
cms.b6 = FALSE; // Turn CMS.B6 off
delay( 40 ); // Wait 2 seconds
cms.b7 = TRUE; // Turn on CMS.B7
delay( 1 ); // Wait while it sends the third character
cms.b7 = FALSE; // Turn CMS.B7 off
endSequence
endScript
You can just copy the Macro Script portion and paste it into your existing script with the CM editor.
Up in the GUI you'd need to program Buttons 5, 6, and 7, on the CMS Controls tab to send the 3 characters. You don't want them to repeat, so tag a NULL on them, e.g. "6 NULL", "7 NULL", and "8 NULL". Also, if you're cutting and pasting, you need to have just one "script" statement at the top and one "endScript" statement at the bottom.
One other note. The 2-second delays are based on the "Character Rate" setting on "Program Settings" tab in the GUI. It defaults to "50" (milliseconds) so a delay of 40 gives you 40 x 50 milliseconds = 2 seconds. If you've changed the Character Rate setting, you would need to adjust the value accordingly. Actually, Windows isn't all the precise about timing anyway, so you may need to tweak the values a little in any case.
Give it a try and see how it goes!
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Rasmothius
7th October 2008, 06:37 PM
thanks bob.it works perfectly!
Bob Church
7th October 2008, 07:02 PM
Hi Rasmothius,
>> thanks bob.it works perfectly! <<
You're quite welcome! I'm glad it did the job for you!
Enjoy!
Best regards,
- Bob
The StickWorks
http://www.stickworks.com
Powered by vBulletin® Version 4.1.4 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.