main.tin 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #nop vim: set filetype=tt:;
  2. /*
  3. 模块名称:框架主程序
  4. 模块说明:本文件属于框架代码的一部分,不建议修改。如有需求请在 GitHub 发 issue 或者 PR
  5. 版权声明:本文件属于 PaoTin++ 的一部分
  6. ===========
  7. PaoTin++ © 2020~2022 的所有版权均由担子炮(dzp <danzipao@gmail.com>) 享有并保留一切法律权利
  8. 你可以在遵照 GPLv3 协议的基础之上使用、修改及重新分发本程序。
  9. ===========
  10. */
  11. #class main open;
  12. #kill all;
  13. #event {PROGRAM START} {
  14. #if { "$user[id]" != "{[A-Za-z0-9]+}" } {
  15. #echo {<110>请参考使用文档指定用户正确的 user id。<070>};
  16. #return;
  17. };
  18. #if { "@InitLog{$user[id]}" != "true" } {
  19. #echo {<110>创建日志目录 $gLog[PATH]/$user[id] 时遇到错误。<070>};
  20. #echo {<130>请检查你的安装环境,或者参考使用手册重新安装本软件。<070>};
  21. #return;
  22. };
  23. load-module basic/login;
  24. auto-login;
  25. };
  26. #alias {auto-login} {
  27. login {$session} {$user} {
  28. load-file {framework/online.tin};
  29. };
  30. };
  31. #event {SESSION CREATED} {
  32. #%0 {
  33. log.Open;
  34. load-module lib/event;
  35. load-module lib/ui/prompt;
  36. load-module lib/ui/beautify;
  37. load-module lib/ui/tmux;
  38. };
  39. };
  40. #event {SESSION TIMED OUT} {
  41. #echo {%s} {<110>连接服务器超时,稍后自动重试。<070>};
  42. #gts #delay 3 auto-login;
  43. };
  44. #event {SESSION DISCONNECTED} {
  45. #if { "%0" == "$session[name]" } {
  46. #local reconnect {$session[reconnect]};
  47. #if { "$session[remote_maint]" == "true" } {
  48. #local reconnect {$session[reconnect_slow]};
  49. #var session[remote_maint] {false};
  50. };
  51. #if { "$reconnect" == "{|0}" } {
  52. #local reconnect 12;
  53. };
  54. #nop 断开连接后再次重连不要太频繁,以免服务器不高兴。;
  55. #echo {%s} {<110>连接已被服务器断开,$reconnect 秒后自动重连。<070>};
  56. #gts #delay {$reconnect} {
  57. #echo {%s} {<120>自动重连。<070>};
  58. auto-login;
  59. };
  60. };
  61. };
  62. #nop 优先加载 var/$file(玩家自定义文件),其次加载 mud/$file(MUDLIB 相关文件);
  63. #alias {load-file} {
  64. #local file {%1};
  65. #local output {};
  66. #script output {test -f var/$file && echo true || echo false};
  67. #if { "$output[1]" == "true" } {
  68. #read var/$file;
  69. #return;
  70. };
  71. #if { "$gCurrentMUDLIB" != "" } {
  72. #local output {};
  73. #script output {test -f mud/$gCurrentMUDLIB/$file && echo true || echo false};
  74. #if { "$output[1]" == "true" } {
  75. #read mud/$gCurrentMUDLIB/$file;
  76. #return;
  77. };
  78. };
  79. #read $file;
  80. };
  81. #alias {init} {
  82. #nop 调整 tintin 环境;
  83. load-file framework/settings.tin;
  84. #nop 框架依赖的基本函数;
  85. load-file framework/utils.tin;
  86. #nop 日志支持;
  87. load-file framework/log.tin;
  88. #nop 为 TinTin 赋能,实现模块加载器;
  89. load-file framework/module-loader.tin;
  90. #nop 支持不同的 MUD 服务器环境;
  91. load-file framework/multi-mud.tin;
  92. #nop 为 TinTin 赋能,自行实现的扩展语法和实用函数集。;
  93. load-lib xtintin;
  94. #nop 提供 TinTin++ 命令行自动补全功能。;
  95. load-lib tab-completion;
  96. #nop 默认的用户环境配置;
  97. load-file ids/DEFAULT;
  98. };
  99. init;
  100. #class main close;