Jump to content
squeaker

Binding keys to menu actions

Recommended Posts

Is it possible to bind a key (or, in my case, a joystick button) to a specific menu option?

What I'm after is binding a key on my Rhino X-55 that will open and close the ramp on the CH-67 Huron.

I have searched the forums, and all the in-game options, I can't seem to find it.

TIA for any assistance.

Share this post


Link to post
Share on other sites

I don't think it's possible to bind context sensitive actions to a key without scripting. I bind one of the hat switches on my warthog throttle to next/previous action and another button to action.

Would be awesome if you could record command macros though!

Share this post


Link to post
Share on other sites
I don't think it's possible to bind context sensitive actions to a key without scripting. I bind one of the hat switches on my warthog throttle to next/previous action and another button to action.

Would be awesome if you could record command macros though!

Forteh is correct, but scripting it wouldn't be too hard, just use a displayEventHandler.

Edited by JShock

Share this post


Link to post
Share on other sites
Forteh is correct, but scripting it wouldn't be too hard, just use a displayEventHandler.

WOOOOOSHHHHHH!!!!! (that was the sound of something going over my head so fast, you can hardly see the blur!)

Thanks for the answers chaps, but I'll stick with binding the menu control commands as forteh suggests.

Share this post


Link to post
Share on other sites

Likewise! The last time I did any game scripting was configs in counterstrike 15 years ago :D

Are the scripts something that can be bound to as per a normal control and run on a keystroke like a macro? If so is there a quick and dirty beginners guide?

Share this post


Link to post
Share on other sites
Likewise! The last time I did any game scripting was configs in counterstrike 15 years ago :D

Are the scripts something that can be bound to as per a normal control and run on a keystroke like a macro? If so is there a quick and dirty beginners guide?

http://forums.bistudio.com/showthread.php?130863-Run-script-when-button-is-pressed

The execVMed script would contain the code needed to make the ramp go up and down:

http://forums.bistudio.com/showthread.php?185658-New-DLC-Helicopter-Ramp

Share this post


Link to post
Share on other sites

Thanks JShock, this is starting to look a little less daunting.

Helo animateDoor ["Door_rear_source", 0];

Where 'Helo' is the name of your vehicle

Is there a wildcard to use instead of the helo name to mean 'current helo'?

Share this post


Link to post
Share on other sites
Is there a wildcard to use instead of the helo name to mean 'current helo'?

Yes, since key presses are local to each client, that means you should be able to use:

(vehicle player) animateDoor ["Door_rear_source", 0];

Share this post


Link to post
Share on other sites

Thanks JShock, this is looking good.

So now I have the commands I need, I just need to know how to map them to a keypress or joystick switch. As I'm sure this is already available somewhere, but as you seem to have an uncanny knack for this black art, can you point me in the direction of a good noob's guide? And I mean total noob, I have never done scripting in games before.

---------- Post added at 10:31 ---------- Previous post was at 10:19 ----------

Ah, cancel my last, I found it from a link you posted a little further up the thread, thanks JShock

Share this post


Link to post
Share on other sites

I think that's what you need to use the event handler for?

I personally would like to be able to pan the map around using the trackstick on my warthog but to be honest I haven't got a clue how :(

You can pan the map using the numpad keys, however if I bind the trackstick to the same commands it doesn't work, need to take hands off stick to view the map properly.

Share this post


Link to post
Share on other sites

Dammit, cancel my cancellation, I just can't understand it. back to my request, a complete noobs guide?

Share this post


Link to post
Share on other sites

I just read the first 30 odd pages of focks guide to scripting and I'm 100% lost :(

I was the same at uni trying to learn C, I had no idea what I was doing or how to do it, I guess this is why I'm a mechanical engineer not a coder :D

If it were as simple as creating a text file script that executes on a certain keypress (trackstick up = excute map pan up) then it would all be so easy!

Share this post


Link to post
Share on other sites
If it were as simple as creating a text file script that executes on a certain keypress (trackstick up = excute map pan up) then it would all be so easy!

That's what I was hoping for too!

Share this post


Link to post
Share on other sites

As far as the trackstick usage, I'm not too sure how to make that work myself, seeing how I've never owned a joystick/gamepad of any sort, but as far as using the eventhandler and such, here is a code snippet that may help, it's used to disable the "map" key and to prevent reload with a full magazine.

http://forums.bistudio.com/showthread.php?184463-CODE-SNIPPET-Using-actionKeys-amp-amp-prevent-players-from-reloading-if-magazine-is-full

Below would be an example of using custom user action key #9 and #10 to open/close the rear ramp:

