opening doors from both ends at once

Started by tekram, Mon 22/11/2004 16:10:05

Previous topic - Next topic

tekram

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

Radiant

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.

tekram

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

strazer

Take a look in the manual (help file) under Reference -> System limits.
The maximum number of GlobalInts is 500 at the moment.

Radiant

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;

Ashen

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:
Code: ags

  // 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.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk