Trying to make events in one room influence another room [SOLVED]

Started by Racoon, Mon 25/11/2019 19:21:23

Previous topic - Next topic

Racoon

Hey,

I am at a dead end again. I would like the visibility of an object1 in room1 to influence the visibility of object2 in room2 with if/else. But since object1 is not in room2, it wont be recognized in the script of room2.

How can it work?

Thanks!

Slasher

You can use a variable like a boolean.

Change to false/true depending on the object visibility in room one.

In room two set object if boolean true else set if false


Crimson Wizard

To elaborate a little on what slasher said, the only way is to save other room's state in a variable (or multiple variables, depending on how much you need to change), and then assign new state to objects in that room's "Enter room before fade-in" event.

The variables have to be global, because room variables are only accessible within same room too.

For example, create a global variable of type "bool" called "Room2_MyObject_Visible".
Then in room 1 script you do
Code: ags

Room2_MyObject_Visible= true; // or false

And in room 2 you create a function for "Enter room before fade-in" in which you do
Code: ags

oMyObject.Visible = Room2_MyObject_Visible;

eri0o

The state can also be stored for later consumption on room leave event

Crimson Wizard

Quote from: eri0o on Mon 25/11/2019 19:59:50
The state can also be stored for later consumption on room leave event

Yes, right, this is actually important, if you want the variable to be consistent at all times, and in case you change object visibility in room 2 script as well.

The general logic is this:

* you have a real room's state, only loaded when room is on;
* you have a set of variables that store room's state (maybe partially, like only one object's visibility).

* in "Before fade-in" event you copy state from variables to room objects
* in "Leave room" event you copy state from room objects to variables.

this way everything stays in sync and you may get and change this information outside of the room.

Racoon

Thanks for that quick support! It worked out just fine. Special thanks to Crimson Wizard for that detailed example  :)

SMF spam blocked by CleanTalk