Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: PokeyFlame on Mon 28/04/2008 19:16:28

Title: Simple question - Turning object on in different room
Post by: PokeyFlame on Mon 28/04/2008 19:16:28
I have checked the manual and read quite a lot of questions about this topic however I'm having trouble with it. I'm using 3.0.
From my GlobalScript.asc

function cMayor_Talk()
{
if (GetGlobalInt(1) ==1) {
  dMayor2.Start();
}
else {
  dMayor1.Start();
  SetGlobalInt(1, 1);
  object[2].Visible = true;
    }
}

When I play and I talk to the Mayor an error message appears:-

Error: ObjectOn: invalid object specified

The object is    oJail (Object; ID 2)

If anyone can help thanks alot
Title: Re: Simple question - Turning object on in different room
Post by: Pumaman on Mon 28/04/2008 20:26:49
Are you definitely in the same room as the object when you talk to the mayor?
Title: Re: Simple question - Turning object on in different room
Post by: PokeyFlame on Mon 28/04/2008 21:50:34
Sorry I forgot to mention. The object is in a different room to the mayor. What happens is when you finish talking to the mayor the first time an object appears in a different room.
Title: Re: Simple question - Turning object on in different room
Post by: Pumaman on Mon 28/04/2008 23:32:09
The object[] array always accesses the current room.

You can't directly access objects in other rooms. There are various ways to do it, but the simplest is probably to use the OtherRoom module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=20650).

Title: Re: Simple question - Turning object on in different room
Post by: PokeyFlame on Tue 29/04/2008 17:11:23
Sorry the download is for AGS 2.70 etc.
I have AGS 3.0 so I don't think it would work. Do you know of any scripting that could make it turn on. I have tried before OtherRoom.Object_On(2,2) but it doesn't understand 'OtherRoom'.
Title: Re: Simple question - Turning object on in different room
Post by: InCreator on Tue 29/04/2008 17:17:30
Why do you have to do it from different room anyway? In that "other room" use globalint and in the room where thing happens, let function start when globalint is something you set in other room -- "before fadein" event.

I mean--

in the other room, when you want to manipulate things in another room...
SetGlobalint(a,b)

and in the room itself, before fadein
if (GetGlobalInt(a) == b)
-- do stuff

Since it's before fadein, when player sees the room, it's changed already.
Or use "after fadein" if you want stuff to happen as soon as player sees the room.
Title: Re: Simple question - Turning object on in different room
Post by: SSH on Tue 29/04/2008 17:23:29
OtherRoom module should probably work in 3.0 AFAIK. Why not try it?
Title: Re: Simple question - Turning object on in different room
Post by: PokeyFlame on Tue 29/04/2008 19:16:57
I know how to use global ints and i have tried using OtherRoom.
What I don't understand is what i put as a function. You said before fade in type getglobalint...

But what is the function? That is where i get confused
Title: Re: Simple question - Turning object on in different room
Post by: Khris on Tue 29/04/2008 19:21:14
Go to the room's events, select "player enters room (before fadein)" in the list, then click the little ... button.
This should take you to / create the roomLoad function. Put the code in there.

Why don't people rtfm before posting here anymore...?
Title: Re: Simple question - Turning object on in different room
Post by: PokeyFlame on Tue 29/04/2008 19:40:04
Quote from: KhrisMUC on Tue 29/04/2008 19:21:14
Why don't people rtfm before posting here anymore...?

I'm sorry, I have done the tutorial and read quite a bit about scripting. It's just that I didn't realise rooms had events. I'm sorry, I wasn't thinking right.
But thanks anyway, it's working perfectly now. Cheers