ブロック名を取得したい

初歩的な質問ですみません。 type of block で stone block のようなブロック名が取得できるのですが、 stone のような形式で取得する方法はありますか? (文字列の操作でblockを削除するとかはなしで)
16 Replies
mirageeeeeeeeeeeeeeeeeeeeeeeeeee
aliasesってことですか?
ゆきあ
ゆきあ2mo ago
minecraft:stone の stone の部分のみ取得したいです。 type of block で石ブロックから取得しようとすると stone block になるので、他のブロックも一律に stone の部分がほしいんです。
gladiolus8789
gladiolus87892mo ago
raw name of block ?
ゆきあ
ゆきあ2mo ago
send "%raw name of tool of player%" to player
で、minecraft:golden_pickaxeを取得できました。
gladiolus8789
gladiolus87892mo ago
そこからminecraft:の部分消したら大丈夫そう?
ゆきあ
ゆきあ2mo ago
そうですね、これは文字列操作のほうが良さそうでしょうか。 んーむずかしい
gladiolus8789
gladiolus87892mo ago
command /test:
trigger:
set {_a} to "minecraft:stone"
set {_b} to length of {_a}
set {_c} to subtext of {_a} from 1 to 10
set {_d} to subtext of {_a} from 11 to {_b}
send "アイテムID > %{_a}%"
send "文字列の長さ > %{_b}%"
send "先頭の文字列 > %{_c}%"
send "欲しい文字列 > %{_d}%"
command /test:
trigger:
set {_a} to "minecraft:stone"
set {_b} to length of {_a}
set {_c} to subtext of {_a} from 1 to 10
set {_d} to subtext of {_a} from 11 to {_b}
send "アイテムID > %{_a}%"
send "文字列の長さ > %{_b}%"
send "先頭の文字列 > %{_c}%"
send "欲しい文字列 > %{_d}%"
これでどうでしょうか
ゆきあ
ゆきあ2mo ago
なるほど、文字数で指定するんですね。
gladiolus8789
gladiolus87892mo ago
その通りです もっとスマートなやり方はあるかもですが、ひとまず思い付いたのは上のやつです
ゆきあ
ゆきあ2mo ago
ありがとうございます!参考になります!
soramame_256
soramame_2562mo ago
split で:使うのが一番良さそう? 正直sponge環境でmod入れない限りsubtextでとったほうが楽だろうけど
ゆきあ
ゆきあ2mo ago
splitは使い方わからなくて・・・アドバイスありがとうございます。
soramame_256
soramame_2562mo ago
split %文字列% at %分割文字% set {_a::*} to split raw name of tool at ":" send {_a::2}
mirageeeeeeeeeeeeeeeeeeeeeeeeeee
splitは、文字列を指定した文字のところで分割する構文です 分割後は複数の文字列になるため、リスト変数に代入してindexを1, 2, 3...で指定することで取得できます
ゆきあ
ゆきあ2mo ago
参考にしてやってみます。ありがとうございます!!
Want results from more Discord servers?
Add your server