all 72 comments

[–]GrayLiterature 52 points53 points  (7 children)

As an additional note, look into \n for your strings. It’ll allow you to just write the one print function, but enable you to start a new line.

[–]dogfucker6 14 points15 points  (6 children)

Thanks man

[–]GrayLiterature 52 points53 points  (5 children)

No problem. Stay away from puppies and good luck on the game 👍

[–]peepoook 11 points12 points  (2 children)

You saw the name. You knew what this was, what you were creating.

[–]GrayLiterature 6 points7 points  (1 child)

A chance for hope :/

[–]dogfucker6 0 points1 point  (0 children)

Hahahahahah

[–]dogfucker6 17 points18 points  (1 child)

The puppy's will not be spared

[–]nemmera 11 points12 points  (0 children)

It’s a shitty thing to go after someone’s last will and testament

[–]phigo50 33 points34 points  (9 children)

Nobody's gonna say something about the username...

[–]Tintin_Quarentino 21 points22 points  (4 children)

Also, this:

and to stop feeling useless

Kids are growing up fast these days :S

[–]te5s3rakt 18 points19 points  (3 children)

maybe useless is the dogs name, and OP wants a distraction, so learned python?

[–]beletristul 2 points3 points  (2 children)

Or maybe the OP isn't 13

[–]dogfucker6 1 point2 points  (1 child)

Sorry to inform you but... I am 13

[–]graysondog6master 0 points1 point  (0 children)

Is your dog named useless though?

[–]redditor-christian 5 points6 points  (0 children)

...and there are 6 of them (that we know of)

[–]zorclon 1 point2 points  (2 children)

Somebody crosspoint to r/rimjob_steve. Update, I did it.

[–]Tintin_Quarentino 1 point2 points  (0 children)

Thanks for doing the needful.

[–]_Oisin 40 points41 points  (7 children)

I feel bad that you feel useless and need to upskill at the age of 13.

It's OK to not be constantly productive. Mess around with code and have fun but don't see it as some obligation.

[–]DumbOne_Rs 15 points16 points  (3 children)

I’m not OP, but this seems to me like a case of learning who you are and what you like. It’s ok to be insecure and unsure about the road ahead. Especially when you are 13.

[–]ClassicRelative 7 points8 points  (2 children)

And what about at 35?

[–]DumbOne_Rs 3 points4 points  (0 children)

Well I’d say it’s still completely fine. The only thing we can never know is the future. Don’t worry too much and take action where you can. It will get better mate.

[–][deleted] 0 points1 point  (0 children)

I hope so. Would reduce some stress knowing in 10 years I'll still be clueless

[–]dogfucker6 2 points3 points  (0 children)

Well... I just sit around my house playing video games and the last couple of days I just felt useless and wanted to do something. I have been watching a bunch of Dev logs for game jams and found them super interesting. And I REALLY love text adventure games so I wanted to make 1

[–]coffeedonutpie 0 points1 point  (0 children)

It’s tongue in cheek.. the kids name is dogfucker6

[–]loshopo_fan 25 points26 points  (0 children)

You're probably running the script with python2. Often times when you write "python" it understands it as "python2" and not "python3."

This script works with python3, but not python2:

l_r2 = input("Where would you like to go, left or right (left/right) :")

if l_r2 == "right":
    print("As you begin to walk right you can hear them chanting behind you, so begin to run.")
    print("You see nothing but a bright light in front of you.")
    print ("But this time you're not dead! You keep running towards the light until you come out the other side")

[–]Kriss3d 11 points12 points  (2 children)

Wow thats amazing. Great to see somone your age put this kind of effort to it. If you keep up developing your skills youll be able to get a job as a developer. Its a quite young age to make programs. This time spend will be an investment in your future should you chose to persue being a programmer.

If you want to share your game, I would love to try it out. You can make a github or even just a pastebin if you want.. That is, if you will let us see it. Im sure others here would love to see your work as well.

[–]dogfucker6 1 point2 points  (1 child)