_animateDoors = (findDisplay 46) displayAddEventHandler ["KeyDown",
{

   _handled = false;

   if ((_this select 1) in (actionKeys "User9")) then
   {
          (vehicle player) animateDoor ["Door_rear_source", 0];
          _handled = true;
   };
   if ((_this select 1) in (actionKeys "User10")) then
   {
          (vehicle player) animateDoor ["Door_rear_source", 1];
          _handled = true;
   };

};

Share this post


Link to post
Share on other sites

So (and please excuse my complete lack of knowledge here) do I just copy and paste that script into a file (named rampcontrol.php for example), which I put in a specific directory which is then loaded when the game runs, so any time I press the appropriately mapped key to user action key 9 and 10, the ramp opens and closes?

Share this post


Link to post
Share on other sites
So (and please excuse my complete lack of knowledge here) do I just copy and paste that script into a file (named rampcontrol.php for example), which I put in a specific directory which is then loaded when the game runs, so any time I press the appropriately mapped key to user action key 9 and 10, the ramp opens and closes?

You should be able to just make a file named: init.sqf, and place the code in there, and place that file in your mission root directory.

FYI, the "PHP" is just tags we put around the code to make it easier to read (color differentials) here on the forums.

Share this post


Link to post
Share on other sites

With the code written into init.sqf will that be persistently available ( i.e. in sp campaign, mp missions, messing about in editor etc.) as a bindable script?

When you say place the script into the mission root directory does that mean that this particular script will only be available in custom missions that you write it into?

Apologies for the stupid questions, stuff like this really isn't my strong point :)

Share this post


Link to post
Share on other sites

Init.sqf is run for every player that joins the mission, so yes it should apply to every player that joins, persistence is not the proper terminology here. But there is a little change that you would need to make for MP dedicated servers:

if (hasInterface && !isDedicated) then {

_animateDoors = (findDisplay 46) displayAddEventHandler ["KeyDown", 
{ 

   _handled = false; 

   if ((_this select 1) in (actionKeys "User9")) then 
   { 
          (vehicle player) animateDoor ["Door_rear_source", 0]; 
          _handled = true; 
   }; 
   if ((_this select 1) in (actionKeys "User10")) then 
   { 
          (vehicle player) animateDoor ["Door_rear_source", 1]; 
          _handled = true; 
   }; 

 };  

};

What I mean by mission root directory is basically yes, the custom missions you make that are in your missions/MPmissions folder in your Arma 3 - Other Profiles, documents folder:

C:\Users\Survivor\Documents\Arma 3 - Other Profiles\JShock

So depending on whether you saved your mission as a SP or an MP, you would go into the respective missions/MPmissions folder, find the mission folder, open it and place the init.sqf into that folder, with this code contained within that file.

If your wanting it without placing it in the init.sqf, it would have to be an addon, which I'm not too far into that world of Arma, yet.

Share this post


Link to post
Share on other sites

Ah so this wouldn't work as a method of binding controls/macros outside of the normal control configuration. It doesn't work like the old autoexec.cfg file for counterstrike for example.

Share this post


Link to post
Share on other sites
Ah so this wouldn't work as a method of binding controls/macros outside of the normal control configuration. It doesn't work like the old autoexec.cfg file for counterstrike for example.

I don't have any clue about counterstrike, but what I have should allow you to define your own keys for the up/down of the ramp, but no, this isn't a way to have it "always" binded to those actions. Like I said, it would need to be an addon, or there may be another way, but I am unaware of any other way.

Share this post


Link to post
Share on other sites

Ok, I think I understand what's needed here but I must be doing something wrong.

I've saved the script in a file called init.sqf, and put that in the mission dir (specifically in C:\Users\Tim\Documents\Arma 3 - Other Profiles\Squeaks\Saved\steam\Pilot%20CH-67%20Huron%20On%20Missions.Altis ) but no joy. (I did remember to bind user9 and user10 custom commands to the required 2 joystick inputs, one for open and one for close).

Does it make a difference that it's one I've downloaded through the steam workshop and not something I have created myself?

Share this post


Link to post
Share on other sites
Ok, I think I understand what's needed here but I must be doing something wrong.

I've saved the script in a file called init.sqf, and put that in the mission dir (specifically in C:\Users\Tim\Documents\Arma 3 - Other Profiles\Squeaks\Saved\steam\Pilot%20CH-67%20Huron%20On%20Missions.Altis ) but no joy. (I did remember to bind user9 and user10 custom commands to the required 2 joystick inputs, one for open and one for close).

Does it make a difference that it's one I've downloaded through the steam workshop and not something I have created myself?

Could you zip up a folder of that mission and send it this direction? And did you overwrite a file named init.sqf already in that mission folder?

EDIT: Actually with steam missions, it auto updates them, so you adding a new file could cause it to "update" itself because the files are different, so it deletes the new file that you just added.

Edited by JShock

Share this post


Link to post
Share on other sites

You've got PM with a link to the dropbox file

No, there wasn't already a file in there with that name, and I have started and quit Arma 3 a couple of times (running the scenario is question) and the file has remained in place.

Share this post


Link to post
Share on other sites

Ok, well, I can tell I don't do much Steam Workshop downloading, the issue was that Steam saves the pbo file, not a physical mission file (unless you extract it out via the pbo, which I have done), so the below link is a version with the necessary changes needed, just unzip and overwrite the necessary files in the same folder:

https://www.dropbox.com/s/xglhzld9n50ybho/PilotCH-67Huron.zip?dl=0

Share this post


Link to post
Share on other sites

Thank you for trying to sort this, but I think something might be broken. I loaded up the scenario, and the small script that runs to allow you to specify weather, time of day, etc, wasn't there. the other minor thing that was missing was the helicopter! Only a minor issue. :) Tried re-starting a couple of times, but still no Huron. I restored the original file, and it was fine.

Perhaps I'm looking at this the wrong way, because if the mission itself needs to be tweaked, it'll be overwritten next time the author makes an update and steam rolls it out. Is there a way to make a mod that will work with the main game, and therefore would be available in all missions, scenarios, etc?

I know that's a much bigger thing than a little script, but it appears that even a simple script is causing problems. I don't suppose there's a way to add the script to the main program that runs whenever the program does, and would therefore also be universal?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×