--- deliantra/server/ext/help.ext 2007/04/18 17:32:06 1.2 +++ deliantra/server/ext/help.ext 2007/04/19 21:54:41 1.4 @@ -2,8 +2,8 @@ our $TOPIC; -sub load_topics($) { - my ($path) = @_; +sub load_topics($$) { + my ($type, $path) = @_; my $paragraphs = cf::pod::load_pod "$PODDIR/$path.pod" or die "unable to load $path"; @@ -15,7 +15,7 @@ Coro::cede; if ($par->{type} eq "head2") { if ($par->{markup} =~ /^(\S+)/) { - push @topics, $1 => [$par]; + push @topics, $1 => [$type => $par]; $level = $par->{level}; } } elsif ($par->{level} > $level) { @@ -28,10 +28,10 @@ sub reload() { $TOPIC = { - load_topics "dmcommand_help", - load_topics "emote_help", - load_topics "command_help", - load_topics "generic_help", + (load_topics "DM Commands" => "dmcommand_help"), + (load_topics "Emotes" => "emote_help"), + (load_topics "Commands" => "command_help"), + (load_topics "Generic Help Topics" => "generic_help"), }; } @@ -43,11 +43,37 @@ }; }; -cf::register_command xhelp => sub { +cf::register_command help => sub { my ($pl, $topic) = @_; if (cf::lock_active "ext::help::loading") { - $pl->reply (undef, "help files are being loaded currently, try again in a few seconds"); + $pl->reply (undef, "help files are being loaded currently, try again in a few seconds."); return; } + + $topic = $1 if $topic =~ /(\S+)/; + + if (!length $topic) { + # sort.. + + my %topics; + while (my ($k, $v) = each %$TOPIC) { + push @{$topics{$v->[0]}}, $k; + } + + my $res; + while (my ($k, $v) = each %topics) { + $res .= "[b]$k:[/b]\n" . (sort join " ", @$v) . "\n\n"; + } + + $pl->reply (undef, $res); + + } elsif (my $topic = $TOPIC->{$topic}) { + my ($type, @pars) = @$topic; + $pl->reply (undef, cf::pod::as_text \@pars); + + } else { + $pl->reply (undef, "'$topic' no such help topic, try just 'help' to get a list of topics."); + } }; +