Turing Final Project
Author |
Message |
riya
|
Posted: Tue Jan 20, 2015 10:38 pm Post subject: Turing Final Project |
|
|
What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>
What is the problem you are having?
<My final project for grade ten computer studies in Turing, is not working because it stops at this error at the else in my if statement, I've tried rearranging and all this stuff but, yeah. >
Describe what you have tried to solve this problem
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
edit: paste in from a separate thread
Quote:
Post subject: Turing Final Project
I have my turing final project due tomorrow and I decided to post my Q here, in case I do not get a chance to ask my teacher. Basically, my program which is a text-adventure game (through an enchanted forest!) stops at this one part in the middle of my if statement at else, I have no idea why and obv. I need it to work lool. So if you can help please do! Thanks in advance!! I have no idea how to post a file on here, so here's the problem:
code: |
if r1 = "nothing" or r1 = "Nothing" then
put "Well done! Your smartness is evident. The dwarfs let you"
put "go through their portal and you arrive a little late, but"
put "what matters is that you are there! Your journey is complete!"
put "You have made it with two Fairy Dust left! Type 'again' to"
put "replay!"
get again
if again = "again" or again = "Again" then
scene := 1
end if
else r1= "No" then
put "Wrong answer! You have lost one life!"
fd := fd - 1
put "\t\t\t\t\t\t\t\t Fairy Dust: ", fd
riddle := 1
end if
if fd>=0 then
scene:=7
end if
end if
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
|
|
|
|
riya
|
Posted: Wed Jan 21, 2015 7:06 pm Post subject: RE:Turing Final Project |
|
|
okay I kind of fixed the error, thanks A TONNE for replying and the tutorial link! My teacher said to just do else and then have what to do like the turing instruction. My problem now is that, when they get it wrong the program is suppose to take them to the riddle again so they can try again but, it doesn't instead, it takes the user to the start which is not what I need it to do. Any suggestions? |
|
|
|
|
|
riya
|
Posted: Wed Jan 21, 2015 7:08 pm Post subject: RE:Turing Final Project |
|
|
put "\t\t\t\t\t\t\t\t Fairy Dust: ", fd
put ""
put "The Unknown: After, a little walking you see a sign: LAND OF DWARFS "
put "There you meet Grumpy and Happy, and after a few laughs"
put "they take you over to their portal. You can cross the portal"
put "only on one condition: you must solve their riddle!"
delay (7500)
cls
put "\t\t\t\t\t\t\t\t Fairy Dust: ", fd
Draw.FillStar (0, 0, star, star, brightgreen)
Draw.FillStar (maxx - star, 0, maxx, star, brightgreen)
delay (2900)
riddle := 1
put "The Unknown: The riddle is: "
put ""
put "What is more powerful than God?"
put "What is more evil than the Devil?"
put "The poor have it."
put "The rich need it."
put "If you eat it you will die."
put "Hint: The answer is one word! Type in the word: "
get r1
end if
if r1 = "nothing" or r1 = "Nothing" then
put ""
put "The Unknown: Well done! Your smartness is evident. The dwarfs let you"
put "go through their portal and you arrive a little late to that party,"
put "but, what matters is that you are there! Your journey is complete!"
put "You have made it with two Fairy Dust left! Type 'again' to"
put "replay!"
get again
if again = "again" or again = "Again" then
scene := 1
end if
end if
else
cls
put "Wrong answer! You have lost one life!"
fd := fd - 1
put "\t\t\t\t\t\t\t\t Fairy Dust: ", fd
end if
if fd >= 0 then
scene := 0
end if |
|
|
|
|
|
Tony
|
Posted: Wed Jan 21, 2015 7:57 pm Post subject: RE:Turing Final Project |
|
|
code: |
loop
...
...
# success, we can move on
exit
...
...
end loop
|
use loops to repeat stuff. exit once whatever condition is met. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
riya
|
Posted: Wed Jan 21, 2015 8:08 pm Post subject: RE:Turing Final Project |
|
|
how do I post a file on here? Turing is killing me omg |
|
|
|
|
|
riya
|
Posted: Wed Jan 21, 2015 8:11 pm Post subject: RE:Turing Final Project |
|
|
OMG Tony! I got the else to work but, it only works when I have one put statement and if I add another one or anything it crashes. What should I do? |
|
|
|
|
|
Tony
|
Posted: Wed Jan 21, 2015 8:13 pm Post subject: RE:Turing Final Project |
|
|
lets see the code. How does it crash (is there an error?) |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Sponsor Sponsor
|
|
|
riya
|
Posted: Wed Jan 21, 2015 8:15 pm Post subject: RE:Turing Final Project |
|
|
okay this is the code.
if crosspath = "East" or crosspath = "east" then
cls
fd := fd + 0
put "\t\t\t\t\t\t\t\t Fairy Dust: ", fd
Draw.FillStar (0, 0, star, star, yellow)
Draw.FillStar (maxx - star, 0, maxx, star, yellow)
delay (2900)
put "The Unknown: Oh no! The goblin managed to catch up to you!"
put "After demanding one of your precious Fairy Dust and scaring"
put "you very much so, he is off on his way."
delay (1000)
fd := fd - 1
put "\t\t\t\t\t\t\t\t Fairy Dust: ", fd
delay (4000)
put ""
put "The Unknown: After, a little walking you see a sign: LAND OF DWARFS "
put "There you meet Grumpy and Happy, and after a few laughs"
put "they take you over to their portal. You can cross the portal"
put "only on one condition: you must solve their riddle!"
delay (5900)
cls
put "\t\t\t\t\t\t\t\t Fairy Dust: ", fd
Draw.FillStar (0, 0, star, star, yellow)
Draw.FillStar (maxx - star, 0, maxx, star, yellow)
delay (2900)
riddle := 1
put "The Unknown: The riddle is: "
put ""
put "What is more powerful than God?"
put "What is more evil than the Devil?"
put "The poor have it."
put "The rich need it."
put "If you eat it you will die."
put "Hint: The answer is one word! Type in the word: "
get r1
end if
if r1 = "nothing" or r1 = "Nothing" then
put ""
put "The Unknown: Well done! Your smartness is evident. The dwarfs let you"
put "go through their portal and you arrive a little late, but"
put "what matters is that you are there! Your journey is complete!"
put "You have made it with two Fairy Dust left! Type 'again' to"
put "replay!"
get again
else
put "Wrong answer! You have lost one life!"
end if
if again = "again" or again = "Again" then
scene := 1
end if
if fd >= 0 then
scene := 0
end if
if I add anything even another put statement to the else right up there it crashes! |
|
|
|
|
|
riya
|
Posted: Wed Jan 21, 2015 8:19 pm Post subject: RE:Turing Final Project |
|
|
and what I need to add to that else is this:
fd := fd - 1
put "\t\t\t\t\t\t\t\t Fairy Dust: ", fd
and then put the loop in to take it back to the riddle, but if i use this loop, will it mess anything else up? I have one big loop for the entire program and many if statements. Will the loop work? I AM SO SORRY FOR BOMBARDING YOU WITH Q'S |
|
|
|
|
|
riya
|
Posted: Wed Jan 21, 2015 9:16 pm Post subject: RE:Turing Final Project |
|
|
tony I really need your help |
|
|
|
|
|
riya
|
Posted: Wed Jan 21, 2015 9:45 pm Post subject: RE:Turing Final Project |
|
|
nvm I got it! Thanks for your help! |
|
|
|
|
|
Tony
|
Posted: Thu Jan 22, 2015 1:42 pm Post subject: RE:Turing Final Project |
|
|
I'm glad that you figured out this particular issue, but I'd like to stress this one important technique for figuring out the problems faster:
- pay attention to the error messages (you haven't mentioned those, even after having been asked).
- in a separate file, find the minimal amount of code that reproduce the same error.
E.g. for an error with a if-else structure, we really don't need all of those puts, delays, and draws. It's difficult to understand large blocks of code, but you can cut it down to a small example
code: |
if 1 = 2 then
put "A"
else
put "B"
end if
|
and study that. If the error is still there, it will be much easier to find. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
|
|