Hi! I'm using the JavaScript in my game and I used it to record information like the players name and age. I'm trying to call back to the variables in other passages to make my story more interactive. Below is my code with some string changes as to not reveal my writing.
It seems to me that vars cannot be called upon in other passages. Is there a way that I can achieve my goal?
The calls to variables like PLAYER and CITY work fine in this passage, but when addressing them in other passages like the below:<%
var start = prompt("Type 'start' to continue...")
alert("Let's gather some information about yourself.")
var PLAYER = prompt("What's your name?")
var AGE = prompt("How old are you? (This will determine whether profanity is used or not ONLY.)")
var SEX = prompt("Are you a boy? or a girl?")
var CITY = prompt("What city are you from?")
if (start === "start") {
print(" You are " + PLAYER + ". You live in "+CITY+". You are a "+SEX+". You are "+AGE+" years old.");
}
else {
close();
}
%>
[[Chapter 1]]
I get an error message that reads:You decide to go to the bank. While Frances is on her phone, your friends start walking off. <% print("Wait up " + PLAYER + " !") %> You and your friends wait for her to catch up. You head towards the bank. As you are walking, Josh suddenly stops. "Yo, whats up Josh? You alright?" asks Trevor. Josh pukes on the ground. "Holy <% if (AGE < 13) {
print("shit josh!");
}
else {
print("cow josh!");
}
%>
⚠ Uncaught ReferenceError: PLAYER is not defined (file:///C:/Users/Alec/AppData/Local/Temp/nw5500_29090/index.html#stories/fff4c9b3-e354-dd95-3290-56d6e1dd92d9/test: 4)
It seems to me that vars cannot be called upon in other passages. Is there a way that I can achieve my goal?