Guide / Tutorial Get your Basic TARGET Script - PIPs and Curves here.

Hello fellow scriptwriters,

i am fiddling around with TARGET script editor since 3 or 4 years now... Not too much and not too much into depth, only one thing at a time to get some things working.
I started out with a dual T1600m script for ARMA, since i wanted to change the sensitivity curves for Helicopter movement on the fly.
Which i finally was able to do.

Since some days now, i own a TWCS throttle and give it a try with StarCitizen (yes SC, but no worries i play ED as well a lot ;) )

My problem:
i want the TWCS throttle axis to do thrust forward or backward, but only one direction at a time.
Not too hard till here, actually, since the SC keybinding options does provide you with an option to bind a reverse forward/backward key.
ok...now, sometimes i can not remember which direction is on in a given moment, which can cause some serious problems for your vehicle in the game,
so i was thinking of using one button to change the throttle axis binding to forward movement and another one for backward movement.
Since this is not possible in the SC-options, i came up with the idea to swap axis mapping via TARGET.
With the TARGET script it would be possible to assign one analog axis to forward thrust and a different one to backward thrust.

so maybe just for illustrating, something like this:



//HAT-up button binds the DX-Throttle axis to the slider, which in game is bound to "Thrust forward"
MapKey(&T16000, H1U, EXEC(" MapAxis(&TWCSThrottle, TTHR, DX_THROTTLE_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);"));

//HAT-down button binds the DX-slider axis to the slider, which in game is bound to "Thrust backward"
MapKey(&T16000, H1D, EXEC(" MapAxis(&TWCSThrottle, TTHR, DX_SLIDER_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);"));


if i do that... yah, then i am running out of axes pretty fast, which i do need for the other "normal" six degrees of movement axes...



All that being said, only to ask this question:
-Is there a way to virtually enhance the number of analog axes for the combined joystick?
-Or asked differently: how much axes do i have available, or can i call/map on the combined Joystick?


If i count it i have 9 analog axes on the TWCS Throttle plus T16000m...
As far as i know, there are only 8 DX ones.
x,y,z,xrot,yrot,zrot,slider,throttle

i hope, my question is not too weird and i hope i did not post the wrong question in the wrong thread...
Thank you for your attention :)
 
Last edited:
Hi @SandskinK ,

You are correct...only 8 DX axes in Windows.

You may be able to dynamically use the same axis in the above example by using “AXIS_REVERSED” as an argument.
That is, don't map one to the other, just use the same axis but use REVERSED in the second MapKey statement.
This will save you an axis.

Hope this helps and let us know how you get on.

Clicker
 
Last edited:
Hi Clicker,

thank you for your fast response.
Actually the reverse Axis idea was the first one i came up with, too.
Unfortunately, in this case, it only works as suggested by the word 'reversed'.
So, i have one axis, lets say i have the values
0 -100
If i reverse the axis i have the values
100-0.
What the game needs for backward thrust would be
0 - (-100).

