I hope i can get some help here, i've stumbled across this setup file when i was searching for a method to use the secondary trigger button for either shoot weapons maped on second trigger in game or to use it as a macro button for the dss honk (like you pull the trigger to the first stage it starts scanning or firing, if you pull it further to the second stage and let it go it scans / fires automatically for a set amount of time).
i've tried to figure this out by looking at the files but i cant :rolleyes:

Hi Certhas,

The code around the firing is a bit messy due to the multiple variables being tracked (does make it hard to follow even for me!) & then also using a combo function to change the mappings from single to combo fire. Thinking about what you are trying to achieve, I don't think you would need to go down that route as your requirements are a bit more straight forward.

I would probably try to tackle this using a simple modifier (say without modifier it fires weapons, with modifier it uses the scanner). You could do this in-line. If you load up the older version of my script 2.3.0 it should be before I introduced the newer complicated function (To give you an idea anyways).

The logic may follow something along these lines (just off the top of my head, & its 1am so excuse any brevity/mistakes):

MapKey(&Joystick, TG1, EXEC(
"if(!Modifier1) Actkey(KEYON+PULSE+Primary Fire)
"if(Modifer1) Actkey(KEYON+PULSE+Scanner))

MapKey(&Joystick, TG2, EXEC(

"if(!Modifier1) Actkey(KEYON+DOWN+Secondary Fire)
"if(Modifer1) Actkey(KEYON+DOWN+Scanner))

MapKeyR(&Joystick, TG2, EXEC(
DeferCall(TimerDelay, &ActKey, KEYON+UP+Secondary Fire)
DeferCall(TimerDelay, &ActKey, KEYON+UP+Scanner))


You could also look at a variable to track the state for the 'hold' action on the secondary trigger, rather than using a set time 'TimerDelay' such as a 6 sec I use for scanners, and do it manually. This may be better for combat oriented stuff vs scanners as it would need you to press the trigger again to release the hold.

Example:

MapKey(&Joystick, TG2, EXEC(

"if(!Modifier1 & Var1) Actkey(KEYON+DOWN+Secondary Fire)
"if(Modifer1 & Var1) Actkey(KEYON+DOWN+Scanner)
"if(!Modifier1 & !Var1) Actkey(KEYON+UP+Secondary Fire)
"if(Modifier1 & !Var1) Actkey(KEYON+UP+Scanner)
Var1=!Var1



Hope it helps :)
AD
 
Last edited:
will look into it tomorrow
is the modifier a shift button set in the keymap.ttm?
im only using very basic stuff like:
MapKeyIO(&Joystick, H3L, LARROW, CHAIN(PULSE+'1', D(), PULSE+ 'g')); //Shiftpress: Power to Systems, Default: Wingman 1 Target

let me summarize:
MapKey(&Joystick, TG2, EXEC(

"if(!Modifier1) Actkey(KEYON+DOWN+Secondary Fire)
"if(Modifer1) Actkey(KEYON+DOWN+Scanner))
this is for maping the keystroke for TG2 on press for the default and shifted state

MapKeyR(&Joystick, TG2, EXEC(
DeferCall(TimerDelay, &ActKey, KEYON+UP+Secondary Fire)
DeferCall(TimerDelay, &ActKey, KEYON+UP+Scanner))
here you add a delay to the release of TG2 for the default an and shifted state, is that about right?

sorry, my programming skills are more or less not existing ;)
 
Hello again.

You seem to have become many people's default go-to for anything related to the Warthog script or the Target GUI.
If there's a better place for me to post or ask, please let me know as I'd hate to be bugging you unnecessarily.

My keybinds are all set as per HCS Voicepacks to ensure maximum compatibility and I've programmed the buttons and switches for my Warthog via the Target GUI to suit me.
Everything works but there's been a couple of weird happenings, most of which I've got a work around and one which bugs me and I don't know what's happening.

First the workarounds...
Occasionally when I press the button for "Request Dock" it fires the "Boost" ... this is being caused as I use TAB for boost as well as going to the next panel.
My macro was 1,tab,tab,spc,down,spc,tab,tab,tab,1 and it seemed it would switch to the left panel, tab once, boost then exit without requesting to dock...not fun when you're in an Anaconda and less than 1k from the letterbox!
I found that "e" and "q" are bound to move forward and back between panels so, I switched the "tab" keys to "e" and "q"s in my macro and was also able to reduce the sequence by one keystroke.
Request docking now works even faster...it's like a split second between when I hit the button the req has been sent.

I have an issue similar to the above with another macro I created...this one clears the chatter in the comms panel by sending 2,enter,/,c,l,e,a,r,enter,2, however every now and then, it gets to the "/" and opens the Galaxy map instead.
I know that "/" is the default key to open the Galaxy map, but why does this only occasionally open the map (or boost when I used TAB in previous example above) when in the middle of a macro?
My workaround for this is currently not to use this macro!

Note: most of the time the macros worked flawlessly, but every now and then, they displayed the odd behavior described.

My timings for the keys (ie pulse) are all set to whatever the default was.

Do you know what's happening here, is the pulse simply too short?

My other issue is/was headlook. The default keybind for this is Mouse3.
I've mapped a button the throttle to send this.
When in game, the first time I press the button, nothing happens, the second time, Headlook is toggled.
Everytime thereafter in the session the headlook button works fine.
I now use "o" as the secondary keybind for headlook and this works first time, everytime.

Any ideas around why the Mouse3 button needs 2 hits to start working?

Last of all, I use LED3 to light up when I have the gear down.
By default the LEDS (1-5) are off by default.
q1) is there a way to initialise the LEDs using the GUI?
q2) As I'm not always docked when I start the game, is there a way to determine if the gear is lowered when you start the game?

Cheers
Clicker
 
Last edited:
Hey Certhas,

MapKeyIO is one way to do it, & perhaps the more efficient way to do it, but personally I find it hard to follow the code using it, so I just use a separate key as a Modifier (this remains unmapped to any specific command if pressed in isolation). In my setup, I primarily use the Pinky Trigger. Hold this and press something else will give another layer of commands. An example:

"if(!Joystick[S4]) ActKey(KEYON+PULSE+WingmanTarget);"
"if(Joystick[S4]) ActKey(KEYON+PULSE+FighterDock);"


Joystick S4 (Pinky Trigger) remains unmapped as I said:

// MapKey(&Joystick, S4, 0);

I think the solution will come down to how you want to use it. What is natural to you. If you already have other MapKeyIO in use then that may be the more logical solution to fit into your config, else a simple setup like above may suit too. As with most of this scripting stuff, there are many ways to accomplish the same thing.

You are correct in your reading of the TimerDelay. When you release the trigger, it will start a countdown to release the button without you having to keep it held. This would be a value such as 6000 (6secs). Using the DOWN/UP instead of a PULSE.


===============

Hey Clicker,

I'm happy to field questions from other script users to help them. I still remember the difficulty I had finding answers to things or someone to talk to, to help me learn. There were some existing scripts I used and reread the manual so many times, but it makes things hard & relies on a lot of trial and error. I don't know of anywhere else to get such answers, but I do recall a few bits of code I found on a Flight Sim website (can remember the name now) that did help, but nothing really specific to ED so often required some translation. There are a few other people I would consider experts in scripts that pop by this thread from time to time too to offer assistance too.

Besides, everyone to date has been so respectful, polite, patient & appreciative (even on Steam!) that it encourages me more to help others enjoy this great game & their Warthogs (if I can). :)

I have seen things like your Autodock experience, and seems like you found the right solution already. The only thing that may be needed to overcome such things is using the LOCK command, but I assume in this case that might not help as it would still allow firing the boost when a panel is open (just the way the game is designed) so remapping would be the only way.

The clear chat command sounds like it may be a timing issue. If the panel doesn't open in due time, before the slash is entered then it would logically go to the Galaxy Map rather than inputting to the chat box. Perhaps try playing with the timing, increasing it till its reliable. This is the version I use, which seems fairly reliable:

mTextCLEARChatBox = CHAIN(UIBack, D(), PULSE+CommsPanel, D(250), PULSE+QuickCommsPanel, D(), PULSE+'\/', D(), PULSE+'c', D(15), PULSE+'l', D(15), PULSE+'e',D(15), PULSE+'a', D(15), PULSE+'r', D(15), PULSE+QuickCommsPanel, D(), UIEscape, D(250), UIEscape);

Now the headlook issue. Boy I have spent a lot of time on this one! I have the same issue with my PIP macro commands. It will simply not fire first time, so requires two presses. I am in the habit of cycling the PIPs, pressing all the keys once before I launch, but its a workaround not a solution. I have only had it with complex commands though and not straight key presses, but to be fair I don't map anything to the mouse. My opinion on this is that it is a limitation of the scripting software. Standard keys (a,b,c,1,2,3) seem fine, but any special keys (for me its the arrow keys, for you the mouse) seem to require a second pass before working. This has been a personal bug-bear for a long time for me, but you are the first to mention something similar.

Regarding the LEDs, I am not sure if that sort of programming is possible via the GUI, sorry, certainly is via a script as I do this myself for several of them. Remembering the location of the toggle (or the state of the landing gears) between sessions I don't think is possible. I have overcome this with an override for my toggles, so if I happen to be landed, and my toggle is off, I can hold my Pinky Modifier to override the position (basically if I hold the Pinky it will not trigger the landing gear). Cargo scoop can also get out of alignment between SRV and Ship so comes in handy during sessions at times too. Again, not sure if GUI can do this sort of thing.


Cheers,
AD
 
Thanks AD.

So, work arounds it is.

Next question, is it possible to call external scripts and have them return a result which can be acted upon within the Target script?

Clicker
 
Thanks AD.

So, work arounds it is.

Next question, is it possible to call external scripts and have them return a result which can be acted upon within the Target script?

Clicker

No worries Clicker.

Being that TARGET script or GUI can only run one instance at a time, I think it wouldn't be possible to run a second external script to call on. Think it would need to be integrated into the main one. You can call to run an external software app though, so perhaps something like AutoHotKey may be an alternative, but I dont think that would feed back into the script in any way.

What are you trying to achieve with calling an external script if you don't mind me asking?

Cheers,
AD
 
I believe I can read the journal after ED starts and determine if I'm docked and therefore have my landing gear down.
If I can call this external powershell (or other) script from within Target and have it return a code, for simplicity sake say a boolean for landing gear, I'm then looking to initialise the LED.

Im using this simple example as a learning tool, for something bigger I have in mind.

However, nothing Ive read in the target manual (from memory) seems to indicate this is possible, so maybe, thisll be a pipe dream.

Cheers
Clicker
 
Last edited:
MapKey(&Joystick, TG1, EXEC(
"if(!Modifier1) Actkey(KEYON+PULSE+Primary Fire)
"if(Modifer1) Actkey(KEYON+PULSE+Scanner))

MapKey(&Joystick, TG2, EXEC(

"if(!Modifier1) Actkey(KEYON+DOWN+Secondary Fire)
"if(Modifer1) Actkey(KEYON+DOWN+Scanner))

MapKeyR(&Joystick, TG2, EXEC(
DeferCall(TimerDelay, &ActKey, KEYON+UP+Secondary Fire)
DeferCall(TimerDelay, &ActKey, KEYON+UP+Scanner))

Ok, so i looked a bit into it and tried several things but i couldnt get it to work.
I probably dont understand everything and mixed stuff but this is what i think should have worked:

MapKey(&Joystick, TG2,
EXEC(
"if(!Joystick[S3]) Actkey(KEYON+DOWN+USB[0x57])"
"if(Joystick[S3]) Actkey(KEYON+DOWN+SPC)"
));

MapKeyR(&Joystick, TG2,
EXEC(
"DeferCall(50, &ActKey, KEYON+UP+USB[0x57])"
"DeferCall(6000, &ActKey, KEYON+UP+SPC)"
));

well, it didnt, so i tried to cut it down to just scanning:
MapKey(&Joystick, TG2,
EXEC(
"Actkey(KEYON+DOWN+SPC)"
));

MapKeyR(&Joystick, TG2,
EXEC(
"DeferCall(6000, &ActKey, KEYON+UP+SPC)"
));

that also doesnt work, always get errors like this:
Compile error in Execute: ; expected, in "Actkey(KEYON+DOWN+SPC)"

Compile error in Execute: ; expected, in "DeferCall(6000, &ActKey, KEYON+UP+SPC)"
Script stopped!

i am confused ;)
 
I believe I can read the journal after ED starts and determine if I'm docked and therefore have my landing gear down.
If I can call this external powershell (or other) script from within Target and have it return a code, for simplicity sake say a boolean for landing gear, I'm then looking to initialise the LED.

Im using this simple example as a learning tool, for something bigger I have in mind.

However, nothing Ive read in the target manual (from memory) seems to indicate this is possible, so maybe, thisll be a pipe dream.

Cheers
Clicker

Ahh cool idea! If you could somehow parse the journal file, identify the entry for the docking status, perhaps then somehow find a way to rewrite/update the script file to modify the variable to an appropriate state to match prior to running. If you do find a way to do that, I would be very interested to hear how you accomplish it. :)

====

Hey certhas,

The code looks fine overall, but it is missing something required on every statement in the script file. That is a ; to end the statement.

Try something like this:

MapKey(&Joystick, TG2,
EXEC(
"if(!Joystick[S3]) Actkey(KEYON+DOWN+USB[0x57]);"
"if(Joystick[S3]) Actkey(KEYON+DOWN+SPC);"
));


Previously, you were only ending the EXEC statement with the ; . But the two IF statements did not have the ; at the end.

Hope it helps :)

AD
 
Hi Droid, sorry to hijack the thread for a T.A.R.G.E.T. question: I am creating a somewhat complex pip management script, and I declared functions that I invoke with EXEC().

Everything that I call inside such function works, except for methods that would trigger an input: ActKey, Chain, you name it: they get stepper over (I put a bunch of printf and the variables work as expected) but no output whatsoever is generated.
Is there a restriction I am not aware of?

Example: I replaced the perfectly working

MapKey(&Joystick, H4U, vUIUp);

with

MapKey(&Joystick, H4U, EXEC("vUIUpFun();"));

where the function is defined as


int vUIUpFun() {
ActKey(PULSE + vUIUp);
printf("DUH?!?!?!\x0a");
}

This causes "DUH?!?!?!" to be printed when I press the key, but no event concerning vUIUp is generated. Do you know what's going on?

EDIT: Never mind, I sorted it - apparently, I have to use

ActKey(PULSE + KEYON + vUIUp);

inside a function. Which is an issue, because it prevents me from inputting multiple keypresses of the same type, apparently, as CHAIN() doesn't seem to work either. Still working on it...
 
Last edited:
Hey Herbrand,

I took a look back at some of my older code to see if there is a way to do what you want to do.

I think I have got around this by creating a macro with a CHAIN command, then using that in the function, but it sounds like that may be what you are trying already?

An example from my script for some comparison.

First the macro:

mPowerEngSys = CHAIN(
PULSE+BalancePower, D(),
PULSE+PowerEng, D(),
PULSE+PowerSys, D(),
PULSE+PowerEng, D(),
PULSE+PowerEng);

With that mapped, you could then use a line like this to call it in the function (int):

ActKey(KEYON+PULSE+mPowerEngSys);

Your key mapping would be something like this:

MapKey(&Joystick, H3U, EXEC("initAdvancedPIPManagement();"));

Looks like you are on the right track.. hope it helps.

Cheers,
AD

Edit: see previous version of my script around 2.3.0 (before I changed to the newer version) for some further reference. :)
 
Last edited:
I'll try that.

As a software developer, I understand that the way CHAIN() is described points towards a multi-threaded implementation - unless you want your entire script to pause until the Chain ends - and as such it cannot be that easily manipulated.

But not wanting to spend precious tenths of seconds switching pips during combat, I _must_ find a reasonably fast way to achieve this. I want to be able to get max pips to engines, strafe-boost, then switch back to max pips to sys in case that's still not enough to dodge that plasma volley.
 
I've done it! I have put the script on github and will create a thread one of those days:

https://github.com/EmanueleCiriachi/SmartPipsManagement

Basically, I am implementing this:

PowerManagementDiagram.jpg


And in order to achieve this, every bind is linked to a CHAIN of two different macros, like so:

MapKey(&Peripheral, SysKey, CHAIN(cVB402, B222toB402));


Where "cVB402" and similars are defined like this:


cVB402 = EXEC(
"changeVariableB402();"
);


and "changeVariableB402" and similars take care of re-assigning each key to the new set of macros:


int changeVariableB402() {
MapKey(&Peripheral, ThrKey, CHAIN(cVB420, B402toB420));
MapKey(&Peripheral, SysKey, doNothing);
MapKey(&Peripheral, WepKey, CHAIN(cVB204, B402toB204));


printf("Current State: B402\x0a");
}


finally, "B222toB402" and similar is where the CHAIN actually happens:


B222toB402 = CHAIN(PULSE + vPowerToWeapons, D(), PULSE + vPowerToWeapons, D(), PULSE + vPowerToSystems, D(), PULSE + vPowerToSystems, D(), PULSE + vPowerToSystems, D(), PULSE + vPowerToSystems);


So, at every keypress a CHAIN is executed and all keys are re-bound to the right sequence of commands. Perfect!
 
Hey AD. Thanks for your previous help. Things are taking shape. I do still have a couple of problems.

1/. As you recall, I use Warthog Hotas and Thrustmaster pedals. In settings file, UsePedals var is set to 1.
However, as I understand it, I need to set some keybindings in the Aussiedroid Warthog Enhanced 2.4.3.2.0.binds file, using the Options/Controls menu. I want the stick x-axis to be 'roll' and the pedals (combined as z-axis) to be 'yaw' as per standard flight controls. I set these in the Controls/Flight Rotation Menu.
However, when I quit and re-enter the game, those bindings are gone, the stick x-axis is bound to yaw, and the pedal z-axis is blank.
Can I hard code these into the tmh file to prevent this problem? If so, how can I do this?

2. The pinkie lever plus the left throttle red button access the 'escape vector' option, i.e. select previous system and engage fsd. This does not appear to work for me. is there anything else that needs to be set. eg pilot log file location?

Many thanks

Paul - Hobson's Choice
 
Hey Paul,

Shouldn't be any tricks to saving new bindings in ED (should be separate from any of the script stuff). Select, then Apply/Save at the bottom of the page. Is the binds file being updated (can you see the modify date being updated or contents changing)? I would try updating it outside of a session, save it and exit. Restart and see if it forces a save. Only time I have seen commands clear themselves after a save is when the controller isn't found on starting the game. If that profile bindings is then loaded it will clear any commands found on the active controllers. Not sure if that is applicable in your case but thought I would mention.

What happens when you try the Escape Vector command? Are any specific combinations not working, such as when you have cargo scoop out or weapons deployed etc? You can try to reset the flag for the escape action by holding down the red throttle button only for a long press, then try again. Do you have deploy on weapon fire enabled (if so that can mess it all up too)?

Cheers,
AD
 
Hey Paul,

Shouldn't be any tricks to saving new bindings in ED (should be separate from any of the script stuff). Select, then Apply/Save at the bottom of the page. Is the binds file being updated (can you see the modify date being updated or contents changing)? I would try updating it outside of a session, save it and exit. Restart and see if it forces a save. Only time I have seen commands clear themselves after a save is when the controller isn't found on starting the game. If that profile bindings is then loaded it will clear any commands found on the active controllers. Not sure if that is applicable in your case but thought I would mention.

What happens when you try the Escape Vector command? Are any specific combinations not working, such as when you have cargo scoop out or weapons deployed etc? You can try to reset the flag for the escape action by holding down the red throttle button only for a long press, then try again. Do you have deploy on weapon fire enabled (if so that can mess it all up too)?

Cheers,
AD

Thanks for the pointers. I have often edited bindings files outside of ED. so checked out, with notes, all seemed ok to begin with. datestamp suggestions worked. then i looked in bindings folder and removed all except the original, edited that outside of ED, checked in game and all seems to be ok. changed a value in ED, applied the change. checked in folder and datestamp was correct. went back in ED, corrected and applied my change. All the flight controls seem to be working as they should. Think I cracked it :) . Thanks.
I am compiling and running the script in Target Editor. Which works fine.
Regarding the Escape problem. I have made no progress. I do not have deploy on fire option, I use red left throttle button to deploy. That works fine! I do not have anyything open or deployed, that would normally prevent FSD.
When I press pinky lever and press and hold red throttle button, nothing happens at all.
If I press mod button 2 (grey hat) game does not go to main menu.
I will look into it again later.

Thanks for your help :)

Cheers
Hobson's Choice
 
Ah maybe it needed to be saved in game not out of game :) Strange behavior, but glad its sorted!

If both modifiers (or even when modifiers 1+2 are held) then its probably not what I was thinking it might be (ie issue in the code). Wonder if it may relate to the bindings issue you had? Most of the functionality is in the script for that button, but not sure off the top of my head if anything is also bound in the bindings file. Hardpoints/CQC Scoreboard might be? If so, might be worth doing the same saving in game etc and rebind the again, and force another save. Any results coming back when you try the combos out of the game in the event viewer?

AD
 
Ah maybe it needed to be saved in game not out of game :) Strange behavior, but glad its sorted!

If both modifiers (or even when modifiers 1+2 are held) then its probably not what I was thinking it might be (ie issue in the code). Wonder if it may relate to the bindings issue you had? Most of the functionality is in the script for that button, but not sure off the top of my head if anything is also bound in the bindings file. Hardpoints/CQC Scoreboard might be? If so, might be worth doing the same saving in game etc and rebind the again, and force another save. Any results coming back when you try the combos out of the game in the event viewer?

AD
'Stuff' is weird sometimes, right!
Ok. I have got bindings working properly. turns out there were several warthog bindings files, deleted all but original, made changes and all is ok.
Regarding the escape route - my bad - I was holding down the left throttle red button for too long, not just a quick press. So when I realised that, I tested the output, which deploys then retracts hardpoints, changes system pips, followed by a jump to fsd. I may have miseread uour release notes. I assume that I need to have previously targetted another system for the escape route to jump to hyperspace; if no system selected, the escape route will jump to supercruise only.
 
Thanks for getting back to me and letting me know all is good now :)

Weird about sums it up I think :p .. or perhaps about the best we can do given the limited feedback that some of these issues provide to trouble shoot. Why other binding files would interfere (or whatever the cause may have been) may remain a mystery... ah .. maybe this is one of those mysterious updates Frontier talk about in the patch notes LOL!

I'll take a look back at how I explain the Escape Vector macro in my guide and see if I can improve on it to better explain how it works.

What it will action will depend on the current states of your toggles, and if you have prepped an escape path. You also have a couple of optional tasks you can include such as boosting on escape or fire off a chaff which can be configured user prefs. The script manages this function via some flag values, and will only trigger if valid (1). You can test different combinations outside of a station etc to see how it will work.

It will override your toggles when used, so if you have cargo scoop deployed when you hit the Escape Vector then it will close cargo scoop but your toggle position will be misaligned. You will need to manually toggle to get back once you are safe, and if needed can use the override by holding down Modifier and the toggle (if you swap from SRV with Cargo Scoop open to Ship for example). There is an override for all the toggles now, plus one to swap the flag value for hardpoints (this is a long hold on the hardpoints with modifier held).

As long as you do not have hardpoints deploying on fire then the flags should stay aligned for the function to work.

Fly Safe CMDR!
AD
 
Launching ED from script

You guys seem to be profs concerning TARGET scripting

According to the manual the line to launch software from the script should look something like this:
Code:
system("spawn -w "G:\\steam\\steamapps\\common\\Elite Dangerous\" \"G:\\steam\\steamapps\\common\\Elite Dangerous\\EDLaunch.exe\"");

However this throws several errors with the Elite-Launcher.

The first path should be the "main game folder" and the second the "shortcut to the exe-file".
I'm not really sure what the 'main game folder' is supposed to be in this case.

Maybe somebody has already solved this problem ;)

PS: Here are the errors that I get:
1.png


1.png


1.png


1.png


1.png


EDIT2: There seems to be a problem with the links to the pictures now...
 
Last edited:
Back
Top Bottom