f2k sel 164 Posted January 2, 2012 (edited) The following script reads a key press and returns 1 when pressed 0 when not which is fine but when I change the variable test to _test it won't work. Any ideas? Working script disableSerialization; sleep 1; test = 0; _display = (findDisplay 46); _display displayAddEventHandler ["KeyDown","if ((_this select 1) == 31) then {test = 1} else {test = 0}"]; while {true} do { sleep 0.1; hint format ["test %1",test]; }; I've also tried (findDisplay 46) displayAddEventHandler ["KeyDown","null=[_this select 1] execvm 'keypress.sqf'"]; (findDisplay 46) displayAddEventHandler ["KeyDown","null=[_this] execvm 'keypress.sqf'"]; but keypress.sqf is never run unless it's in a loop and then I still can't find any result. ie _this select 0; _this select 1; _this select 2; all return any. Edited January 2, 2012 by F2k Sel Share this post Link to post Share on other sites
demonized 20 Posted January 2, 2012 think you maybe could use the keyUp version together with keydown. to pass local variables to something you can use a format of the "" in the eh. _test = 0; _lv = format["if ((_this select 1) == 31) then {1} else {%1}",_test]; _display displayAddEventHandler ["KeyDown",_lv]; Share this post Link to post Share on other sites
f2k sel 164 Posted January 2, 2012 Thanks, I also completely forgot that it was an eventhandler so it should pass the info based on _this select I think. I will try later but have to work right now. Share this post Link to post Share on other sites
f2k sel 164 Posted January 2, 2012 That didn't actually work but it isn't a problem, I just let it call a script and can read the value just like any other EVH. Something had messed up and only restarting the game cleared it. Thanks though. Share this post Link to post Share on other sites