--- deliantra/server/ext/help.ext 2007/04/18 17:32:06 1.2 +++ deliantra/server/ext/help.ext 2007/09/19 21:56:30 1.10 @@ -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,26 +28,64 @@ 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"), }; } cf::sync_job { my $guard = cf::lock_acquire "ext::help::loading"; cf::async_ext { + $Coro::current->{desc} = "help loader"; reload; undef $guard; }; }; -cf::register_command xhelp => sub { +# for lack of a better place: "media tags" +# b bold +# i italic +# ul underlined +# fixed font +# arcane font +# hand font +# strange font +# print font (default) +# color=xxx + +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:>\n" . (join " ", sort @$v) . "\n\n"; + } + + $pl->reply (undef, $res); + + } elsif (my $item = $TOPIC->{$topic}) { + my ($type, @pars) = @$item; + $pl->reply (undef, cf::pod::as_cfpod \@pars); + + } else { + $pl->reply (undef, "'$topic' no such help topic, try just 'help' to get a list of topics."); + } }; +