Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #《文字列操作関数群》
- # テキストを操作する関数です
- #【テキストから指定した範囲を抜き取る(開始と終了を指定する)】
- # substr(text,start,end)
- # 'text' (text型) 抜き取り元のテキスト
- # 'start' (integer型) 抜き取る範囲の最初
- # 'end' (integer型) 抜き取る範囲の最後
- # 返り値 (text型) 抜き取った結果のテキスト
- # ※'end' より 'start' が大きかった場合 'end'~'start' の範囲を抜き取ります
- function substr(text: text, start: integer, end: integer) :: text:
- set {_length} to {_end}-{_start}+1
- set {_cnt} to {_start}
- if {_start} >= {_end}:
- set {_length} to {_start}-{_end}+1
- set {_cnt} to {_end}
- set {_text::*} to split {_text} by ""
- set {_return} to ""
- loop {_length} times:
- set {_return} to "%{_return}%%{_text::%{_cnt}%}%"
- add 1 to {_cnt}
- return {_return}
- #【テキストから指定した範囲を抜き取る(開始と長さを指定する)】
- # substrl(text,start,length)
- # 'text' (text型) 抜き取り元のテキスト
- # 'start' (integer型) 抜き取る範囲の最初
- # 'length' (integer型) 抜き取る範囲の長さ(文字数)
- # 返り値 (text型) 抜き取った結果のテキスト
- # ※'length' がマイナスの場合 'start' を終点にして文字数分抜き取ります
- function substrl(text: text, start: integer, length: integer) :: text:
- set {_text::*} to split {_text} by ""
- set {_cnt} to {_start}
- if {_length} < 0:
- remove abs({_length})-1 from {_cnt}
- set {_return} to ""
- loop abs({_length}) times:
- set {_return} to "%{_return}%%{_text::%{_cnt}%}%"
- add 1 to {_cnt}
- return {_return}
- #【テキストから指定した文字(列)を検索する】
- # checkstr(text,check)
- # 'text' (text型) 検索元のテキスト
- # 'check' (text型) 検索する文字(列)
- # 返り値 (text型) 文字(列)のあった場所の番号 無かった場合には-1が返される
- # 複数あった場合はコロンで区切られる 例:"3,7"
- # 帰ってくるのはtext型なので注意(型を変換して使ってね)
- function checkstr(text: text, check: text) :: text:
- loop length of {_text} times:
- set {_len} to length of {_check}
- set {_len} to "%{_len}%" parsed as integer
- set {_ln} to loop-number
- set {_ln} to "%{_ln}%" parsed as integer
- set {_get} to substrl({_text},{_ln},{_len})
- {_get} is {_check}
- if {_return} is not set:
- set {_return} to loop-number
- else:
- set {_return} to "%{_return}%,%loop-number%"
- if {_return} is not set:
- set {_return} to "-1"
- return {_return}
- #《ホログラム関数群》
- # ホログラム(名前付き透明アマスタ)を管理する関数です
- # スコアボードタグ「lbfunc.holo.*」「lbfunc.invisible」を使用します
- # 変数 {lbfunc::holo::*} を使用します
- #【ホログラムを新規作成する】
- # holoCreate(id,location)
- # 'id' (text型) ホログラムの名前(ID)
- # 'location' (location型) ホログラムの座標
- # 返り値なし
- function holoCreate(id: text, location: location):
- set {lbfunc::holo::%{_id}%} to {_location}
- add {_id} to {lbfunc::holo.list::*}
- #【ホログラムに行を追加する】
- # holoLineAdd(id,text)
- # 'id' (text型) ホログラムの名前(ID)
- # 'text' (text型) 新しい行の内容
- # 返り値なし
- function holoLineAdd(id: text, text: text):
- {lbfunc::holo::%{_id}%} is set
- add {_text} to {lbfunc::holo::%{_id}%::*}
- add 1 to {lbfunc::holo::%{_id}%::q}
- holoDraw({_id})
- #【ホログラムの内容をリセットする】
- # holoLineReset(id)
- # 'id' (text型) ホログラムの名前(ID)
- # 返り値なし
- function holoLineReset(id: text):
- {lbfunc::holo::%{_id}%} is set
- holoUndraw({_id})
- clear {lbfunc::holo::%{_id}%::*}
- #【ホログラムを削除する】
- # HoloDelete(id)
- # 'id' (text型) ホログラムの名前(ID)
- # 返り値なし
- function holoDelete(id: text):
- {lbfunc::holo::%{_id}%} is set
- holoUndraw({_id})
- clear {lbfunc::holo::%{_id}%::*}
- clear {lbfunc::holo::%{_id}%}
- remove {_id} from {lbfunc::holo.list::*}
- #【ホログラムの表示をリロードする】
- # 他のホログラム関数で使用する関数です
- # 通常は実行する必要はありません
- function holoDraw(id: text):
- {lbfunc::holo::%{_id}%} is set
- loop {lbfunc::holo::%{_id}%::q} times:
- command "/tp @e[tag=lbfunc.holo.%{_id}%.%loop-number%] ~ -1000 ~"
- command "/kill @e[tag=lbfunc.holo.%{_id}%.%loop-number%]"
- set {_loc} to "%{lbfunc::holo::%{_id}%}%"
- set {_loc::*} to {_loc} split by ","
- replace "x: " in {_loc::1} with ""
- replace " y: " in {_loc::2} with ""
- set {_loc::2} to {_loc::2} parsed as number
- add 1 to {_cnt}
- set {_loc::2} to {_loc::2}-(1.5+{_cnt}*0.3)
- replace " z: " in {_loc::3} with ""
- set {_loc} to "%{_loc::1}% %{_loc::2}% %{_loc::3}%"
- command "summon armor_stand %{_loc}% {CustomName:""%coloured {lbfunc::holo::%{_id}%::%loop-number%}%"",CustomNameVisible:1b,Tags:[""lbfunc.holo.%{_id}%.%loop-number%"",""lbfunc.invisible""],Invulnerable:1b,PersistenceRequired:1b,Silent:1b,NoGravity:1b,Invisible:true}"
- #【ホログラムの表示を消す】
- # 他のホログラム関数で使用する関数です
- # 通常は実行する必要はありません
- function holoUndraw(id: text):
- loop {lbfunc::holo::%{_id}%::q} times:
- command "/tp @e[tag=lbfunc.holo.%{_id}%.%loop-number%] ~ -1000 ~"
- command "/kill @e[tag=lbfunc.holo.%{_id}%.%loop-number%]"
- #【ホログラム再描画】
- # 3秒ごとに再描画します
- every 3 second:
- loop {lbfunc::holo.list::*}:
- holoDraw(loop-value)
Add Comment
Please, Sign In to add comment