🧑💻 tellraw を出力ごとに別の色で出力できるような debug fn を追加#2237
Conversation
There was a problem hiding this comment.
Pull request overview
tellraw のデバッグ出力を、呼び出しごとに色を交互に変えて見やすくするための debug 関数を追加するPRです。
Changes:
debug:print_with_alternating_colors.mを新規追加し、ストレージ状態に応じてtellrawの色を切り替える
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $execute if data storage debug:print_with_alternating_colors {n:"odd" } run tellraw @a {"text":"","extra":$(Message),"color":"#FFFFFF"} | ||
| $execute if data storage debug:print_with_alternating_colors {n:"even"} run tellraw @a {"text":"","extra":$(Message),"color":"#C0C0C0"} |
There was a problem hiding this comment.
tellraw の JSON で extra は配列が必須ですが、ここでは extra:$(Message) になっていて Message が TextComponent オブジェクトの場合に JSON が不正になります(例: {...} がそのまま入る)。Message を 1 要素の配列に入れる形(または引数型を配列に統一)にして、常に有効な TextComponent になるよう修正してください。
| $execute if data storage debug:print_with_alternating_colors {n:"odd" } run tellraw @a {"text":"","extra":$(Message),"color":"#FFFFFF"} | |
| $execute if data storage debug:print_with_alternating_colors {n:"even"} run tellraw @a {"text":"","extra":$(Message),"color":"#C0C0C0"} | |
| $execute if data storage debug:print_with_alternating_colors {n:"odd" } run tellraw @a {"text":"","extra":[$(Message)],"color":"#FFFFFF"} | |
| $execute if data storage debug:print_with_alternating_colors {n:"even"} run tellraw @a {"text":"","extra":[$(Message)],"color":"#C0C0C0"} |
| # tellraw を出力ごとに別の色で出力します | ||
| # | ||
| # @input args | ||
| # Message: string (TextComponent) | TextComponent |
There was a problem hiding this comment.
@input args の型表記が、このコードベースでよく使われている string(TextComponent) 表記と異なり、string (TextComponent) | TextComponent になっています(例: TheSkyBlessing/data/api/functions/button/core/create_text_component.m.mcfunction:3)。表記を既存の形式に統一し、実際に受け付ける形式(TextComponent オブジェクト/配列/文字列)もコメントと実装で一致させてください。
| # Message: string (TextComponent) | TextComponent | |
| # Message: string(TextComponent) |
haiiro2gou
left a comment
There was a problem hiding this comment.
imo: String 型や Object 型も TextComponent として扱われるようなので解釈する部分を用意するか @input を改善するかしたほうが良さそう?
|
まぁ、言うても使うタイミングで中身見る気がするので、そこまで詳細にしなくてもいいかな感 |
|
じゃあいいか |
PR デバッグ中の副産物