Help with room changing script

B

batmanai15

Guest
hello

I have the following code that I wrote. What it’s doing is assigning either room1 or Room2, randomly, to a variable room_. Then using an if statement bring the player to that room that was chosen.

What I want to do is remember what room was chosen so if the player back tracks they don’t get a new room assigned.

So not sure how to do that without re assigning the variable again.

I know I could create a new variable after room_ variable is assigned and have the new variable = room_. So I could call that in the beginning of the script. I just don’t know how to use the new variable instead of re assigning it.




var random_room = choose (Room1, Room2)

room_ = random_room;



if room_ == Room1

{

start_ = Room1Start;

global.from_room_GroupA = Room1;

global.from_start_GroupA = FromStart;

}



if room_ == Room2

{

start_ = Room2Start;

global.from_room_GroupA = Room2

global.from_start_GroupA = FromStart2;

}
 
Last edited by a moderator:
B

batmanai15

Guest
I solved my own issue.

I created a new global variable and declared it as noone. Then when the room was picked assigned that variable the room name.

Then In the beginning of the code I check if that new variable has a value assigned and if it does then proceed to that room if it equals noone then it goes through the random assign.

Works great now.
 
Top