I yesterday tried some strange things with the AXEMAP2... did not work out so well, so far.
my idea was to have several zones and use some code that repeats a keyboard button push (S - key) with different delays in between, representing the different speeds....
dont do it... not good :(, at least the way i tried it, but i am not a math or coding genius.

In SC options, you can bind one axis to forward, one for backward, or one for forward/backward and a key to reverse the forward or backward setting..
not the forward/backward setting, tho.
Confused? yes , me too.
this reverse key works different, than the REVERSE_AXIS command in the script. What it actually does, it changes the sign of the output value from positive to negative
of the one directional bound analog axis.

What i did so far is to bind one axis to one movement direction starting from zero.
since i use a throttle slider and not a joystick with auto centering, i did not want to use a split axis on that....
But after you mentioned the TM-editors revers axis option, i was thinking, i could use indeed a split axis on that and shift the center point on the physical axis, via the script, for the cost of some resolution.

Looks like the script can handle 2048 steps on one axis. The range is
-1024 to 1024,
whereas the value range from the actual throttle axis is
0 to 65535.
So, one tick in the script is around equal to 32 ticks on the physical throttle axis.
I am not really sure, what that means for working with it, in the end.

This is my try to solve that problem now:

Code:
// Bind axis to Throttle

MapAxis(&TWCSThrottle, TTHR, DX_THROTTLE_AXIS, AXIS_REVERSED, MAP_ABSOLUTE);


// Trim Throttle axis

TrimDXAxis(DX_THROTTLE_AXIS, SET(1024));


// initial settings when button pressed

MapKey(&T16000, H1U, EXEC(

                         "MapAxis(&TWCSThrottle, TTHR, DX_THROTTLE_AXIS, AXIS_REVERSED, MAP_ABSOLUTE);"

                         "TrimDXAxis(DX_THROTTLE_AXIS, SET(1024));"

                         ));

                

// reverse initial settings when button pressed           

MapKey(&T16000, H1D, EXEC(

                         "MapAxis(&TWCSThrottle, TTHR, DX_THROTTLE_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);"

                         "TrimDXAxis(DX_THROTTLE_AXIS, SET(-1024));"                   

                         ));

That was my thought...
I am not too good at such things, it seems...
Turns out, i do not only lose resolution with this code, I lose half of my physical axis.
With that code, it works almost as intended, but the axis works only up to 50% of its range, because than i have reached the max output values in both cases

Apart from that it seems to be the right way to go.
 
Last edited:
Hi @SandskinK ,

It's great that you are having a go to sort this out yourself.

If you get stuck, I would recommend you take a look at @Aussiedroid 's script.
I believe he has several methods of changing the throttle axis on the fly.
Whilst written for the Warthog, I'm certain you could use the same or similar theory for your purpose.


Cheers
Clicker
 
Hello Clicker,

thanks for the reply and the link to Aussiedroid's script. I will definitely have a look on it.
In the meantime i tried to simply change the value sign for the axis output value with the trim command and thought that would be the solution.

MapKey(&T16000, H1U, EXEC("TrimDXAxis(DX_THROTTLE_AXIS, SET(TWCSThrottle[TTHR]*(-1));"));

... the more you know.
I was right with my statement of the Throttle axis generating values from 0 to 65535.
The combined Joystick axis, however treats that axis as a split-axis by default, which is then treated by the game as a value array from low to high again.
No way to get to a satisfying solution, that way.

Next approach:

what about having a look on the button states instead of messing with the axes, in this case, since he game already switches direction perfectly.
Only it does it with one button and i so badly want to have it on two buttons, one button for each direction :p

I defined a flag, called "reverse_on", set its initial value to 0/false (just to be sure).
Then i declared a function, which should press my thrust-reverse-toggle key ( in this case i bound that action in game to DX8) and change the flag value between 0 and 1,
each time it is run.

Attention!! here follows a NOT working code ;P


Code:
include "target.tmh"

char reverse_on;    // creating flag
int reverse_toggle;  // creating function

//program startup
int main()
{
   if(Init(&EventHandle)) return 1;

reverse_on=0;      // set flag value to 0/false

reverse_toggle = CHAIN(
                       EXEC("ActKey(PULSE+KEYON+DX8);"),
                       EXEC("reverse_on = !reverse_on;")
                       );   //declaring function


MapKey(&T16000, H1U, EXEC("if(reverse_on) reverse_toggle;"));       // if thrust direction is forward (default) ignore the key press, otherwise run 'reverse_toggle'
MapKey(&T16000, H1D, EXEC("if(reverse_on==0) reverse_toggle;"));    // if thrust direction is back ignore the key press, otherwise run 'reverse_toggle'


}

//event handler
int EventHandle(int type, alias o, int x)
{
   DefaultMapping(&o, x);

   //add event handling code here
}

That gives me an compile OK, if not started. When started and i push one of the buttons, the editor comes up with this message:

Compile error in Execute: = expected, in "if(reverse_on == 0) reverse_toggle;"

Compile error in Execute: = expected, in "if(reverse_on) reverse_toggle;"


i have no clue, why it is expecting a '=' and even the message says "expected in see above...", i don't know where that relation should go to.

Can you help me out?
 
Last edited:
Page 38 in the TARGET Script Manual...

"To keep your CPU’s resources for your flight simulator software, using SEQ, CHAIN, EXEC, TEMPO, AXIS,
LIST inside an EXEC is forbidden"

You seem to be trying to use both CHAIN and then an EXEC within the CHAIN.
You would be better off coding a function and not a MACRO then call the function from the EXEC in the MapKey Statement.

replace...
Code:
reverse_toggle = CHAIN(
                       EXEC("ActKey(PULSE+KEYON+DX8);"),
                       EXEC("reverse_on = !reverse_on;")
                       );   //declaring function
with...
Code:
int reverse_toggle() {
                       ActKey(PULSE+KEYON+DX8);
                      reverse_on = !reverse_on;
}

Then, edit your MapKey statements thus...
Code:
MapKey(&T16000, H1U, EXEC("if(reverse_on) reverse_toggle();")); 
MapKey(&T16000, H1D, EXEC("if(!reverse_on) reverse_toggle();"));

Hope this helps.

Clicker
 
Last edited:
omg yes!!!

The one, who is able to read has an advantage...

Thank you!!!

on site 49 they write "Let’s transform the previous program using a function: "
and this is in the main() function and looks like this
Code:
autopilot = SEQ(   EXEC("ActKey(PULSE+KEYON+'a');"),
                   EXEC("ActKey(PULSE+KEYON+L_SHIFT+'a');"));              //we define the contents of the autopilot function
That got me confused.

I was aware, that i should not use SEQ or CHAIN in an EXEC command, that is why i wrote that function... which, i just learned that now, is actually a macro.
I was trying NOT to use one of the mentioned commands in an EXEC, but visa versa.
The other fact i was not aware of, is that the EXEC command is a function, too.

As you probably have noticed, i am not an native English speaker, that is why reading a manual like the thrustmasters one is not an easy task for me.

Thank you very, very much for clearing some things up for me!!!
And yes! That helped!
A lot! :)

