Hi,
How to make an object appear in one room when you are in another?
Set a global variable, then check that variable in the end room's 'before fade-in' script.
~Trent
How do i set a varible?
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.
Sorry, but i don't get you, where do I put show_obj = 1' and how do i connect to the other room please?
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
}
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.
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.
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!!!
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
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. ;)
I have lookedf at all of the turtorials thank you!!!