Make an object appear in one room when you are in another?

Started by shaungaryevans, Thu 30/04/2009 21:01:17

Previous topic - Next topic

shaungaryevans

Hi,

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


Trent R

Set a global variable, then check that variable in the end room's 'before fade-in' script.


~Trent
To give back to the AGS community, I can get you free, full versions of commercial software. Recently, Paint Shop Pro X, and eXPert PDF Pro 6. Please PM me for details.


Current Project: The Wanderer
On Hold: Hero of the Rune


Khris

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

Code: ags
  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.

shaungaryevans

#4
Sorry, but i don't get you, where do I put show_obj = 1' and how do i connect to the other room please?

Khris

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:

Code: ags
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:

Code: ags
function room_Load() {
  if (elevator_down == 1) oElevator.Visible = true;  // turn on the elevator object if the variable equals 1
}

shaungaryevans

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.

Khris

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.

shaungaryevans

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!!!

shaungaryevans

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

monkey0506

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. ;)

shaungaryevans

I have lookedf  at all of the turtorials thank you!!!

SMF spam blocked by CleanTalk