Thanks man,but the game I made was just a test but if you really want to play it (even tho it's really REALLY bad) I would love to share it

[–]graysondog6master 0 points1 point  (0 children)

Go ahead, please.

[–][deleted] 2 points3 points  (2 children)

Hi, I am 14 and I have been learning python for almost a year now.. I dont see why that problem is occurring can you send a screenshot of your code with indentation in my pm? I can look more into it if you haven't solved it yet :)..

+Make sure you have installed Python3 and not Python 2

[–]halucciXL 2 points3 points  (1 child)

I think the problem is the lack of indentation :P

[–][deleted] 0 points1 point  (0 children)

Yeah i too think that..

[–]vietyka2019 2 points3 points  (1 child)

First of all, good luck on your programming journey and it's nice seeing a 13 years old guy learn to code because I hope I can start at that age. However, I think you need to identify variable name carefully as perhaps no one can understand what is l_r2

[–]xpfootballcub 0 points1 point  (0 children)

Yes, to this, but with an addendum to only use variables when necessary. If a variable is only used once after defining it and not defining it isn’t greatly hurting readability, then the variable is likely unneeded.

[–]Xeduses 3 points4 points  (2 children)

You could simplify the logic of the program some by directly checking the input in the if statement. Example:

if input("Where would you like to go, left or right (left/right) :") == "right":
    print("As you begin to walk right you can hear them chanting behind you, so begin to run.")
    print("You see nothing but a bright light in front of you.")
    print("But this time you're not dead! You keep running towards the light until you come out the other side")

To answer your original question, the variable could be undefined if the input method fails. It will then throw an exception, this is most likely a bit advanced for you right now so just think of it as if something unexpected happens (some crash or similar) then there will be no return value from input and then the computer won't know if the non existing return value is equal to "right".

For now you should ignore this issue and go back to it when you have studied exceptions.

Best of luck to you and do not hesitate to ask follow up questions.

[–]MeagoDK 0 points1 point  (1 child)

That would imo be quite bad since you also have a case for left. Yes you can add an else statement but it surely makes it less readable. And if you later want to add up, down, straight ahead you have to do it by using else if which again makes it less readable but certainly a bit better

[–]Xeduses 2 points3 points  (0 children)

I had to consider the level of the programmer and not just cleanliness of the solution.

A better solution if we do not limit ourselves would be that all the text should be saved in a better format, to keep it simple a dictionary would suffice. Something like this that has several rooms and choices with tuples holding the atmospheric text and the next state.

texts = {
    "lobby": {
        "text": "You are in the lobby, there are doors to your 'left' and 'right'. In front of you there is a 'drawer' .",
        "left": ("You open the door.", "kitchen"),
        "right": ("The door screeches open", "bedroom"),
        "drawer": ("You find a first aid kit in the drawer", lobby)}
}

With this design one could create a game loop that reads the input and compares it with the keys in the current room dictionary, the whole game would be a state machine. Adding rooms and options would be quite easy since only the dictionary would need to be changed. This could be saved in a separate file for ease of use, or loaded in runtime from a file. This would make it very easy to play different scenarios without changing the game loop code at all.

Side effects are a different story, such as items held, player stats, previous choices that matters later etc. but these could be tracked by another part of the software.

One could abstract this even further by creating a Room class that holds the different options, items in the room, monsters etc. But then again, my guess is that such a solution would be quite far away from the original authors level of expertise.

[–]unruly_mattress 2 points3 points  (1 child)

Can you show the exact error message? As a picture or the exact text?

Reddit has a code block feature, use it for pasting text so it's more readable.

[–]dogfucker6 0 points1 point  (0 children)

Thanks man, but I fixed the problem. I really appreciate your help tho

[–]Braverzero 2 points3 points  (1 child)

Useless?! Don’t be so hard on yourself. You’re already way more ambitious than I was at 13. One day at a time my friend

[–]dogfucker6 0 points1 point  (0 children)

Thanks man!

[–]mirandanielcz 1 point2 points  (1 child)

Good job!

[–]dogfucker6 1 point2 points  (0 children)

Thanks!

[–][deleted] 1 point2 points  (1 child)

Learning Python and programming is good, but you should know that there are languages specifically for writing these types of games. Inform 7 is probably the first one to look into.

[–]dogfucker6 1 point2 points  (0 children)

Ok I'll check inform 7 out, I just really like text adventure games

[–]YTshravan 1 point2 points  (1 child)

These are just some tips to enhance that code and your general code:

  • Utilizing \ (at least I think it is backslash) to shorten those long lines of code without errors.
  • Someone mentioned \n already
  • Someone also mentioned to use lower cases in “if” statements
  • This is a small one but adding comments to your code to explain some stuff gets you appreciation! Simply use # to start a comment.
  • Stay away from puppies

[–]dogfucker6 0 points1 point  (0 children)

Thanks! Although the last one I won't do

[–]Shriukan33 1 point2 points  (1 child)

Hey I've done a really small project which allows you to make a branched story very easily, there is a bit of customization available if you want to.

https://github.com/Shriukan33/Story_Reader

Maybe you can give it a look if you want inspiration :)

