Advertisement
Guest User

Untitled

a guest
Dec 14th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 7.90 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use utf8;
  5. use Term::ANSIScreen qw(cls);
  6.  
  7. STARTMENU:
  8. print
  9. "___________________________________________
  10. |                                         |
  11. |        Generic Text Adventure           |
  12. |                                         |
  13. |                                         |
  14. |                                         |
  15. |         How far will you go?            |
  16. |                                         |
  17. |XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX|
  18. |                                         |
  19. | [1] Start Game          [2] Load Game   |
  20. |                                         |
  21. |               [3] Help                  |
  22. |                                         |
  23. |                                    V1.0 |
  24. ------------------------------------------- \n";
  25. my $gamechoise = <STDIN>;
  26.  
  27. if ($gamechoise == "1"){
  28. goto GAME}
  29. elsif ($gamechoise == "2"){
  30. goto LOAD}
  31. else {goto HELP};
  32.  
  33. HELP:
  34. print "helptext \n
  35. This is help for this game. \n
  36. This is just a generic text adventure, nothing really special. \n
  37. It's rather a smol excercise / perl training for meh. \n
  38. So since it's a text adventure, use your keyboard to enter commands to trigger certain actions to continue the journey. \n
  39. If an input is required, you are seeing a field that tells you which actions and which items can be used. Those fields look something like this: \n
  40. _________\n
  41. ACTIONS: ACTION1 \n
  42. OBJECTS: OBJECT1, OBJECT2\n
  43. --------- \n
  44. Every command you type in has to consist of maximum 1 action and at least 1 object.\n
  45. For Example, to do ACTION 1 WITH OBJECT 1, just type following and apply with enter: \n
  46. ACTION1 OBJECT1 \n
  47. Note that you have to use caps lock for your input. To use several objects at once, just put an AND in between the objects you want to use, for example: \n
  48. ACTION1 OBJECT1 AND OBJECT2 \n
  49. This is what a command should look like with real values: \n
  50. EAT SPAGHETTI AND PIZZA \n
  51. And this is basically how this game works. Now it's your turn. Start the game and enjoy :)\n
  52. [1] Main Menu \n";
  53. $gamechoise = <STDIN>;
  54. if ($gamechoise == 1){
  55. goto STARTMENU;}
  56.  
  57. GAME:
  58. print "You wake up in a dark room. Of course, and just like in any other generic RPG, you don't know what happened or what led you to this situation.
  59. You take a look in you bag. Inside your bag you find a matchbox..\n";
  60. ONE: print "_________\n
  61. ACTIONS: USE \n
  62. OBJECTS: MATCHES\n
  63. --------- \n";
  64. chomp (my $action = <STDIN>);
  65. if ($action eq "USE MATCHES"){
  66. print "\n You are lighting one match to get a hint of your surroundings. The light your match creates is not very bright and didn't last long. But you were able to recognise a candle standing on a table next to you.. \n"}
  67. else {print "\nthis doesn't work \n \n "; goto ONE};
  68.  
  69. TWO: print "_________\n
  70. ACTIONS: USE \n
  71. OBJECTS: MATCHES, CANDLES\n
  72. --------- \n";
  73. chomp ($action = <STDIN>);
  74. if ($action eq "USE MATCHES AND CANDLES"){print "\n You are lighting the candle to get a better view of your surroundings. You seem to be in a bigger room since the candlelight doesn't illuminate the whole room you're in. It's enough tho to see following contruction next to you:
  75. There's a light switch mounted to the wall. Two open, non insulated copper wires connect that light switch to a lightbulb hanging several feet above you. Your feet are bound to the ground via a rope that you can't loosen
  76. with your bare hands.. \n"}
  77. else {print "\nthis doesn't work \n \n"; goto TWO};
  78.  
  79. THREE: print "_________\n
  80. ACTIONS: USE \n
  81. OBJECTS: SWITCH\n
  82. --------- \n";
  83. chomp ($action = <STDIN>);
  84. if ($action eq "USE SWITCH"){print "\nAs you press the switch to turn on the light bulb, a loud bang and a bright flash emerge from the bulb above you, before it gets dark again.
  85. As the bulb explodes, the glass of the bulb shatters and bigger pieces of glass shards land around you..\n";}
  86. else {print "\nthis doesn't work"; goto THREE}
  87.  
  88. FOUR: print "_________\n
  89. ACTIONS: USE \n
  90. OBJECTS: SHARDS, ROPE\n
  91. --------- \n";
  92. chomp ($action = <STDIN>);
  93. if ($action eq "USE SHARDS AND ROPE"){print "\nYou use the glass shards to cut the rope that keeps you from moving around freely.
  94. You pick up the lit candle and start to investigate the room you're in.\n"}
  95. else { print"\nthis doesn't work\n"; goto FOUR}
  96.  
  97. FIVE: print "_________\n
  98. ACTIONS: GO \n
  99. OBJECTS: NORTH\n
  100. --------- \n";
  101. chomp ($action = <STDIN>);
  102. if ($action eq "GO NORTH"){print "\nOn the other side of the room there's a locked door. It has a keyhole, where, obviously, dear player, a key is supposed to be inserted into in order to proceed. As you look down, you can find a kind of drainage hole in the floor.
  103. Luckily, our weak candlelight reveals a weak reflecting thing on the bottom of that hole. Sadly, your arm is just too thick in order to reach that object you suspect to be a key. If only there was a hook or someting to fish it out..\n"}
  104. else { print"\nthis doesn't work\n"; goto FIVE}
  105.  
  106. SIX: print "_________\n
  107. ACTIONS: GO \n
  108. OBJECTS: SOUTH\n
  109. --------- \n";
  110. chomp ($action = <STDIN>);
  111. if ($action eq "GO SOUTH"){print "\nNow you are where you were tied to the floor and that weird lamp connected to those 2 flexible bare copper cables was connected to exploded due to what seemed to be overvoltage..\n";}
  112. else { print"\nthis doesn't work\n"; goto SIX}
  113.  
  114. SEVEN: print "_________\n
  115. ACTIONS: TAKE, TURN OFF \n
  116. OBJECTS: CABLES, SWITCH\n
  117. --------- \n";
  118. chomp ($action = <STDIN>);
  119. if ($action eq "TURN OFF SWITCH"){print "\nYes, it was a good decision to turn off that switch..\n"}
  120. elsif ($action eq "TAKE CABLES") {print "\nAs you touch the cables, 230 volts run through your body, leaving you dead. Game Over. Didn't they teach you not to mess around with electricyty? \n";
  121. goto STARTMENU;} else {print "this doesn't work \n"; goto SEVEN;}
  122.  
  123. print "You picked up the cables that seem like you could use as some kind of hook and head back to that hole..\n";
  124.  
  125. EIGHT: print "_________\n
  126. ACTIONS: USE \n
  127. OBJECTS: CABLES, HOLE\n
  128. --------- \n";
  129. chomp ($action = <STDIN>);
  130. if ($action eq "USE CABLES AND HOLE"){print "You obtained the key to open the locked door. You open the door to find youself in a well-lit room. You enter that room, but there are metal bars between you and the rest of the room. You notice a strange guy standing near
  131. to the bars that lock you down, facing away from you. There also is a kind of door that leads out of your cage, that of course requires keys to open. You notice a keychain hanging from the guys pocket. You try to talk to
  132. that guy but he just ignores you. You notice a table a couple feet away from your cell. On that table is a glass of water that the guys is drinking from every couple minutes. He doesn't seem to even look at the glass when he's
  133. drinking from it. Maybe he is blind or whatever. What a strange occasion.
  134. you notice that your bagpack feels pretty heavy. As you take a look inside it, you find what is causing this weight. You have a container full of heavy lead dust..\n";}
  135. else {print "this doesn't work"; goto EIGHT;}
  136.  
  137. NINE: print "_________\n
  138. ACTIONS: USE, SWALLOW \n
  139. OBJECTS: LEAD, GLASS\n
  140. --------- \n";
  141. chomp ($action = <STDIN>);
  142. if ($action eq "USE LEAD AND GLASS"){print "Tho you can't directly pour the dust into that glass because it's too far away to reach with your hands, you try to throw some dust into the glass. Luckily, a fair amount of dust particles actually land in the glass.
  143. A few moments later, the guy drinks from the glass again, of course not knowing that you messed with it. He doesn't even seem to notice that dust you added. A few minutes after drinking that water, the guy falls on the floor.
  144. You killed him via lead poisoning. You freaking genious. End of Demo :) GG. To be continued.. \n"}
  145. elsif ($action eq "SWALLOW LEAD") {print "For some reason, you decided to swallow this poisonous element. Several minutes later, you die due to lead poisoning. Congrats. \n"; goto STARTMENU;}
  146. else {print "\nthis doesn't work"; goto NINE}
  147.  
  148.  
  149. exit;
  150.  
  151. LOAD:
  152. print "load";
  153. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement