Explorar o código

feat(framework): 增加 user-online 事件

dzp %!s(int64=3) %!d(string=hai) anos
pai
achega
b6ecc6c171

+ 1 - 0
framework/main.tin

@@ -44,6 +44,7 @@ PaoTin++ © 2020~2022 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
     #%0 {
         log.Open;
         load-module lib/event;
+        event.Define {user-online} {无参} {framework} {已经登录到服务器,所有命令都可以正常使用了。};
         load-module lib/ui;
     };
 };

+ 2 - 5
framework/online.tin

@@ -34,11 +34,6 @@ PaoTin++ © 2020~2022 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
 #ticker {drink}     {xtt.Send drink $char[favorite][water]} {60};
 
 #delay 1 {
-    set table_pattern 1;
-    set area_detail 1;
-    set learn_emote 1;
-    set localmap 1;
-
     load-module basic/char;
     load-module shortcut;
     load-module silent;
@@ -48,6 +43,8 @@ PaoTin++ © 2020~2022 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 
 
     tmux.SetTheme GAME;
 
+    event.Emit user-online;
+
     #nop 提供给用户的自动执行函数;
     user-online;
 };

+ 4 - 0
mud/pkuxkx/plugins/basic/char/__init__.tin

@@ -8,3 +8,7 @@ load-module {basic/char/sachet};
 load-module {basic/char/score};
 load-module {basic/char/gmcp};
 load-module {basic/char/jifa};
+
+event.HandleOnce {user-online} {char/init} {basic/char} {
+    set table_pattern 1;
+};

+ 3 - 1
mud/pkuxkx/plugins/basic/char/score.tin

@@ -159,4 +159,6 @@ load-lib event;
 
 event.Define {char/score} {无参} {$MODULE} {score 命令的数据解析成功时,发送本事件}
 
-score;
+event.HandleOnce {user-online} {score/init} {basic/char} {
+    score;
+};

+ 20 - 18
mud/pkuxkx/plugins/lib/ui/chat.tin

@@ -99,8 +99,6 @@
     chat.log 私聊 {%0};
 } {9.999};
 
-set learn_emote 1;
-
 #action {^关闭所有频道。$} {
     #class chat-turn-on open;
     #gag {^你现在并没有打开任何频道。$};
@@ -113,19 +111,23 @@ set learn_emote 1;
     #line gag;
 };
 
-tune all;
-tune bd;
-tune chat;
-tune fb;
-tune group;
-tune helpme;
-tune jh;
-tune jy;
-tune mp;
-tune nation;
-tune qq;
-tune qy;
-tune rumor;
-tune rw;
-tune tt;
-tune;
+event.HandleOnce {user-online} {chat/init} {ui/chat} {
+    tune all;
+    tune bd;
+    tune chat;
+    tune fb;
+    tune group;
+    tune helpme;
+    tune jh;
+    tune jy;
+    tune mp;
+    tune nation;
+    tune qq;
+    tune qy;
+    tune rumor;
+    tune rw;
+    tune tt;
+    tune;
+
+    set learn_emote 1;
+};