--- deliantra/server/ext/help.ext 2007/06/26 23:09:30 1.8 +++ deliantra/server/ext/help.ext 2010/05/14 22:56:47 1.17 @@ -2,6 +2,13 @@ our $TOPIC; +our $HELP_CHANNEL = { + id => "help", + title => "Help", + reply => "help ", + tooltip => "Online Help", +}; + sub load_topics($$) { my ($type, $path) = @_; @@ -12,7 +19,7 @@ my $level = 1e9; for my $par (@$paragraphs) { - Coro::cede; + cf::cede_to_tick; if ($par->{type} eq "head2") { if ($par->{markup} =~ /^(\S+)/) { push @topics, $1 => [$type => $par]; @@ -27,38 +34,29 @@ } sub reload() { + my $guard = cf::lock_acquire "ext::help::loading"; + + local $Coro::current->{desc} = "help loader"; + $TOPIC = { (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 { - reload; - undef $guard; - }; +cf::post_init { + cf::async_ext { reload }; }; -# 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->send_msg ($HELP_CHANNEL => "help files are being loaded currently, try again in a few seconds.", cf::NDI_REPLY | cf::NDI_CLEAR); return; } @@ -74,17 +72,17 @@ my $res; while (my ($k, $v) = each %topics) { - $res .= "B<$k:>\n" . (join " ", sort @$v) . "\n\n"; + $res .= "T<$k:>\n\n" . (join " ", sort @$v) . "\n\n"; } - $pl->reply (undef, $res); + $pl->send_msg ($HELP_CHANNEL => $res, cf::NDI_REPLY | cf::NDI_CLEAR); } elsif (my $item = $TOPIC->{$topic}) { my ($type, @pars) = @$item; - $pl->reply (undef, cf::pod::as_text \@pars); + $pl->send_msg ($HELP_CHANNEL => (cf::pod::as_cfpod \@pars), cf::NDI_REPLY | cf::NDI_CLEAR); } else { - $pl->reply (undef, "'$topic' no such help topic, try just 'help' to get a list of topics."); + $pl->send_msg ($HELP_CHANNEL => "'$topic' no such help topic, try just 'help' to get a list of topics.", cf::NDI_REPLY); } };