I played some text based adventure games when I was a kid, and I want to re-create one of them and also in a re-imagined way .. Here is my very humble function to init the rooms .. It works now, is very minimum still.
sub initrooms
{
my (@ta, %things, $b, @ar, $t, $de, $ex, $th, @a);
open (RF, "rooms.txt")
or die "could not open datafile: $!";
$/ = undef;
$b = (<RF>);
$/ = "\n";
@ar = split /0/, $b;
foreach (@ar)
{
($t, $de, $ex, $th) = split ":", $_;
if ($th eq "")
{
next;
}
@ta = split "-", $th;
%things = @ta;
push @a, { TITLE => $t, TEXT => $de, EXITS => $ex, TH
+INGS => {%things} };
};
return \@a;
}
|