Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Barn Owl on Mon 26/05/2025 22:53:34

Title: object[1].Visible in room 1, triggered by dialog in room 2
Post by: Barn Owl on Mon 26/05/2025 22:53:34
Hi all, hope everyone is well.

Let's say room 1 is the front porch of a house. oPizza is object ID 1. oPizza.Visible=false;

Room 2 is inside the house, and for fun let's say there's a corded landline rotary telephone. Interacting with oRotary triggers dPhone. Let's imagine dPhone looks something like this:

Phone a friend
Order a pizza
Prank call King Graham

If option 2 is selected, the pizza becomes visible in room 1

I'm checking the manual but so far I'm stumped as to how to do this with an object.

I could make a character that acts as an object, and do it that way instead...

If anybody feels like lending a hand, as to how to make an object visible in room 1 via dialog in room 2, it would be much appreciated.
Title: Re: object[1].Visible in room 1, triggered by dialog in room 2
Post by: Crimson Wizard on Tue 27/05/2025 00:16:20
There's no way to directly access other room. The usual way is to make a global variable, set it in room 2 and check in room 1's "before fade in" event, and setup the object accordingly.

Also, there's no need to use "object[1]", room objects can be given explicit script names and addressed using these names in script, like oPizza.Visible = true.
Title: Re: object[1].Visible in room 1, triggered by dialog in room 2
Post by: Barn Owl on Tue 27/05/2025 00:24:47
Copy that.

Alright, in this case I'll just take the detour route of creating a character that the player will think is an object. Sometimes you're the hero in a video game, and sometimes you're just the pizza, hah.

I believe this method will work for me here.

Thanks again, Crimson Wizard!
Title: Re: object[1].Visible in room 1, triggered by dialog in room 2
Post by: Khris on Tue 27/05/2025 11:48:15
The correct time to learn how to use variables is always yesterday, because it means you can suddenly solve 99% of your problems today ;)

Seriously, don't put this off. Adding a global variable is very easy thanks to the project tree node of the same name.
Create an int named pizza_state with an initial value of 0.
A value of 1 means the pizza was ordered and has appeared in the other room. A value of 2 means the pizza is gone again.

  // ordering pizza
  if (pizza_state == 0) pizza_state = 1;

In the other room's room_Load:
  oPizza.Visible = pizza_state == 1; // turn object visible if state is 1
When the pizza is taken:
  pizza_state = 2;
  oPizza.Visible = false;
Title: Re: object[1].Visible in room 1, triggered by dialog in room 2
Post by: Barn Owl on Wed 28/05/2025 00:21:52
Copy that, Khris.

Thank you. That's easy to follow, and is once again a huge help.