[SOLVED] Adding a String to an existing string

E

EMm

Guest
So my game is a choose your own adventure style game where the player makes decisions and depending on those decisions they go to certain rooms. I'm trying to make it so theres a string which checks which decision you made and then adds it to an existing string, which then prints on an end screen to show which choices the player made. right now I have:

In the event the player presses the 1 key -

var roomName = room_get_name(room)
global.Choices = "You chose to:";

if roomName = "rm_j1" {
global.Choices += " Be diplomatic,"
}

if roomName = "rm_jw1" {
global.Choices += " Agree with the President"
}


which then prints in a seperate object.

However, the issue I'm having is the variable global.choices is not re setting to the new vaule of global.Choices and is just using the variable set at the top of the code.

I would like it to print:
"You chose to: Be diplomatic, Agree with the president"

But its only printing:
"You chose to: Agree with the President"

I was wondering if anyone could help me understand what is going wrong and how to add each string to the one initialized, without getting rid of the previous one.
 

Tthecreator

Your Creator!
What I'm seeing here is that whenever the key is pressed, global.Choices is reset to "You chose to:"

Lets get an example:
You press the 1 button in rm_j1 then the following will happen:
global.Choices = "You chose to:";
global.Choices += " Be diplomatic,"

Now you continue to rm_jw1 and then this will happen:
global.Choices = "You chose to:";
global.Choices += " Agree with the President"

Are you seeing what is happening? You are resetting global.Choices over and over again, while you are only in a single room at a time.
What you should do is set global.Choices once when starting the game and then never again.
 
E

EMm

Guest
What I'm seeing here is that whenever the key is pressed, global.Choices is reset to "You chose to:"

Lets get an example:
You press the 1 button in rm_j1 then the following will happen:
global.Choices = "You chose to:";
global.Choices += " Be diplomatic,"

Now you continue to rm_jw1 and then this will happen:
global.Choices = "You chose to:";
global.Choices += " Agree with the President"

Are you seeing what is happening? You are resetting global.Choices over and over again, while you are only in a single room at a time.
What you should do is set global.Choices once when starting the game and then never again.
Oh my goodness thank you so much! I dont know why I couldnt think of that
 
Top