Cheers, SandskinK
 
I am a native English speaker and the TARGET manual is NOT much easier for me!
It does give some good examples, but as I've found is VERY much only a light weight guide.
Many things we either need to work out for ourselves, or rely on other people who have already worked it out.

A site I found helpful after I'd already sussed most things out is...


...whilst aimed primarily at DCS World, there's a couple of very knowledgable programmers on there who are also extremely helpful.

Cheers
 
Last edited:
The second sentence alone already nails it haha!
"The intent is to add some clues to what comes out from experimenting with the language after having read this and messed up with what you think the meaning was. "
Thank you again!
 
Thanks for your input.

This is not a thread for which scripting language is best, nor is it about which controller is best...it’s meant for people who want to learn more about TARGET for their Thrustmaster stick/HOTAS.

Cheers
Clicker
 
Last edited:
In the place of my birth, it is said ignorance is bliss. After seventy years of bliss, today I received my cranial CT scan results. The doctor said nothing found. Therefore, I have an excuse for any question without merit. Seriously, I have the Thrustmaster T-16000M FCS with pedals. I use Voice Attack with HCS profile packs. As a gunfighter, I truly suck. I am going to conquer the FA off flight thru diligent practice or frequent destruction by AI in Mobius PVE. I want to fine tune the response and dead zones. If I set up the joystick response curves with TARGET with no scripting {scripting is another challenge for another day} profile, will it affect the ED / HCS bindings. Thank u 4 ur time on my behalf.
 
In the place of my birth, it is said there are no dumb questions...just dumb answers.
I’ve never had a cranial CT scan and I’ve not had a doctor tell me “nothing found”.

This has zero bearing on the quality of my answer unfortunately.

Short answer is yes.

Longer answer:
In order for the curves to take effect, you must run the TARGET GUI Profile you’ve set up before launching the game (and leave it running obviously).

When you run the Target GUI, it will take any/all of the Thrustmaster devices you enabled in the profile and create a single “combined” device. In doing so, your individual devices, in your case, joystick and pedals, will disappear as individual devices within Windows.

Therefore, you will need to rebind everything in game.

Once done, though, you should then be able to tweak your curves from time to time without having to worry about your binds.

Clicker
 
Last edited:
Hello Clicker,
I have been here in the last year's November to ask you something about the TARGET script and you helped me a lot!

Here i am again with a new question.

I have set up my TARGET script now almost to my entire satisfaction...
Then i thought i could put all the defined keyboard-button-presses in a *.ttm macro file, for better editing convenience and for better readability in the script itself.
So i put all the keys in the macro i could possibly want to use, but when including the *.ttm file the TARGETscript compiler says that there is an error in line 193 of that macro file.
line 193 is not special, it is just another define.
So,if i look at the file size, i do hit the 10kb right there. If i delete some text in the file it is working fine again.
(actually my *.ttm file has 309 lines right now, so if i cut it to the working size i am missing around a third of my commands)

My question:
Do you know if there is a *.ttm file-size restriction?
(obviously there is...)
But do you know if i could alter that restriction somewhere, or do i have to split the *.ttm file in multiple ones?
(which actually would not be too much of a problem, but still, i would like to have my define list in one file, if possible)

Thank you for reading and your answer in advance!


SandskinK

EDIT:
tldr got problem in a macro file, thought somehow it is file-size related.
It turned out, that i have given two commands the same name definition, so the script stopped at the second one.
my bad.
 
Last edited:
@SandskinK, All good.

Yeah, I have a "KeyMap.ttm" file in which I define every single key that is bound in the game's controller settings.
I simply comment out the ones not actually used in the script.

Makes it easy when I want to add or change things around.

Cheers
Clicker
 
I've used the Target GUI to create a small macro to use the APENG to send keystrokes to request docking. Is there a way to do this so that when activated, that is the ONLY HOTAS function that is scripted? When I do it now, the rest of the HOTAS doesn't work anymore.
 
Hi @Wolfang42 ,

My understanding (meaning I've not tried this)...

Add a line to your script up near the top.

Configure(&Throttle, MODE_FILTERED);

This should allow any non-scripted functions (ie DX button presses and the axis) to be passed through.
Any defined functions via a MapKey(&Throttle, APENG, EXEC("runmacro;") ); should be trapped and executed.

Let me know if this works.

Cheers
Clicker
 
Well thanks for the suggestion...I tried it but still no go...all other throttle/joystick functions don't work, only the button programmed with the macro works :(
 
Back
Top Bottom