Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: shaungaryevans on Thu 30/04/2009 21:01:17

Title: Make an object appear in one room when you are in another?
Post by: shaungaryevans on Thu 30/04/2009 21:01:17
Hi,

How to make an object appear in one room when you are in another?

Title: Re: Make an object appear in one room when you are in another?
Post by: Trent R on Thu 30/04/2009 21:24:37
Set a global variable, then check that variable in the end room's 'before fade-in' script.


~Trent
Title: Re: Make an object appear in one room when you are in another?
Post by: shaungaryevans on Thu 30/04/2009 21:25:54
How do i set a varible?
Title: Re: Make an object appear in one room when you are in another?
Post by: Khris on Thu 30/04/2009 22:04:22
Create it using the Global variables pane (type int, initial value 0), then set it in a script:

  show_obj = 1;    // set integer variable "show_obj" to hold the value 1

PS: Since all your questions are pretty basic and resolved quickly (often by yourself), why don't you put them in a single thread instead? Less clutter that way.
Title: Re: Make an object appear in one room when you are in another?
Post by: shaungaryevans on Thu 30/04/2009 22:11:03
Sorry, but i don't get you, where do I put show_obj = 1' and how do i connect to the other room please?
Title: Re: Make an object appear in one room when you are in another?
Post by: Khris on Thu 30/04/2009 22:39:00
Alright; you can't turn on an object in another room directly, so instead, you set a variable to one.
When the player enters the other room, in that room's before fadein event, you check if the variable is one and turn on the object if it is.

Say there's a button in room A that'll lower an elevator in room B.

In room A, you've got your "interact with elevatorbutton" event linked to a function.
Instead of turning on the elevator object in room B (which you can't) you'd use something like:

function elevatorbutton_Interact() {
  Display("You push the button.");
  if (elevator_down == 1) Display("Nothing happens.");  // button was already pushed
  else {
    elevator_down = 1;   // set global variable to 1
    Display("You can hear the sound of an elevator coming from the next room.");
  }


In room B's "player enters room (before fadein)" event, you'd have:

function room_Load() {
  if (elevator_down == 1) oElevator.Visible = true;  // turn on the elevator object if the variable equals 1
}
Title: Re: Make an object appear in one room when you are in another?
Post by: shaungaryevans on Fri 01/05/2009 18:04:03
Sorry but is still won't work,

when i put this in,

if (oComputer_1 == 1) oComputer_1.Visible = true;

it says;

room1.asc(423): Error (line 423): Type mismatch: cannot convert 'Object*' to 'int'

and i have done the top bit as well.
Title: Re: Make an object appear in one room when you are in another?
Post by: Khris on Fri 01/05/2009 20:11:20
I'm using an integer variable called "elevator_down".

QuoteCreate it using the Global variables pane (type int, initial value 0), then set it in a script

You are testing the object for being one, which is a) not possible (like the compiler told you) and b) shouldn't make any sense to you if you had read my posts.
Title: Re: Make an object appear in one room when you are in another?
Post by: shaungaryevans on Fri 01/05/2009 20:29:08
I can't do it still. sorry. would you be able to email me a game example with a varible in please? I'm finding it very hard!!!
Title: Re: Make an object appear in one room when you are in another?
Post by: shaungaryevans on Fri 01/05/2009 20:40:58
I'm sorry Khris but it working now. What i didn't do is link the code: room1_load() to room 1 by the '...' button.

Thank you for all your help and sorry it took so long to work out
Title: Re: Make an object appear in one room when you are in another?
Post by: monkey0506 on Sat 02/05/2009 06:26:34
Shaun you seem to be having some difficulty understanding what exactly you're doing with the script. Which means though it might work for you, it's ultimately useless. If you don't know why it works, next time you need to do something like this you're going to have to go through the entire scenario again. I don't mean to sound condescending or anything, but you may want to go through the scripting tutorial in the manual. It was a great help to me when I was getting started and I think it would help you a lot understanding the scripts better. ;)
Title: Re: Make an object appear in one room when you are in another?
Post by: shaungaryevans on Sat 02/05/2009 18:38:07
I have lookedf  at all of the turtorials thank you!!!