PDA

View Full Version : Repeating Key commands


Rawles
31-01-2005, 02:56 AM
Hi You scripting pros i tried to modify or shal i say duplicate a function but on my joystick this time.I tried to just change the controller and the button.Hear is what i want to do i want the prop pitch to repeat while pressing the key command on my joystick button 16 and 14.I keep getting a script unreconized.

// CMS Script File
//
// Game Title: Forgotten Battles_Pacific Fighters
// Written By: Louis"Tuxedo"Rawles
// Date: 12-14-2004
//
// Controller buttons used,
%define incFovIn js2.b7
%define decFovIn js2.b5

// CMS buttons used,
%define incFovOut cms.b7
%define decFovOut cms.b5
script
// Increase field of view
sequence
while(incFovIn);
incFovOut=true;
delay(1);
incFovOut=false;
delay(1);
endSequence
//decrease field of view
sequence
while(decFovIn);
decFovOut=true;
delay(1);
decFovOut=false;
delay(1);
endSequence
// Eject
SEQUENCE
WAIT( JS2.B2 AND JS2.B3 AND JS2.B4 ); // Wait for buttons 2,3 and 4 to get pressed on the throttle
DELAY( 10 ); // Wait half a second
CMS.B1 = TRUE; // Start Ejection Sequence
DELAY( 10 ); // Wait half a second
CMS.B1 = FALSE; // Reset CMS B1 state
DELAY( 10 ); // Wait half a second
ENDSEQUENCE
// Controller buttons used,
%define Prop_Pitch_Inc js1.b14
%define Prop_Pitch_Dec js1.b16

// CMS buttons used,
%define Prop_Pitch_Inc cms.b14
%define Prop_Pitch_Dec cms.b16
script
// Prop_Pitch_Inc
sequence
while(Prop_Pitch_Inc);
Prop_Pitch_Inc=true;
delay(10);
Prop_Pitch_Inc=false;
delay(10);
endSequence
//Prop_Pitch_Dec
sequence
while(Prop_Pitch_Dec);
Prop_Pitch_Dec=true;
delay(10);
Prop_Pitch_Dec=false;
delay(10);
endSequence
endScript

I have included a map and cms file in my attachment.

Bob Church
31-01-2005, 04:32 AM
Hi Rawles,

I ran it up and there are a couple of problems. First, down at line 47 you've got an extra "script" statement. There should only be one at the beginning and one at the end, though I think it doesn't complain about anything after the first "endScript" statement. Anyway, you need to get rid of that.

The second problem is that you've defined Prop_Pitch_Inc and Prop_Pitch_Dec twice, that's not going to work. You need to use different names for one set or the other.

Finally, the second time you define those, you set them to js1.b14 and js1.b16. That's not really a problem in itself (aside from the duplicate naming) but a little further down at line 51 or so, you try to set them TRUE or FALSE. You can't set the value on a a joystick button like js1.b14, you're in effect asking the script to press a button on the stick and that's a no-no.

The script error at download isn't very informative. If you open the script in the editor and click the "Check Script" button on the tool bar, it will check it for you there and tell you where it detected the error and try to tell you what it was that it didn't like about it. In this case, it just says something like "ENDSEQUENCE Expected" when it runs into the point where you try to do set the joystick buttons, when you see one like that then there's generally something wrong on the line immediately before the one where the error is reported. It doesn't know what you meant, but whatever you said didn't belong in the sequence so it comlains about that. Not an exact report, but at least you know about where things went astray that way.

Anyway, I'm glad to see you're getting into it! It'll get easier once you've done a few, it just takes a little while.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Rawles
01-02-2005, 12:16 AM
Hey Bob so your saying that i cannot have a repeating command on those buttons i chose?Or am i going about it wrong?

Bob Church
01-02-2005, 10:05 AM
Hi Rawles,

>> so your saying that i cannot have a repeating command on those buttons i chose?Or am i going about it wrong? <<

Neither, actually. I hadn't really looked at the script for logic, just for errors. The main problem is really just the name duplication:

>> // Controller buttons used,
>> %define Prop_Pitch_Inc js1.b14
>> %define Prop_Pitch_Dec js1.b16
>>
>> // CMS buttons used,
>> %define Prop_Pitch_Inc cms.b14
>> %define Prop_Pitch_Dec cms.b16

That just takes changing two of them so they aren't the same. If you rename the first two to Prop_Pitch_Inc_Button and Prop_Pitch_Dec_Button for example, that would get rid of the conflict and fix the script at the same time. I was just saying that you can't define "Prop_Pitch_Inc" as a real joystick button (js1.b14) and then try to force it's state, which is what the lines like:

>> Prop_Pitch_Inc = true

seemed to imply you were trying to do.

If you change the name of the buttons in the %define directives and in the script that problem disappears:

>> // Controller buttons used,
>> %define Prop_Pitch_Inc_Button js1.b14
>> %define Prop_Pitch_Dec_Button js1.b16
>>
>> // CMS buttons used,
>> %define Prop_Pitch_Inc cms.b14
>> %define Prop_Pitch_Dec cms.b16
>>
>> // Prop_Pitch_Inc
>> sequence
>> while(Prop_Pitch_Inc_Button);
>> Prop_Pitch_Inc=true;
>> delay(10);
>> Prop_Pitch_Inc=false;
>> delay(10);
>> endSequence

Now it's just assigning TRUE to a CMS button, perfectly acceptable and really what you meant to do I'm sure. It was just the naming that got in the way.

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

Rawles
02-02-2005, 01:55 PM
Hey Bob thanks for giving me a better explination if what you meant and the visual helped alot!!!.
Being Mr.Mom at home in the evening with 3 boys makes me a little tough to focus

Again thanks i will keep asking and keep learning.
~S~ Rawles

Bob Church
02-02-2005, 03:19 PM
Hi Rawles,

You're quite welcome! I'm glad it was some help!

Best regards,

- Bob

The StickWorks
http://www.stickworks.com