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.

Newcomers DBPro Corner / Need help with my text based game

Author
Message
dan958
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 30th Mar 2008 18:51
hi,

I am new to dbp and im starting coding at the very basic (we all got to start somewhere"
Ive made a few spinning 3d cubes, but no games

my code so far...


As you can see very basic...

in my code, when is says 'are you sure your name is....'
i want to have to different inputs, one for yes, and the other for no, when the person types 'yes' it will say

and when you say 'no' it will say "well what is your name then?" and from then it will loop back to the beginning from where it asks your name.
But im not sure how to do those two inputs and two IF statements to get what im looking for.
Then only way i have managed to do it is you have to type "yes" and "no" but then both the prints will come up for both inputs.

This is probely really simple, but all i need is for somebody to just show me and then il probely call myself stupid for not knowing this.

Thanks in advance
Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 30th Mar 2008 19:11
Try this:


The until and repeat lines might have to be switched. Not at a computer where I can test this sorry.
dan958
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 30th Mar 2008 19:12 Edited at: 30th Mar 2008 19:17
i couldnt get your code to work

and this is the sort of thing i am trying to achieve, if you read the code you will probely see what im trying to do, but my code doesnt work
dan958
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 30th Mar 2008 19:44 Edited at: 30th Mar 2008 19:50
also, im trying to load some music but i just cant seem to get it to work
im using Sven B's rpg song as an example.



it says that it could not load the music, ive put the song in the same folder as the dbp file, i made a folder called 'media' and put it in there, still didnt work
dan958
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 30th Mar 2008 20:31
for my original question:

so far i have this code,


But when i try and run is, it says ' Both operands are required for non-uniary operations at line 14
this is my line 14


Any ideas where i am going wrong?
Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 30th Mar 2008 20:56
Hi dan958. You are right, we all got to start somewhere. I am new to dbo myself.

Try this, it should work:


Its very easy to understand, you just use the IF command. And the music should also work now if you have it in the same folder as your project, dont put it in a folder called media by itself.

I am still learning how to use the GOTO, GOSUB and RETURN commands to return back and repeat a code over again. I will post it as soon as i get it to work. But others might help you with that later
Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 30th Mar 2008 21:01
There are several reasons your code doesn't work.
The error you are getting is because the + after the if statement.
That line should look more like

if yes$="yes" then print "oh, hi " + name$ + "!"

You should only have one input command. Using two commands will ask for two answers.

As for the code I suggested:
As I thought I needed to switch the repeat and until commands.
Now try:


What I did was use a repeat until statement to check what the player answers. If the player answers anything but yes
then it returns to asking for your name, until the player answers yes
Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 30th Mar 2008 21:04
You would also use the IF command if you want to check if the user hasent entered anything, but then you will need a return command like i said or the code would be very long.

The GOTO, GOSUB and RETURN commands can be found in the Command Index - Core Commands list.
Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 30th Mar 2008 21:06
Well, my version also works
dan958
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 30th Mar 2008 21:20
yea, thanks for all that replyed, i used dritt's and it worked perfectly.

but i still cant get the music to load.

i have the file in the same folder as my dbp file, i is called intro and is a midi file
Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 30th Mar 2008 22:28
Im glad it worked

Hmm... thats strange. What version of dbp are you using? There may be a bug in the music command from older versions.
dan958
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 30th Mar 2008 22:55
im not sure how to see what version i am running.
i dont have a case or a manual becuase my dad bought the copy from a boot fair without the case
Dritt
18
Years of Service
User Offline
Joined: 10th Jan 2006
Location:
Posted: 30th Mar 2008 23:04
Click on help, then go to about and you will see.

So i am guessing you havent upgraded to the newest version? Then you must be using the retain version 1.0.

You should upgrade to the latest version 6.2.
dan958
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 30th Mar 2008 23:43 Edited at: 30th Mar 2008 23:44
im sorry, but i know nothing..how would i go about doing that?

*edit* never mind, i found it
dan958
16
Years of Service
User Offline
Joined: 7th Feb 2008
Location:
Posted: 31st Mar 2008 00:10
full upgraded now, il try again
Must Program
16
Years of Service
User Offline
Joined: 22nd Nov 2007
Location:
Posted: 18th May 2008 12:59
hows that going for ya


and

whe i make a text based game is it
input ",inputstring$"
or
input "",inputstring$

they are different and i dont know whats the right one help will be apreiated
Must Program
16
Years of Service
User Offline
Joined: 22nd Nov 2007
Location:
Posted: 18th May 2008 15:53
thanks windows ure a life saver

Login to post a reply

Server time is: 2024-09-27 14:19:57
Your offset time is: 2024-09-27 14:19:57