… | |
… | |
13 | } |
13 | } |
14 | |
14 | |
15 | sub query { |
15 | sub query { |
16 | my ($ns, $flags, $text) = @_; |
16 | my ($ns, $flags, $text) = @_; |
17 | |
17 | |
18 | my $current = $Coro::current; |
18 | $ns->query ($flags, $text, Coro::rouse_cb); |
19 | $ns->query ($flags, $text, sub { $current->ready; $current = $_[0] }); |
19 | Coro::rouse_wait |
20 | Coro::schedule while ref $current; |
|
|
21 | |
|
|
22 | $current |
|
|
23 | } |
20 | } |
24 | |
21 | |
25 | sub can_cleanup { |
22 | sub can_cleanup { |
26 | my ($pl, $mtime) = @_; |
23 | my ($pl, $mtime) = @_; |
27 | |
24 | |
… | |
… | |
446 | }); |
443 | }); |
447 | |
444 | |
448 | cf::register_command quit => sub { |
445 | cf::register_command quit => sub { |
449 | my ($ob, $arg) = @_; |
446 | my ($ob, $arg) = @_; |
450 | |
447 | |
451 | $ob->reply (undef, |
448 | $ob->send_msg (undef, |
452 | "Quitting will delete your character PERMANENTLY: It will be gone forever and any progress will be lost. " |
449 | "Quitting will delete your character PERMANENTLY: It will be gone forever and any progress will be lost. " |
453 | . "If you are sure you want to do this, then use the quit_character command instead of quit.", |
450 | . "If you are sure you want to do this, then use the quit_character command instead of quit.", |
454 | cf::NDI_UNIQUE | cf::NDI_RED); |
451 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
455 | }; |
452 | }; |
456 | |
453 | |
457 | cf::register_command quit_character => sub { |
454 | cf::register_command quit_character => sub { |
458 | my ($ob, $arg) = @_; |
455 | my ($ob, $arg) = @_; |
459 | |
456 | |
460 | my $pl = $ob->contr; |
457 | my $pl = $ob->contr; |
461 | |
458 | |
462 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to PERMANENTLY delete your character and all associated data (y/n)?", sub { |
459 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to PERMANENTLY delete your character and all associated data (y/n)?", sub { |
463 | if ($_[0] !~ /^[yY]/) { |
460 | if ($_[0] !~ /^[yY]/) { |
464 | $ob->reply (undef, |
461 | $ob->send_msg (undef, "Ok, not not quitting then.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
465 | "Ok, not not quitting then.", |
|
|
466 | cf::NDI_UNIQUE | cf::NDI_RED); |
|
|
467 | } else { |
462 | } else { |
468 | $ob->reply (undef, |
463 | $ob->send_msg (undef, "Ok, quitting, hope to see you again.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
469 | "Ok, quitting, hope to see you again.", |
|
|
470 | cf::NDI_UNIQUE | cf::NDI_RED); |
|
|
471 | $pl->ns->flush; |
464 | $pl->ns->flush; |
472 | cf::async { $pl->quit_character }; |
465 | cf::async { $pl->quit_character }; |
473 | } |
466 | } |
474 | }); |
467 | }); |
475 | }; |
468 | }; |
… | |
… | |
488 | cf::async { $pl->save }; |
481 | cf::async { $pl->save }; |
489 | |
482 | |
490 | my $killer = cf::arch::get "killer_logout"; $pl->killer ($killer); $killer->destroy; |
483 | my $killer = cf::arch::get "killer_logout"; $pl->killer ($killer); $killer->destroy; |
491 | $ob->check_score; |
484 | $ob->check_score; |
492 | |
485 | |
493 | $ob->reply (undef, "In the future, you will wake up here when you die."); |
486 | $ob->send_msg ($cf::SAY_CHANNEL => "In the future, you will wake up here when you die.", cf::NDI_DEF | cf::NDI_REPLY); |
494 | |
487 | |
495 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { |
488 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { |
496 | if ($_[0] !~ /^[yY]/) { |
489 | if ($_[0] !~ /^[yY]/) { |
497 | $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1); |
490 | $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1); |
498 | $pl->deactivate; |
491 | $pl->deactivate; |