Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Nerd In Training
16
Years of Service
User Offline
Joined: 13th Feb 2010
Location:
Posted: 26th May 2010 01:00
I'm tiring to make a text based rpg, but i am running into problems with else commands. Here is the code i have so far.


If x=y then we're all doomed.
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 26th May 2010 08:39 Edited at: 26th May 2010 08:43
The problem is not with the else statement but with the variable answer which is not string.To declare a variable as string you need to put an "$" behind it`s name so the program will treat it like string.Up in the code you give value to Nothing = Nothing, you didn`t say what is the value of Nothing so the program gives it 0 by default, because there is no sign that you want it to be a string it integer by default, too.So basicly this line means 0 = 0 for the program.Let`s look at the "answer" the way you write the program it checks if the answer = 0 but anyway it`s 0 if you type nothing when it ask for input an answer, and because you check it against Nothing which is 0 also it allways give you the same result.

Check this out:


Again for 10000 time in this forum, get rid of "goto"!
Using goto is bad!
Using gosub is good!

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th May 2010 09:42
Quote: "print "What did it say?","Type : "nothing" to accept the quest!Leave blank to abandon it!""

This line is wrong also. (Quotation marks are in the wrong places.

It should be...
Quote: "print "What did it say? Type 'nothing' to accept the quest! Leave blank to abandon it!""


My signature is NOT a moderator plaything! Stop changing it!
luskos
19
Years of Service
User Offline
Joined: 28th Jun 2007
Location:
Posted: 26th May 2010 11:03
I didn`t bother much with this, actually i was in a hurry to write my post because i needed to do something else, and didn`t noticed what i`ve done.

You have sharp eye Mobiius!

Where there is a will, there is a way.
I often edit my posts, that`s who i am
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 26th May 2010 11:07
Eyes like hawk!

My signature is NOT a moderator plaything! Stop changing it!
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 26th May 2010 14:25
Also, you should maybe think about putting all the text in a text file and then reading it in, otherwise your code will become massive very quickly!

Nerd In Training
16
Years of Service
User Offline
Joined: 13th Feb 2010
Location:
Posted: 26th May 2010 16:27
Wow that question got answered quickly! Luskos your text changes are nice but i was wanting to make you go into a battle and get killed. Also what is the difference between gosub and goto

If x=y then we're all doomed.

Login to post a reply

Server time is: 2026-07-26 01:00:03
Your offset time is: 2026-07-26 01:00:03