Posted By: Doriel
detect when player is in a specific room? - 08/09/07 13:48
Hello Everyone,
I need to display a panel (and possibly execute some other functions) ONLY when the user is in a specific room. How do I detect that the user is in the boundaries of the room? And when the user leaves the room, how can I detect that?
Any ideas / advice is much appreciated!
Regards,
Doriel
Posted By: demiGod
Re: detect when player is in a specific room? - 08/09/07 14:49
Several ways.
One could be triggers, put a dummy object in the entrance / door of the room and assign an action / function to trigger the event when the player touches the objec.
Ex:
Code:
function my_event
{
if ( EVENT_TYPE == EVENT_ENTITY )&&( you == room1)
{
my._roomPos = 1;
// other functions
}
}
In player action put:
my.enable_entity = on;
my.event = my_event;
In rooms dummy action:
my.passable = on;
my.enable_entity = on;
Posted By: Doriel
Re: detect when player is in a specific room? - 08/09/07 15:47
I tried the whole passable object idea but couldn't get it working. I'll have to try it again now that I have some script to look at.
Thanks!
Posted By: vlau
Re: detect when player is in a specific room? - 08/09/07 18:31
You need to c_move your player in order to
trigger events.
Maybe try :
Code:
if (vec_dist(player.x,specific_room.x) < boundary)
{
// do something when player inside the room
} else {
// do somthing when player outside the room
}
Posted By: MrCode
Re: detect when player is in a specific room? - 08/09/07 22:26
maybe you could use c_content?
Posted By: Doriel
Re: detect when player is in a specific room? - 08/10/07 00:15
I have just tried getting it to work using the passable object. It seems like it would work. The only problem is, when i'm walking through the object, i think it's going into SWIM mode? It makes a splashing sound and the player crouches? Something like that. Oh, and it doesn't trigger my function. When i turn off passable for the object, it triggers my function. Weird.
Any ideas? If not, I will have to try some of the other suggestions.
Regards,
Doriel
Posted By: Keebo
Re: detect when player is in a specific room? - 08/10/07 02:47
You could make it not passable and invisible and remove it just after triggering your function.
You could also compare the player's x, y, and z coordinates to the room coordinates and trigger your function when they coincide. I used that on several occasions back in A5.