Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Mon 22/11/2004 16:10:05

Title: opening doors from both ends at once
Post by: on Mon 22/11/2004 16:10:05
I am making lots of doors in my game, and I understand how to use variables to open and close the door, but my problem is when my character opens the door and goes through it to go to the next room. I can't figure out how to have the door also open from when my character is at the opposite side of the door in the next room.

I can't tell the other room to open that door on the other side when I open the door in the first room

(hope my problem is easy to understand)

I could do it with global variables, but is it really necessisary to create a global variable for each door I create??

thanks for any help

Tekram the Carpathian
Title: Re: opening doors from both ends at once
Post by: Radiant on Mon 22/11/2004 17:47:23
In this case, you would either need global variables (since the problem is not localized to one room), or the plugin that allows you to turn objects on/off in another room.
I would go with globals.  That's what they're there for.
Title: Re: opening doors from both ends at once
Post by: on Tue 23/11/2004 20:26:20
Ok. Thanks for your help, Radiant...I can live with using global variables.

One more thing though, since I will be using global variables, do you know how many global variables I am limited to? I just don't want to end up using them all prematurely if there is a low limit.

Thanks again though!

Tekram
Title: Re: opening doors from both ends at once
Post by: strazer on Tue 23/11/2004 23:05:01
Take a look in the manual (help file) under Reference -> System limits.
The maximum number of GlobalInts is 500 at the moment.
Title: Re: opening doors from both ends at once
Post by: Radiant on Wed 24/11/2004 00:45:46
But if you're using global variables, rather than globalints, the quantity is not limited as far as I know. Plus you get to name them:

top of global script:
int my_var;

bottom of global script:
export int my_var;

inside global header:
import int my_var;
Title: Re: opening doors from both ends at once
Post by: Ashen on Wed 24/11/2004 16:40:45
Alternatively:
Since the door you've just come through will obviously be open, you could use the character[CHARID].prevroom system variable to change the door graphic - it would save you from having to create a variable for every door. For example, suppose you're in room 5, a hallway with 4 doors leading off it, back to rooms 1-4:

  // script for room: Player enters screen (before fadein)
if (character[EGo].prevroom == 1) SetObjectGraphic (DOOR1, OPENSPRITE);
// you came from room 1, so set that door to open
if (character[EGO].prevroom == 2) SetObjectGraphic (DOOR2, OPENSPRITE);
//and so on..
if (character[EGO].prevroom == 3) SetObjectGraphic (DOOR3, OPENSPRITE);
//and so on..
if (character[EGO].prevroom == 4) SetObjectGraphic (DOOR4, OPENSPRITE);
//and so on..
else {
  // otherwise, make sure the door is shut.
  SetObjectGraphic (DOOR1, CLOSEDSPRITE);
  SetObjectGraphic (DOOR2, CLOSEDSPRITE);
  SetObjectGraphic (DOOR3, CLOSEDSPRITE);
  SetObjectGraphic (DOOR4, CLOSEDSPRITE);
}

(Where DOOR1, DOOR2, DOOR3, DOOR4, OPENSPRITE and CLOSEDSPRITE are the appropriate object / sprite numbers)

This just ocured to me, and I haven't had a chance to test it properly, so it might need a bit of fine tuning to work properly, but it's a start, and I wouldn't want to take all the fun out of it for you.
You could also add some AnimateObject() commands, to make the door shut behind you.