Forum Jump :

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#1 Posted at 2014-10-13 15:33        
     
I am working on creating a command prompt style operating system in Arma 3 and I am using the 'KeyDown' event handler to get the key presses for typing on screen. This works great until you try to localize the key presses (so its MP compatible) and when implementing shift (for Caps and symbols).

Right now I have an event handler at the top of my script. When the user types a key its code is assigned to 'pressedKey' and shift's pressed state is assigned to 'shift'. The problem here is when you are pressing shift, after a second, it ignores other keys you have pressed and just notices shift. Is there a way to get around this so that the user can press shift and another key to get caps and symbols?

Second, those two variables 'shift' and 'pressedKey' are not local variables meaning, if in multiplayer, any users using the command prompt thing simultaneously, would all have a combination of everyone's input (if I understand it correctly, I haven't done much mp scripting and can't really test it.). When I try making 'pressedKey' and 'shift' local ('_pressedKey' && '_shift') they are updated to the new values in the event handler code, but outside the event handler, they return to normal. I have tried putting the event handler inline and doing a function call like in: https://community.bistudio.com/wiki/User_Interface_Event_Handlers at the bottom under 'Script Defined Events'. When I do this, the functions never call, though any hints I put in for testing do. If I could call a function from inside the event handler, I wouldn't have to use global variables, but at the moment I am unable to do that.

Fixing these two problems would help me finish up the I/O for this. If you have any unanswered questions about this, or need code let me know.


Author Message

Tajin  



Posts: 433
Rank:


Level: Member

Country: de
Location: Bavaria
Occupation: Communications Designer
Age: 33
In-game name: Tajin

 
#2 Posted at 2014-10-13 17:04        
     
A command prompt? Why don't you simply use an input box for that ?

There are a lot of very capable people on this forum, willing to spend some of their time to help you out. So if you have a problem, it surely isn't too much to ask that you atleast take the time to describe it properly. Thanks.

Advertisement


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#3 Posted at 2014-10-13 17:41        
     
Hi jshear95,
Not sure i can help you. i wonder why you need to localize (do you mean localize function to pick a string in a stringtable.csv? or something else?
I created the same event (for an add-on), initially with some troubles to fire it. It worked when i restarted mission, probably because the script was called too late. I don't know what difference is between "first start" and "restart" loads.
I succeed to trigger this event from first start, calling a compile preprocessfilelinenumbers sqf (in an initial file)with my keys definitions. The "output" variables must be global. It seems you can't avoid this with EH.
You must also call you event with a global "handle", if needed, like MY_KEYS = (findDisplay 46) displayAddEventHandler ["keyDown", "_this call my_compiled_preprocessed_sqf_with_my_keys"];
I haven't written for MP yet but i guess global variable doesn't mean Public. Is your "shift" key assigned for something in game settings? did you try with ctrl or alt?

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#4 Posted at 2014-10-13 18:04        
     
Tajin, I did try to use dialogs but I found them really complicated and I couldn't create an editable text field, I know its possible to do with dialogs, but I am planning to figure them out once I get basic file handling and I/O done.
Right now I am using BIS_fnc_dynamicText on a black background. If you could let me know how to create a dynamic text field that the user can type in, and I can analyze and print text in on the fly with dialogs, that would be great! I looked through a lot of dialog tutorials, but couldn't find any that allowed me to do that.

Pierre thanks for the heads up on the variables having to be global. By localize I mean, just to keep in that instance of the script (using a local variable like '_shift' versus a global one like 'shift'). I have attached it to a laptop in game and its accessible with a action menu command, so theoretically in an MP environment, multiple people could be on different laptops with the script. In reference to "_this call my_compiled_preprocessed_sqf_with_my_keys", is that in a second .sqf file from the file containing the event handler, if so, is it also a stand alone function, or just a script? The stringable.csv sounds useful, however I have a fairly good text parsing method with storing user input as arrays of 1 character strings and concatenating them on the fly for displaying to the user.
The shift key shouldn't be reserved for anything special other than its key code and the modifier in KeyDown. I am using enableSimulation false on the script caller to limit player movements. Its not perfect but that's a whole other problem. I have shift bound to sprint which when simulation is disabled on the player does nothing.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#5 Posted at 2014-10-26 23:21        
     
Sorry i didn't see your last.
Yes, you have to pay attention with loading sequences : see https://community.bistudio.com/wiki/Functions_Library_%28Arma_3%29#Initialization_Order
I used an sqf for my keys, compiled preprocessed in an init file.
Perhaps you could check this add-on MGI_TG_V2 if you have a pbo reader. open HUD_look.sqf.

If think this add-on could work easily for each players in MP mission. Not tested here.

However, I have a remaining problem / Every sounds great but if i save and reload a mission, i recover my in-game config (i.e. add-on menu options) but no more possibility to act HUD color or intensity with my keys. I have to reset (remove) glasses to reactivate the keys. I don't know why.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#6 Posted at 2014-10-28 23:01        
     
I got the shift to work by using KeyUp rather than KeyDown. The built in detection for shift will do the toggle and the key press is registered when the user lifts the key. It prevents holding a key for a string of characters (i.e. aaaaaaaaaaa) but at least shift works. I haven't solved the global variable issue yet but since I am testing it only in SP right now, its inconsequential for now.

Thanks for the help Pierre!


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#7 Posted at 2014-10-29 03:33        
     
Oh, very little help. What appends if you just save, and reload mission? Key remains active? I haven't solved this problem.
I don't understand the difference between starting a mission and reloading a saved game.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS