|
0 registered members (),
1,397
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
points to open a door
#403670
06/24/12 00:05
06/24/12 00:05
|
Joined: Nov 2006
Posts: 497 Ohio
xbox
OP
Senior Member
|
OP
Senior Member
Joined: Nov 2006
Posts: 497
Ohio
|
I have a snippet of code I wrote to require the player to have 2000 points in order to open a door. It works fine if the player walks upto it with 2000+ points and and works by not opening if the player has less than 2000 points. My problem is that after the player walks up to the door and fails to open it (not enough points), once I get more points, I cannot go back and open it. here is my code.
action doorU()
{
while(player==NULL) {wait(1);}
while(vec_dist(player.x , my.x) >80){wait(1);}
if(vec_dist(player.x , my.x) <= 80)
{
if(totalPoints >= 2000)
{
beep();
totalPoints -= 2000;
ent_remove(me);
}
else
return;
}
else
return;
}
|
|
|
Re: points to open a door
[Re: Walori]
#403693
06/24/12 18:06
06/24/12 18:06
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
while(1) give you a error after the ent_remove(me) Use while(me) instead.
Last edited by Widi; 06/24/12 18:06.
|
|
|
Re: points to open a door
[Re: Widi]
#403699
06/24/12 20:38
06/24/12 20:38
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
while(1) give you a error after the ent_remove(me) Use while(me) instead. No, the function is stopped automatically if the my entity gets removed. Thus while(1) is perfectly fine. Walori's code is okay but obviously misses a "wait(1);" in the second while loop.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: points to open a door
[Re: xbox]
#404132
07/03/12 02:44
07/03/12 02:44
|
Joined: Dec 2009
Posts: 128 China
frankjiang
Member
|
Member
Joined: Dec 2009
Posts: 128
China
|
your question: pointer a to open door by mouse or any you want.
open door looks like a animation.your use door animation by game event. and then your put any block nearless your door. So if you want to control just push event to your game Object ,and play animation by itself.
development 3d game is interesting!
|
|
|
Re: points to open a door
[Re: frankjiang]
#404145
07/03/12 14:53
07/03/12 14:53
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
your question: pointer a to open door by mouse or any you want.
open door looks like a animation.your use door animation by game event. and then your put any block nearless your door. So if you want to control just push event to your game Object ,and play animation by itself.
??? For all who want to know, this should work
#define open skill100
action points_door()
{
while(!player) wait(1);
while(my)
{
if(player)if(vec_dist(player.x, my.x) < 80 && totalPoints>2000 && my.open == 0)
{
my.open = 1;
_open_door(); //whatever
}
if(player)if(vec_dist(player.x, my.x) > 80 && my.open == 1)
{
my.open = 0;
_close_door(); //whatever
}
wait(1);
}
}
Last edited by rayp; 07/03/12 15:10.
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
|
|
|