Hello Perlmonks. A while ago I began work on a Multi User Dungeon, but since then I have decided to cut out the "Dungeon" elements and go with a purely survival theme.
#!/usr/bin/perl
use warnings;
if ($diff = easy){
$wood = 120;
}
elsif ($diff = hard){
$wood = 75;
}
if ($diff = easy){
$food = 50;
}
elsif ($diff = hard){
$food = 20;
}
$maxRNG = 6;
$RNG = rand($maxRNG);
NAME:
print "May I have your name please?\n";
chomp($name = <>);
print "Thank you $name.\n";
sleep 1;
system("clear");
goto DIFFICULTY;
DIFFICULTY:
print "Please enter a difficulty level: easy, or hard.\n";
chomp($diff = <>);
print "you chose $diff.\n";
sleep 1;
system("clear");
goto BEGIN;
BEGIN:
print "You have crash landed on a strange alien planet and must find a
+ way to get back to earth.\n";
goto PTURN;
PTURN:
print "\n";
print "You have $wood wood and $food food.\n";
print "You can:\n";
if($wood = 10){
print "BUILD a HUT with 10 wood\n";
}
As you can see I have set the amount of $wood to a selection in $diff. But this is not working. When I run it, I enter hard and it keeps the amount at 120. What am I doing wrong?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|