7mm

【Skript】Malb's Func Collection v3

7mm
Mar 17th, 2019
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. #《文字列操作関数群》
  2. # テキストを操作する関数です
  3.  
  4. #【テキストから指定した範囲を抜き取る(開始と終了を指定する)】
  5. # substr(text,start,end)
  6. # 'text' (text型) 抜き取り元のテキスト
  7. # 'start' (integer型) 抜き取る範囲の最初
  8. # 'end' (integer型) 抜き取る範囲の最後
  9. # 返り値 (text型) 抜き取った結果のテキスト
  10. # ※'end' より 'start' が大きかった場合 'end'~'start' の範囲を抜き取ります
  11.  
  12. function substr(text: text, start: integer, end: integer) :: text:
  13. set {_length} to {_end}-{_start}+1
  14. set {_cnt} to {_start}
  15. if {_start} >= {_end}:
  16. set {_length} to {_start}-{_end}+1
  17. set {_cnt} to {_end}
  18. set {_text::*} to split {_text} by ""
  19. set {_return} to ""
  20. loop {_length} times:
  21. set {_return} to "%{_return}%%{_text::%{_cnt}%}%"
  22. add 1 to {_cnt}
  23. return {_return}
  24.  
  25. #【テキストから指定した範囲を抜き取る(開始と長さを指定する)】
  26. # substrl(text,start,length)
  27. # 'text' (text型) 抜き取り元のテキスト
  28. # 'start' (integer型) 抜き取る範囲の最初
  29. # 'length' (integer型) 抜き取る範囲の長さ(文字数)
  30. # 返り値 (text型) 抜き取った結果のテキスト
  31. # ※'length' がマイナスの場合 'start' を終点にして文字数分抜き取ります
  32.  
  33. function substrl(text: text, start: integer, length: integer) :: text:
  34. set {_text::*} to split {_text} by ""
  35. set {_cnt} to {_start}
  36. if {_length} < 0:
  37. remove abs({_length})-1 from {_cnt}
  38. set {_return} to ""
  39. loop abs({_length}) times:
  40. set {_return} to "%{_return}%%{_text::%{_cnt}%}%"
  41. add 1 to {_cnt}
  42. return {_return}
  43.  
  44. #【テキストから指定した文字(列)を検索する】
  45. # checkstr(text,check)
  46. # 'text' (text型) 検索元のテキスト
  47. # 'check' (text型) 検索する文字(列)
  48. # 返り値 (text型) 文字(列)のあった場所の番号 無かった場合には-1が返される
  49. # 複数あった場合はコロンで区切られる 例:"3,7"
  50. # 帰ってくるのはtext型なので注意(型を変換して使ってね)
  51.  
  52. function checkstr(text: text, check: text) :: text:
  53. loop length of {_text} times:
  54. set {_len} to length of {_check}
  55. set {_len} to "%{_len}%" parsed as integer
  56. set {_ln} to loop-number
  57. set {_ln} to "%{_ln}%" parsed as integer
  58. set {_get} to substrl({_text},{_ln},{_len})
  59. {_get} is {_check}
  60. if {_return} is not set:
  61. set {_return} to loop-number
  62. else:
  63. set {_return} to "%{_return}%,%loop-number%"
  64. if {_return} is not set:
  65. set {_return} to "-1"
  66. return {_return}
  67.  
  68. #《ホログラム関数群》
  69. # ホログラム(名前付き透明アマスタ)を管理する関数です
  70. # スコアボードタグ「lbfunc.holo.*」「lbfunc.invisible」を使用します
  71. # 変数 {lbfunc::holo::*} を使用します
  72.  
  73. #【ホログラムを新規作成する】
  74. # holoCreate(id,location)
  75. # 'id' (text型) ホログラムの名前(ID)
  76. # 'location' (location型) ホログラムの座標
  77. # 返り値なし
  78.  
  79. function holoCreate(id: text, location: location):
  80. set {lbfunc::holo::%{_id}%} to {_location}
  81. add {_id} to {lbfunc::holo.list::*}
  82.  
  83. #【ホログラムに行を追加する】
  84. # holoLineAdd(id,text)
  85. # 'id' (text型) ホログラムの名前(ID)
  86. # 'text' (text型) 新しい行の内容
  87. # 返り値なし
  88.  
  89. function holoLineAdd(id: text, text: text):
  90. {lbfunc::holo::%{_id}%} is set
  91. add {_text} to {lbfunc::holo::%{_id}%::*}
  92. add 1 to {lbfunc::holo::%{_id}%::q}
  93. holoDraw({_id})
  94.  
  95. #【ホログラムの内容をリセットする】
  96. # holoLineReset(id)
  97. # 'id' (text型) ホログラムの名前(ID)
  98. # 返り値なし
  99.  
  100. function holoLineReset(id: text):
  101. {lbfunc::holo::%{_id}%} is set
  102. holoUndraw({_id})
  103. clear {lbfunc::holo::%{_id}%::*}
  104.  
  105. #【ホログラムを削除する】
  106. # HoloDelete(id)
  107. # 'id' (text型) ホログラムの名前(ID)
  108. # 返り値なし
  109.  
  110. function holoDelete(id: text):
  111. {lbfunc::holo::%{_id}%} is set
  112. holoUndraw({_id})
  113. clear {lbfunc::holo::%{_id}%::*}
  114. clear {lbfunc::holo::%{_id}%}
  115. remove {_id} from {lbfunc::holo.list::*}
  116.  
  117. #【ホログラムの表示をリロードする】
  118. # 他のホログラム関数で使用する関数です
  119. # 通常は実行する必要はありません
  120.  
  121. function holoDraw(id: text):
  122. {lbfunc::holo::%{_id}%} is set
  123. loop {lbfunc::holo::%{_id}%::q} times:
  124. command "/tp @e[tag=lbfunc.holo.%{_id}%.%loop-number%] ~ -1000 ~"
  125. command "/kill @e[tag=lbfunc.holo.%{_id}%.%loop-number%]"
  126. set {_loc} to "%{lbfunc::holo::%{_id}%}%"
  127. set {_loc::*} to {_loc} split by ","
  128. replace "x: " in {_loc::1} with ""
  129. replace " y: " in {_loc::2} with ""
  130. set {_loc::2} to {_loc::2} parsed as number
  131. add 1 to {_cnt}
  132. set {_loc::2} to {_loc::2}-(1.5+{_cnt}*0.3)
  133. replace " z: " in {_loc::3} with ""
  134. set {_loc} to "%{_loc::1}% %{_loc::2}% %{_loc::3}%"
  135. 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}"
  136.  
  137. #【ホログラムの表示を消す】
  138. # 他のホログラム関数で使用する関数です
  139. # 通常は実行する必要はありません
  140.  
  141. function holoUndraw(id: text):
  142. loop {lbfunc::holo::%{_id}%::q} times:
  143. command "/tp @e[tag=lbfunc.holo.%{_id}%.%loop-number%] ~ -1000 ~"
  144. command "/kill @e[tag=lbfunc.holo.%{_id}%.%loop-number%]"
  145.  
  146. #【ホログラム再描画】
  147. # 3秒ごとに再描画します
  148.  
  149. every 3 second:
  150. loop {lbfunc::holo.list::*}:
  151. holoDraw(loop-value)
Add Comment
Please, Sign In to add comment