Page 1 of 1

KeyDown in Global Script Editor

PostPosted: Thu Dec 29, 2011 8:05 pm
by QbiWan
Hi, i have made few events for VIEW moving with keys and mouse+screen edge. All is fine but i saw that some events can by found when clicking on SCRIPT button on top screen, and some CANT be found. its just ViewMoving, so i afraid that one day i just wont find some events in created mess.
So to the MAIN TOPIC: can i write all events available in ADD menu in the global script (f.e. KeyDown cant be found in script editor's variables/functions menu)?? If yes, how should it look like??
ScreenShot001.jpg

KeyDown>Down> y = y + 10

Re: KeyDown in Global Script Editor

PostPosted: Thu Dec 29, 2011 8:08 pm
by skydereign
You mean is there a way to determine what key(s) are pressed in script? You can use the function GetKeyState to see if keys are pressed in script.
Code: Select all
char* key = GetKeyState();
if(key[KEY_RIGHT]==1)
{
    x+=10;
}

You can find all the keys here. http://game-editor.com/docs/script_reference.htm

If you want to use just the last key, and have a keydown any key event, you can use getLastKey() function.

Re: KeyDown in Global Script Editor

PostPosted: Fri Dec 30, 2011 11:03 pm
by QbiWan
But can i do it ALL in Global code? To assign actor with moving action when key is pressed, becouse i want to call it a name to have f.e. all move scripts in one place.

Re: KeyDown in Global Script Editor

PostPosted: Fri Dec 30, 2011 11:12 pm
by phyzix5761
Yes, you can have it all in global code.

Make it a function

Code: Select all
void functionName()
{
   //your code here
}

and then in the draw actor event put the function. If you ever need to edit the code just go into global code and edit the function.