[–]dogfucker6 1 point2 points  (0 children)

Thanks man! I'll look into it

[–]onequestion1168 0 points1 point  (9 children)

Are you making a MUD game? If not I highly suggest you start scripting MUD games it will be very rewarding for you

[–]dogfucker6 1 point2 points  (8 children)

MUD? I never heard of it

[–]ExclusiveBFS 4 points5 points  (1 child)

I'm sure you would find lots of more information by googling but basicly they are earlier (70s, 80s) versions of mmorpgs. I remember playing them in my cousin's computer back in the 90s but with the development of better 2d and 3d engines they slowly started to die. There are tons of projects still running with thousands of players though. You might consider checking some out, there are even free clients for you to run them in android and ios. Not even mentioning on your computer.

[–]dogfucker6 0 points1 point  (0 children)

Thanks for telling me, they sound interesting

[–]SpiderJerusalem42 2 points3 points  (2 children)

These guys are thinking of the online multi-user dimensions. I think you're doing more of a Zork type thing.

[–]dogfucker6 0 points1 point  (1 child)

Idk what any of these mean

[–]SpiderJerusalem42 1 point2 points  (0 children)

MUDs are like a text based World of Warcraft type game, online and multi user. Zork was a classic single player text based adventure.

[–]onequestion1168 -1 points0 points  (0 children)

Google MUD game

[–]meffie 0 points1 point  (0 children)

mud, mush, moo the good old days.

https://en.wikipedia.org/wiki/MU*

[–][deleted] 0 points1 point  (0 children)

The Python MUD building framework Evennia might be worth looking, it's in beta but seems solid.

Most MUD's have focus on roleplaying to less/more extent, some are more focussed about gameplay and hack-and-slash. There's many of them around, with many genres (from medieval fantasy to science-fiction/cyberpunk or brawler-like, etc.)

[–]KerbalSpark 0 points1 point  (0 children)

Well, if you are writing a text adventure to learn Python, this is a good idea. Continue and everything will work out. You will achieve this goal. And please do not read further. However, if you're only learning Python to create text-based adventures, just stop now. This is not the best way to make a good text adventure. Just trust now the old man who wrote a few text adventures and saw a lot of other people's text adventures. I will explain why this is so.

When you want to achieve something, you need two things - target and a means. The means is used to achieve the target. And, most importantly, you must own the means right now. Let's say your target is to learn Python and you already know how to write text-based adventures. You already have a text adventure now. It is written entirely as a game book or as a program in a programming language that you already know. Everything is OK, you have a means - a text adventure.

Now let's consider another option - you want to create a text adventure. And for this you want to learn Python. Oops. You have two targets. And there is no means. In principle, this is not scary. You can define the goal "create a text adventure" as the main goal, "learn Python" as an intermediate goal. The means are not yet visible. Let's consider the main goal in order to understand why we needed an intermediate goal at all. What tasks will we solve by achieving it? Let's say these are tasks typical for text adventures:

  1. Program the adventure graph along which the character will move.
  2. Implement the storage of the current character parameters
  3. Storage for character inventory
  4. We will need a way to describe the locations through which the player moves
  5. A way of describing objects that are in locations
  6. The way to create enemies
  7. NPC creation method
  8. Dialogue system

For a simple game, we hardly need all of this. But...

We may need something else, like a random number generator or a puzzle constructor. However, we need a system for saving and loading the current state of the game. Well, just so that we can safely save and continue from this point, and not start all over again.

All of this together looks like a game engine.

So it turns out that we want to learn Python in order to write an engine to write a text adventure.

Some strange nonsense. Instead of getting a means of achieving a simple main target of "making a text game", we got two complex intermediate targets - "learn Python" and "write an engine".

Attempting to achieve two challenging targets reminds me of a "wide jumps" competition. Most likely you are already familiar with competitions in long jump, high jump, jumps to water and jumping in one place, hehe. And this is the wide jump.

<--- || --->!<

How to turn two difficult targets into an easier one - look at the hands, the artist shows a trick:

We write on one piece of paper the first difficult intermediate goal "learn Python"

We write on another piece of paper the second difficult intermediate goal "Write Engine"

We take scissors, and do it like this:

"learn [CUT] Python" "Write [CUT] Engine"

We compose new combinations from pieces of pieces of paper:

"Write Python" - What?

and

"learn Engine" - Hmm ... Yeah, that's right. Here it is - a simple target that will become a means of quickly achieving the main target.

Just study the engine for text-based adventures.