1+ function shortId ( id ) {
2+ if ( ! id ) return '' ;
3+ const s = String ( id ) ;
4+ return ` #${ s . slice ( - 4 ) } ` ;
5+ }
6+
17function stringifyResult ( value ) {
28 return JSON . stringify ( value , null , 2 ) ;
39}
@@ -53,7 +59,7 @@ function formatLook(result) {
5359
5460 info += '👥 【附近的人】\n' ;
5561 nearby . forEach ( ( person ) => {
56- info += `- ${ person . name } 距离你 ${ person . distance } 步 (位于 ${ person . zone } )` ;
62+ info += `- ${ person . name } ${ shortId ( person . id ) } 距离你 ${ person . distance } 步 (位于 ${ person . zone } )` ;
5763 if ( person . relativeDirection ) info += `,在你的${ person . relativeDirection } ` ;
5864 if ( person . message ) info += `,他正在说: "${ person . message } "` ;
5965 else if ( person . lastSpeakAt ) info += `,最近说过话` ;
@@ -85,7 +91,7 @@ function formatChat(messages, selfText) {
8591 for ( const msg of messages ) {
8692 const t = new Date ( msg . time ) ;
8793 const ts = `${ String ( t . getHours ( ) ) . padStart ( 2 , '0' ) } :${ String ( t . getMinutes ( ) ) . padStart ( 2 , '0' ) } ` ;
88- info += `[${ ts } ] ${ msg . name } : ${ msg . message } \n` ;
94+ info += `[${ ts } ] ${ msg . name } ${ shortId ( msg . playerId ) } : ${ msg . message } \n` ;
8995 }
9096 return info . trimEnd ( ) ;
9197}
@@ -105,16 +111,17 @@ function formatPerceptions(perceptions) {
105111 for ( const event of perceptions ) {
106112 const icon = typeLabels [ event . type ] || '•' ;
107113 const attentionBar = event . attention >= 0.7 ? '⚡' : event . attention >= 0.4 ? '●' : '○' ;
114+ const tag = shortId ( event . fromId ) ;
108115 if ( event . type === 'chat' ) {
109- info += `${ attentionBar } ${ icon } ${ event . from } 说: "${ event . text } " (距离 ${ event . distance } 步)\n` ;
116+ info += `${ attentionBar } ${ icon } ${ event . from } ${ tag } 说: "${ event . text } " (距离 ${ event . distance } 步)\n` ;
110117 } else if ( event . type === 'interact' ) {
111- info += `${ attentionBar } ${ icon } ${ event . from } 在${ event . zone } 进行了: ${ event . action } (距离 ${ event . distance } 步)\n` ;
118+ info += `${ attentionBar } ${ icon } ${ event . from } ${ tag } 在${ event . zone } 进行了: ${ event . action } (距离 ${ event . distance } 步)\n` ;
112119 } else if ( event . type === 'move' ) {
113- info += `${ attentionBar } ${ icon } ${ event . from } 移动到了${ event . zone } (距离 ${ event . distance } 步)\n` ;
120+ info += `${ attentionBar } ${ icon } ${ event . from } ${ tag } 移动到了${ event . zone } (距离 ${ event . distance } 步)\n` ;
114121 } else if ( event . type === 'join' ) {
115- info += `${ attentionBar } ${ icon } ${ event . from } 加入了小镇\n` ;
122+ info += `${ attentionBar } ${ icon } ${ event . from } ${ tag } 加入了小镇\n` ;
116123 } else if ( event . type === 'leave' ) {
117- info += `${ attentionBar } ${ icon } ${ event . from } 离开了小镇\n` ;
124+ info += `${ attentionBar } ${ icon } ${ event . from } ${ tag } 离开了小镇\n` ;
118125 }
119126 }
120127 return info . trimEnd ( ) ;
0 commit comments