Interact with an object, and it appears in another room

Started by NickyNyce, Mon 14/03/2011 18:44:28

Previous topic - Next topic

NickyNyce

I was wondering how you can interact with an object in room 2 and make it appear in room 1....
(example)...My lake runs along for 2 rooms...i would like to interact with my object in the lake in room 2 , and have it appear in the lake in room 1....as if it floated down river.
i have not seen how to do this anywhere....


monkey0506

Objects are room-specific, and there's no way to directly work with objects in other rooms. You would at least need a global variable which you could check in the room_Load function for the second room.

Alternately, you could consider using a Character, and then just moving it to the second room.

Sephiroth

Hello,

You could do this:

-Create a global int: flag = 0
-Create the first item in room 1 and set it to visible
-Create the second item in room2 and set it to Invisible
-On the first item 'interact event' just make it invisible and set flag to 1

Code: ags

 obj1.visible = fasle;
 flag =1; 


Now in the room2 'entersroomafterfadein' event just put:

Code: ags

if (flag == 1)
{
 obj2.visible = true;
}


Something like that would do?

AdamM

As monkey says, I think it would be easiest to substitute a character for the object. After all, the AGS Manual itself states:

QuoteA character is similar to an object, except that it can change rooms

monkey0506

Actually if you're only doing this across the two rooms I'd say a global bool would be a better option. It probably wouldn't make much difference overall, but a character is significantly larger than an object. Also, characters would exist in every room whereas the object+bool route would only leave a bool existing in every room, and the objects would only consume memory in their respective rooms.

The character route would probably be simpler though if you need this particular item to move across more than just these two rooms.

Just some things to keep in mind.

NickyNyce

Thanks alot guys, i appreciate the ideas and will mess with all of them, if i had your knowledge of AGS i would never leave the house....lol

thanks again

SMF spam blocked by CleanTalk