Page 1 of 1

Select actor on key down

PostPosted: Thu May 03, 2007 11:47 pm
by nate020605
i would liek to find out how i can SELECT an ACTOR on key down "q" and then deselect the actor once a different key is pressed "a", i have six gun turrets all with the same functions and i need to have a key asigned to select them, and does anybody have a link to a good post that would describe how to rotate them, each only needs to 180 degrees does anybody know how i would go about doing that, i've read some of the other posts and had a hard time following them. thanks for your help in advance i appreciate it.

PostPosted: Fri May 04, 2007 12:05 am
by Sgt. Sparky
to make your actor rotate only 180 degrees,
use this on the rotation event after you make an actor variable called MOVE:
Code: Select all
if(MOVE == 1) {
if(direction(x, y, player.x, player.y) < 360 && direction(x, y, player.x, player.y > 180)animpos = direction(x, y, player.x, player.y);\
}

for selecting an actor,
make a variable called count,(integer)
and make a variable called i.
also make a variable(string) called NAME1 and one called NAME2.
on the key down event of q (repeat disabled),
Code: Select all
count = ActorCount("turret");
sprintf(NAME1, "turret.%d", i);
getclone(NAME)->MOVE = 1;
while(i <= count) {
sprintf(NAME2, "turret.%d", i);
if(strcmp(NAME2, NAME) == 1)getclone(NAME2)->MOVE = 0;
i++;
}
if(i > count) i = 0;

this allows you to make more than one clone of the turret instead of making a bunch of different actors(not clones) . :)
:D
I hope that helps,
if you need more help let me know. :)

PostPosted: Fri May 04, 2007 5:18 pm
by nate020605
i appreciate the help i'll try it out tonight, do you or anyone else know of any scripting specific tutorials besides the one packaged with GE, ones that perhaps go more in depth and explain more?

PostPosted: Fri May 04, 2007 10:57 pm
by Sgt. Sparky
I do not know of any... :(

but if you need help,
I and many others are willing to help. :D

PostPosted: Mon May 07, 2007 9:24 pm
by nate020605
im not sure how much work it might be but could anyone break down the script into laymans terms and basically explain what each part is doing, so i can get abetter understanding of whats happeneing and hopefully wont have to post a whole lot more times :D . still pretty confused as to why it works the way it does.
Also attached is a screenshot of my game wich will hopefully give everyone abetter understanding of what im trying to accomplish.

1."q" key down to select turret1 (pressing any other key deselects it)

2."z" key down to select turret2 (pressing any other key deselects it)

3. Mouse click left on water -> fire missle from turret1
missle parent is turret1. (mouse cursor is the direction i want the missle to go in)

4.mouse click "right" on water -> fire missle from turret2
missle parent is turret1. (mouse cursor is the direction i want the missle to go in)

sorry if it was rendundant just wanted to get my point acrros clearly. thanks for the help everyone

PostPosted: Tue May 08, 2007 12:48 am
by Sgt. Sparky
make a variable called select,
when you press q,
Code: Select all
select = 1;//setting the select variable to 1

when you press z,
Code: Select all
select = 2;//setting the select variable to 2

and on the key down event of any key,
Code: Select all
char*key=GetKeyState();
if(key[KEY_q] == 0 &&  key[KEY_z] == 0)select = 0;
//it asks if either q or z is not pressed it will set the select variable to 0,
//in which case you will not use a turret.

and when you fire turret one,
Code: Select all
if(select == 1)
{
    your actions here;
}

when you fire turret 2,
Code: Select all
if(select == 2)
{
    your actions here;
}

:D
if you still need help let me know. :)

PostPosted: Tue May 08, 2007 1:11 am
by nate020605
extremly helpful Sparky thanks for the quick replies as well, i see your name on alot of the posts. I along with everyone else apprciates your knowledge of C script. thanks again

PostPosted: Tue May 08, 2007 1:12 am
by Sgt. Sparky
you're welcome. :D