Text-Based Game

Unrelated, but your DOCTYPE declaration is not formatted correctly, and you're also missing the character encoding declaration.

Should be (you're missing the ! at the beginning):
Code:
<!DOCTYPE html>

Then add the encoding between your <head> and <body> tags
Code:
<head></head>
<meta charset="UTF-8">
<body></body>
 
Was getting those errors in Chrome's console as well but it continued on anyway. I didn't look into it much - assumed you just didn't define that function yet.

Have you defined it in your JS file?

Yes, I did define bluefunction. I was just adding more after the correct and do not correct buttons and I somehow screwed it up again, now I get the same error in chrome as I got in firefox (the first button didn't disappear, and neither of the red/blue buttons work. I think it may have something to do with the closing/opening brackets? It gets so hard to keep track of them when your code is 370 lines long!! Here is the new file:
 

Attachments

  • Lines of Story 2.zip
    4.3 KB · Views: 0
Unrelated, but your DOCTYPE declaration is not formatted correctly, and you're also missing the character encoding declaration.

Should be (you're missing the ! at the beginning):
Code:
<!DOCTYPE html>

Then add the encoding between your <head> and <body> tags
Code:
<head></head>
<meta charset="UTF-8">
<body></body>

Ah thanks
 
Yes, I did define bluefunction. I was just adding more after the correct and do not correct buttons and I somehow screwed it up again, now I get the same error in chrome as I got in firefox (the first button didn't disappear, and neither of the red/blue buttons work. I think it may have something to do with the closing/opening brackets? It gets so hard to keep track of them when your code is 370 lines long!! Here is the new file:

Note: I'm still looking at your previous file still (haven't downloaded your new source yet).

Ok...looking at your JS file now... you have quite a few errors.

Firstly...comments are wrong. Comment lines begin with // not /
Secondly... you're missing 2 closing braces at the end of your change() function (one for closing the switch, and another for closing the function)
Thirdly...looks like the 2 missing closing braces are actually at the end of your file...remove them after adding the 2 in the correct spot

I'm going to HIGHLY suggest you use a code editor with syntax highlighting. Use Notepad++; it supports folding (collapsting functions/statements that have braces) and syntax highlighting.

Unfortunately...fixing that stuff seems like it broke it more.
 
Note: I'm still looking at your previous file still (haven't downloaded your new source yet).

Ok...looking at your JS file now... you have quite a few errors.

Firstly...comments are wrong. Comment lines begin with // not /
Secondly... you're missing 2 closing braces at the end of your change() function (one for closing the switch, and another for closing the function)
Thirdly...looks like the 2 missing closing braces are actually at the end of your file...remove them after adding the 2 in the correct spot

I'm going to HIGHLY suggest you use a code editor with syntax highlighting. Use Notepad++; it supports folding (collapsting functions/statements that have braces) and syntax highlighting.

Unfortunately...fixing that stuff seems like it broke it more.

Comments... Check

Braces... Check

More Braces at end... Check

Okay then... now when I get to the red/blue choice, the red button does not work at all, and the blue button just makes the new submit button appear...?

Screenshot:
Screen Shot 2015-01-08 at 3.29.19 PM.png

New Zip:
View attachment Lines of Story.zip


Edit:
I have used Notepad++ before, on my Windows computers, I am coding this on my school mac air, and for this I have been using an editor called Sublime Text 2.

Oh, and yes, I forgot a comment at the top of the Javascript :D
 
Last edited:
I noticed it started doing that as well after I fixed the comments and the braces in your JS file.

Looks like you have other issues you need to debug. Set breakpoints in your browser in the dev tools' debugger section and you should be able to step through the JS as it's firing and see if it's performing the correct actions.

In the console there were some errors as well about some elements not being found or defined...so you may want to look into that as well.

Sublime Text 2 is fine as well - I've used it before but just prefer Np++.
 
I noticed it started doing that as well after I fixed the comments and the braces in your JS file.

Looks like you have other issues you need to debug. Set breakpoints in your browser in the dev tools' debugger section and you should be able to step through the JS as it's firing and see if it's performing the correct actions.

In the console there were some errors as well about some elements not being found or defined...so you may want to look into that as well.

Sublime Text 2 is fine as well - I've used it before but just prefer Np++.

How do I set breakpoints? I understand what you mean by "run through the code as it fires", but what is a "breakpoint"?
 
A breakpoint is a point where the code "breaks" or stops running during execution.

In Chrome, go to the Sources tab -> open your JS file

To set a Breakpoint, click on the left margin where the line numbers are, and it will put a blue highlight on that line number. That's a breakpoint. It will be listed on the "Breakpoints" panel on the right side of the Sources window. Now, run through the page, and when it hits that point in the code it will stop execution. Now you can look at variable values, see if anything is null, etc.

To go to the next line without it continuing all the way, tap F10 on your keyboard (or the Step Over button on the right-side panel)
To go INTO the function on the current line (if you're calling a function from a function), tap F11 (or the Step Into button)

You can also add Watches (to see the value of a specific variable at all times) in the Watch Expression window.

To remove a breakpoint, either click the blue icon on the line number to remove it, uncheck it from the Breakpoints panel, or remove all by clicking the "Deactive breakpoints" button on the right panel.
 
A breakpoint is a point where the code "breaks" or stops running during execution.

In Chrome, go to the Sources tab -> open your JS file

To set a Breakpoint, click on the left margin where the line numbers are, and it will put a blue highlight on that line number. That's a breakpoint. It will be listed on the "Breakpoints" panel on the right side of the Sources window. Now, run through the page, and when it hits that point in the code it will stop execution. Now you can look at variable values, see if anything is null, etc.

To go to the next line without it continuing all the way, tap F10 on your keyboard (or the Step Over button on the right-side panel)
To go INTO the function on the current line (if you're calling a function from a function), tap F11 (or the Step Into button)

You can also add Watches (to see the value of a specific variable at all times) in the Watch Expression window.

To remove a breakpoint, either click the blue icon on the line number to remove it, uncheck it from the Breakpoints panel, or remove all by clicking the "Deactive breakpoints" button on the right panel.

It says that bluebtn is not defined, but it obviously IS.
 
Last edited:
Back
Top Bottom