|
-
May 16th, 2017, 02:58 PM
#1
Thread Starter
New Member
[RESOLVED] Looking for a way to read specific lines in my program.
I am not really a knowledgeable or experienced programmer, but I know some of the basics. I am working on a game, but the way I am writing it requires the computer to read lines that it has already skipped over. Here is a snippet of the code:
Code:
If HelpScreen3 = 1 Then
Console.Clear()
Console.WriteLine("In the game you will always have two, three, or four choices to make.")
Console.WriteLine("Each choice can affect things that happen later in the game, so choose wisely.")
Console.WriteLine("Your goal is to escape, and stay alive.")
Console.WriteLine("")
Console.WriteLine("Here are the commands you can type:")
Console.WriteLine("")
Console.WriteLine("")
Console.WriteLine("'help' brings up this screen. (The help screen)")
Console.WriteLine("'inventory' shows what you are carrying in the game.")
Console.WriteLine("'map' shows a map of what you have explored.")
Console.WriteLine("'exit' will close the game. Be warned, there is currently no saving.")
Console.WriteLine("")
Console.WriteLine("")
Console.WriteLine("Type 'return' to continue the came.")
Console.WriteLine("")
Do Until Stage1 = 1 Or Stage2 = 1 Or Stage3 = 1
Dim enteredText As String = Console.ReadLine()
If enteredText = "return" Then
If StageNumber = 1 Then
Stage1 = 1
HelpScreen3 = 0
End If
If StageNumber = 2 Then
Stage2 = 1
HelpScreen3 = 0
End If
If StageNumber = 3 Then
Stage3 = 1
HelpScreen3 = 0
End If
If StageNumber = 4 Then
Stage4 = 1
HelpScreen3 = 0
End If
If StageNumber = 5 Then
Stage5 = 1
HelpScreen3 = 0
End If
If StageNumber = 6 Then
Stage6 = 1
HelpScreen3 = 0
End If
Else
Console.WriteLine("")
Console.WriteLine("This command does not exist!")
Console.WriteLine("")
End If
Loop
End If
If Stage1 = 1 Then
StageNumber = 1
Console.Clear()
Console.WriteLine("You awake inside of a cold and very dark room.")
Console.WriteLine("As you come to your senses, the room appears lighter.")
Console.WriteLine("The moonlight shines bright through a broken window to your right.")
Console.WriteLine("It appears as though you are in your bedroom, but something happened there.")
Console.WriteLine("Someone looks to have been in your house.")
Console.WriteLine("You see a closed door in front of you.")
Console.WriteLine("There is a drawer to your left.")
Console.WriteLine("A wall stands behind you.")
Console.WriteLine("")
Console.WriteLine("")
Console.WriteLine("'1' to climb out the window.")
Console.WriteLine("'2' to open the door.")
Console.WriteLine("'3' to check the drawer.")
Console.WriteLine("'4' to examine the wall.")
Console.WriteLine("")
Do Until Stage2 = 1 Or Stage3 = 1 Or Stage1Drawer = 1 Or Stage1Wall = 1 Or HelpScreen3 = 1 Or Inventory = 1 Or Map = 1
Dim enteredText As String = Console.ReadLine()
If enteredText = "1" Then
Stage2 = 1
Stage1 = 0
ElseIf enteredText = "2" Then
If Stage1DoorKey = 1 Then
Stage3 = 1
Stage1 = 0
ElseIf Stage1DoorKey = 0 Then
Stage1Door = 1
Stage1 = 0
End If
ElseIf enteredText = "3" Then
Stage1Drawer = 1
Stage1 = 0
ElseIf enteredText = "4" Then
Stage1Wall = 1
Stage1 = 0
ElseIf enteredText = "help" Then
HelpScreen3 = 1
Stage1 = 0
ElseIf enteredText = "inventory" Then
Inventory = 1
Stage1 = 0
ElseIf enteredText = "map" Then
Map = 1
Stage1 = 0
ElseIf enteredText = "exit" Then
Environment.Exit(0)
Else
Console.WriteLine("")
Console.WriteLine("This command does not exist!")
Console.WriteLine("")
End If
Loop
End If
Now as you can see, there are 2 main chunks of code in this part. In the game, the computer skips over the first chunk and reads the second chunk. That is what is supposed to happen. What I want to happen is when you type 'help' it will read the first chunk, but this only works if the first chunk is under the second chunk. Makes sense since the computer reads downward, but it is required for the first chunk to stay where it is. I cant flip flop the chunks or else the program wont work for the way I a writing it.
So, is there anything I can put inside of HERE, that will allow me to read the start of chunk number 1. Remember that chunk 1 is not the start of my program.:
Code:
If enteredText = "1" Then
Stage2 = 1
Stage1 = 0
ElseIf enteredText = "2" Then
If Stage1DoorKey = 1 Then
Stage3 = 1
Stage1 = 0
ElseIf Stage1DoorKey = 0 Then
Stage1Door = 1
Stage1 = 0
End If
ElseIf enteredText = "3" Then
Stage1Drawer = 1
Stage1 = 0
ElseIf enteredText = "4" Then
Stage1Wall = 1
Stage1 = 0
ElseIf enteredText = "help" Then
HelpScreen3 = 1
Stage1 = 0
(HERE)
ElseIf enteredText = "inventory" Then
Inventory = 1
Stage1 = 0
ElseIf enteredText = "map" Then
Map = 1
Stage1 = 0
ElseIf enteredText = "exit" Then
Environment.Exit(0)
Thank you for any help!
Last edited by Shaggy Hiker; May 16th, 2017 at 04:01 PM.
Reason: Added CODE tags.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|