Cali 10 Posted October 25, 2010 Hi guys, sorry to post two times, but this subject is quite different from the other one. I'm trying to make a camera script, which is a loop : While {_loop} do... I would like this loop to be interrupted if the player presses any key, while in camera mode. Is there a simple way to do that? Does someone could give me a basic example (I'm a perfect beginner ^^) ? Share this post Link to post Share on other sites
5133p39 16 Posted October 25, 2010 You could use displayAddEventHandler to set display event handler. When user presses some key, the handler will run your script, passing it some variables like the key which was pressed, state of any modifiers (Shift/Ctrl/..) and based on which key it was (or any key) your script could set some variable to make the camera script exit the loop. Simple solution to terminate camera on any key pressed would be like this: CAMERA_ON = true; ehDispKeyDown = (findDisplay 46) displayAddEventHandler ["KeyDown", "CAMERA_ON = false;"]; while {CAMERA_ON} do { ... }; ...when user presses any key, the display event handler will set the global variable CAMERA_ON to false, and the loop will exit. I am not sure if the display number 46 is the right one, but it should be the "main display" so i think it should work. (i am not at my computer, so i had no means to test the code, but generaly this is how it should work). Share this post Link to post Share on other sites
Cali 10 Posted October 25, 2010 Cool, many thanks! One thing, how can I be sure of the right display (46)? Is there a list or a way to check it? Many thanks for the code, I will use it :) Share this post Link to post Share on other sites
jamesf1 0 Posted October 25, 2010 46 is the primary display :) Share this post Link to post Share on other sites
Cali 10 Posted October 30, 2010 Thanks James :) Another question : this method doesn't seems to work with mouse click... is there a way to interrupt the camera with left or right mouse button? Share this post Link to post Share on other sites