/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Choose your own adventure game….. HELP!!!!

I am currently developing a choose your own adventure game for a class I am taking. I made an alert box that asks the players name that I am wanting to link to the game so that their name is a part of the story. I have no clue how to do this, I am also wanting to link the alert box to the next page in the series. If anyone could help me on this I would greatly appreciate it!!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERNov 14.2014 — For help you must post some original code.

We don't normally do homework.
Copy linkTweet thisAlerts:
@JacobsMommy806authorNov 14.2014 — For help you must post some original code.

We don't normally do homework.[/QUOTE]


There is no code because I don't even know where to start on doing this.. I'm not asking someone to do it all for me but I would like to atleast be pointed in the right direction.
Copy linkTweet thisAlerts:
@Sup3rkirbyNov 14.2014 — I never want to discourage a curious mind, but coding/programming often involves more than just knowing the language. You also need to be able to conceptualize the logic behind what you want to do first, and then find a way to make that possible. I could learn every single thing there is to know about javascript, but if I lack the ability to creatively and logically assess a problem or situation, I'd never be able to code anything on my own.

[B]tl;dr[/B] You need to first think out what you want to do logically, then ask about how to code it.



But, I'll throw you a bone.

You claimed you have an alert box that ask for the player's name (which would be a prompt, not an alert). All you need to do is store this name in a global variable and then you will be able to reference that variable anywhere else in your script. This would allow you to insert the name into various parts of the story by calling that variable.
[CODE]
var $player = prompt("Hello there, what's your name?");
alert("Alright, well thanks for dropping by, " + $player + ". Now your adventure begins!");
[/CODE]

Above is just an example. It's there to do nothing more than demonstrate the idea of saving the name and then referencing it later. The code above does not verify that a valid name was entered and the use of [B]alert()[/B] boxes to display story messages would be a poor decision. So hopefully you don't copy and paste my code and try to use it for your assignment.
Copy linkTweet thisAlerts:
@JacobsMommy806authorNov 14.2014 — I never want to discourage a curious mind, but coding/programming often involves more than just knowing the language. You also need to be able to conceptualize the logic behind what you want to do first, and then find a way to make that possible. I could learn every single thing there is to know about javascript, but if I lack the ability to creatively and logically assess a problem or situation, I'd never be able to code anything on my own.

[B]tl;dr[/B] You need to first think out what you want to do logically, then ask about how to code it.



But, I'll throw you a bone.

You claimed you have an alert box that ask for the player's name (which would be a prompt, not an alert). All you need to do is store this name in a global variable and then you will be able to reference that variable anywhere else in your script. This would allow you to insert the name into various parts of the story by calling that variable.
[CODE]
var $player = prompt("Hello there, what's your name?");
alert("Alright, well thanks for dropping by, " + $player + ". Now your adventure begins!");
[/CODE]

Above is just an example. It's there to do nothing more than demonstrate the idea of saving the name and then referencing it later. The code above does not verify that a valid name was entered and the use of [B]alert()[/B] boxes to display story messages would be a poor decision. So hopefully you don't copy and paste my code and try to use it for your assignment.[/QUOTE]


Thank you, I am just starting out in javascript and understand only a small amount but thank god I still have 2 years of school left, lol. Explaining to me to use global actually helps me ALOT!!
×

Success!

Help @JacobsMommy806 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...