fumanshoo Posted January 6, 2013 Share Posted January 6, 2013 So, I haven't been able to work on this too long or too hard, but I want my mouse to stop rotating around my controller ( or pivot in this case ) and start moving freely around the screen when I press "K" and stop moving and then start rotating around my controller ( or pivot in this case ) when I press "K" again. So basically a menu. Here's my code. Please don't judge if it's completely off... --mouse if KeyHit (KEY_K)==1 then if mouse== 1 then mouse = 0 ShowMouse(mouse) MoveMouse(GraphicsWidth(),GraphicsHeight()) mx=Curve(MouseX()- GraphicsWidth(),3.0/AppSpeed()) my=Curve(MouseY()- GraphicsHeight(),3.0/AppSpeed()) else mouse = 1 HideMouse(mouse) MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2) mx=Curve(MouseX()- GraphicsWidth()/2,3.0/AppSpeed()) my=Curve(MouseY()- GraphicsHeight()/2,3.0/AppSpeed()) end end So far, it shows and hides the mouse, but other than that, nothing happens... Quote Link to comment Share on other sites More sharing options...
dennis Posted January 6, 2013 Share Posted January 6, 2013 mouse = 0 While AppTerminate == 0 do if KeyHit(KEY_K) == 1 then mouse = 1 function FlipHook() MoveMouse(GraphicsWidth(),GraphicsHeight()) mx=Curve(MouseX()- GraphicsWidth(),3.0/AppSpeed()) my=Curve(MouseY()- GraphicsHeight(),3.0/AppSpeed()) end end Not sure what you exactly want to achieve... with the K key, but I use an GUI button to close it again. but this will hold it on screen. because the mouse = 0 which was declared before main loop. it's not perfect but an start and will definitely work Quote Link to comment Share on other sites More sharing options...
ChrisMAN Posted January 6, 2013 Share Posted January 6, 2013 mouse is being declared outside the 'lexical scope' but because it is not declared with the local keyword it is being put in global scope which lets it work. In general global variables should be looked down upon. However after you find out why they are bad you will go through a dogmatic period of time where principles are the law of the land. Then after mastery is acquired you go back to breaking all of the rules whenever you feel like. So I guess I don't know what to say... ShowMouse and HideMouse do not require a parameter. I would leave the mx, my variable as they were and not set them in the gui loop. Also you do not need to use MoveMouse in the gui loop since you are moving that on your own. The MoveMouse command is often used to set the mouse back to the middle of the screen programatically when you have moved it manually. Due to the way the Curve function works it lags behind. I hope this helps. Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted January 6, 2013 Author Share Posted January 6, 2013 @ Dennis, I forgot to add that I have my mouse = 0 before the main loop, and I am using "K" because I have run out of keys and I am not smart enough to do something like press escape and then use GUI because I am already using escape to end the program... Anyways, when I use your script, my mouse goes to the right corner and then freaks out and I can't go back to normal... I think that has to do with the function FlipHook because that didn't really do anything like change colors or anything like that... Quote Link to comment Share on other sites More sharing options...
dennis Posted January 6, 2013 Share Posted January 6, 2013 @fumanshoo. I will give you the code I'm using for that So you can't run out of keys 1 Quote Link to comment Share on other sites More sharing options...
fumanshoo Posted January 6, 2013 Author Share Posted January 6, 2013 Thank you so much. I tried once, but I couldn't get anywhere because under scripts/constants/keycodes, it says MOUSE_LEFT to obviously click on things, but for what ever reason, it was not working for me... Quote Link to comment Share on other sites More sharing options...
dennis Posted January 7, 2013 Share Posted January 7, 2013 No problem at all. But you will receive it at this friday due my field operations which I'm taking part at. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.