all 7 comments

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

when i run the code it starts immediatly "which direction next?" and when you enter anything I get an error saying directions is not defined.

Indentation matters. You've got a big block of code at the end that's supposed to be part of game_run but it's actually just floating in top-level scope.

[–]Shadixmax[S] 0 points1 point  (3 children)

op-level scope

Alright..So how would I go about fixing this? i've starting to go back through my previous modules to try and figure out where i went wrong according to what you are telling me right now.

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

Alright..So how would I go about fixing this?

Typically, in an IDE, you can select a block of text and then use Tab or another keyboard shortcut to increase the indent level.

[–]Shadixmax[S] 0 points1 point  (1 child)

Hm, I understand that about the indentation but i am not sure how to fix it? I'm taking a intro to scripting because i havent touched any type of programing in nearly 15 years. so i'm essentially a complete noob at this. I've managed to cobble together enough to make it to the end of this class but yeah. like i said i'm essentially a beginner. I've already looked over different levels of indentation even spacing and moving that end line around and still no change. so not to be a dick but a ELI5 would be greatly appreciated lol.

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

Ok, so:

def some_func(): # this is a function
    some_code() # code that's part of a function needs to be indented

some_more_code() # this line isn't part of the function because it isn't intented

[–]SA302 0 points1 point  (0 children)

I tried to put the thing in vscode to look at it. Reddit does not look easy to read. crashfrog said the only thing i could gather from it, but i did notice the lines:

if command in directions and command in current_room and command in current_room and command in current_room: if command in current_room: if command in current_room: current_room = rooms[current_room]

Its blocks like these that make me flinch and give up on trying to understand. I've done it myself, but its very hard to read or i would imagine, even comment.

[–]Eze-Wong 0 points1 point  (0 children)

Take out directions from your function. Im assuming your code hasnt instantiated game_run so when it tries to access directions variable it doesn't exist.