Mirage-Skripter

CustomRecipe & RecipeUnlocker

Sep 25th, 2020 (edited)
478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.40 KB | None | 0 0
  1. on script load:
  2. reloadRecipes()
  3.  
  4. command /recipemaker:
  5. permission: skript.admin
  6. trigger:
  7. openRecipeMakerMenu(player)
  8.  
  9. command /recipes:
  10. permission: skript.admin
  11. trigger:
  12. openRecipesListMenu(player)
  13.  
  14. command /officialRecipe [<text>]:
  15. permission: skript.admin
  16. trigger:
  17. if player's tool is not set:
  18. send "&c&l操作したいアイテムを手に持ってください。"
  19. stop
  20. if arg-1 is not "add" or "remove":
  21. send "&c&ladd &7or &c&lremove"
  22. stop
  23. if arg-1 is "add":
  24. if {officialRecipe::*} contains "%id of player's tool%":
  25. send "&c&lそのアイテムは既に追加されています。"
  26. stop
  27. add "%id of player's tool%" to {officialRecipe::*}
  28. send "&a&l%player's tool%&7を追加しました!"
  29. stop
  30. if {officialRecipe::*} doesn't contain "%id of player's tool%":
  31. send "&c&lそのアイテムは追加されていません。"
  32. stop
  33. remove "%id of player's tool%" from {officialRecipe::*}
  34. send "&a&l%player's tool%&7を削除しました!"
  35.  
  36. on craft:
  37. if name of event-item contains "&d&lレシピペーパー":
  38. slot 5 of player's current inventory is air
  39. send "&c&lこのアイテムは作成できません。"
  40. cancel event
  41. else:
  42. {officialRecipe::*} doesn't contain "%id of event-item%"
  43. {unlockedRecipe::%player's uuid%::*} doesn't contain "%id of event-item%"
  44. cancel event
  45. send "&c&l未開放のアイテムのため作成できません。"
  46.  
  47. on right click with paper:
  48. name of player's tool starts with "&d&lレシピペーパー"
  49. cancel event
  50. set {_string} to uncoloured name of player's tool
  51. set {_length} to length of {_string}
  52. set {_item} to last {_length} - 8 character of {_string}
  53. loop all items:
  54. "%type of loop-item%" is {_item}
  55. set {_item} to loop-item
  56. set {_id} to id of loop-item
  57. exit loop
  58. add "%{_id}%" to {unlockedRecipe::%player's uuid%::*}
  59. send "&b&l%{_item}%&7のレシピを開放しました!"
  60. remove 1 of player's tool from player's inventory
  61.  
  62. on inventory click: #Toggle (shaped | shapeless) mode
  63. name of event-inventory is "&a&lRecipe &e&lMaker"
  64. clicked slot is 41
  65. cancel event
  66. if clicked item is lime wool block:
  67. itemPutter(red wool named "&c素材の並びを限定しない", 41, 1, 1, player, false)
  68. else:
  69. itemPutter(lime wool named "&a素材の並びを限定する", 41, 1, 1, player, false)
  70.  
  71. on inventory click: #Show item recipe
  72. name of event-inventory is "&a&lRecipes &e&lList"
  73. slot (clicked slot) of player's current inventory is not air
  74. clicked type is not right mouse button with shift
  75. cancel event
  76. close player's inventory
  77. wait 3 tick
  78. set {_slot} to clicked slot
  79. add 1 to {_slot}
  80. if {customRecipe::%{_slot}%::shaped::product} is set:
  81. set {_item} to {customRecipe::%{_slot}%::shaped::product}
  82. else:
  83. set {_item} to {customRecipe::%{_slot}%::shapeless::product}
  84. if name of {_item} is set:
  85. set {_item} to name of {_item}
  86. else:
  87. set {_item} to "%type of {_item}%"
  88. openRecipeMaterialMenu(player, {_item}, {_slot})
  89.  
  90. on inventory click: #Remove item recipe
  91. name of event-inventory is "&a&lRecipes &e&lList"
  92. clicked type is right mouse button with shift
  93. slot (clicked slot) of player's current inventory is not air
  94. cancel event
  95. set {_slot} to clicked slot
  96. add 1 to {_slot}
  97. delete {customRecipe::%{_slot}%::shaped::product}
  98. delete {customRecipe::%{_slot}%::shapeless::product}
  99. loop 9 times:
  100. delete {customRecipe::%{_slot}%::material::%loop-number%}
  101. delete {customRecipe::%{_slot}%}
  102. set slot (clicked slot) of player's current inventory to air
  103. reloadRecipes()
  104. send "&c&lレシピを消去しました。 &7反映させるにはサーバーを再起動してください。"
  105.  
  106. on inventory click: #Listener of recipe maker
  107. name of event-inventory is "&a&lRecipe &e&lMaker"
  108. clicked slot is 44
  109. cancel event
  110. if slot 25 of player's current inventory is air:
  111. send "&cレシピにより作成されるアイテムを右のスロットに置いてください。"
  112. stop
  113. else:
  114. slot 10 of player's current inventory is air
  115. slot 11 of player's current inventory is air
  116. slot 12 of player's current inventory is air
  117. slot 19 of player's current inventory is air
  118. slot 20 of player's current inventory is air
  119. slot 21 of player's current inventory is air
  120. slot 28 of player's current inventory is air
  121. slot 29 of player's current inventory is air
  122. slot 30 of player's current inventory is air
  123. send "&c最低一つは素材を指定してください。"
  124. stop
  125. set {_item1} to slot 10 of player's current inventory
  126. set {_item2} to slot 11 of player's current inventory
  127. set {_item3} to slot 12 of player's current inventory
  128. set {_item4} to slot 19 of player's current inventory
  129. set {_item5} to slot 20 of player's current inventory
  130. set {_item6} to slot 21 of player's current inventory
  131. set {_item7} to slot 28 of player's current inventory
  132. set {_item8} to slot 29 of player's current inventory
  133. set {_item9} to slot 30 of player's current inventory
  134. set {_recipeFor} to slot 25 of player's current inventory
  135. set {_indexSize} to size of indexes of {customRecipe::*}
  136. add 1 to {_indexSize}
  137. if type of slot 41 of player's current inventory is lime wool block:
  138. set {customRecipe::%{_indexSize}%::shaped::product} to {_recipeFor}
  139. register new shaped recipe for {_recipeFor} using {_item1}, {_item2}, {_item3}, {_item4}, {_item5}, {_item6}, {_item7}, {_item8}, {_item9}
  140. else:
  141. set {customRecipe::%{_indexSize}%::shapeless::product} to {_recipeFor}
  142. register new shapeless recipe for {_recipeFor} using {_item1}, {_item2}, {_item3}, {_item4}, {_item5}, {_item6}, {_item7}, {_item8}, {_item9}
  143. loop 9 times:
  144. set {customRecipe::%{_indexSize}%::material::%loop-number%} to {_item%loop-number%}
  145. send "&a新たなレシピを登録しました。"
  146.  
  147. function openRecipeMakerMenu(player: player):
  148. set {_player} to {_player}
  149. open chest with 5 rows named "&a&lRecipe &e&lMaker" to {_player}
  150. wait 1 tick
  151. itemPutter(white glass pane, 0, 1, 5, {_player}, true)
  152. itemPutter(white glass pane, 9, 9, 3, {_player}, true)
  153. itemPutter(white glass pane, 13, 9, 3, {_player}, true)
  154. itemPutter(white glass pane, 36, 1, 5, {_player}, true)
  155. itemPutter(white glass pane, 15, 1, 3, {_player}, true)
  156. itemPutter(white glass pane, 24, 0, 1, {_player}, true)
  157. itemPutter(white glass pane, 26, 0, 1, {_player}, true)
  158. itemPutter(white glass pane, 33, 1, 3, {_player}, true)
  159. itemPutter(lime wool named "&a素材の並びを限定する", 41, 1, 1, {_player}, false)
  160. itemPutter(workbench named "&6&lレシピを登録する", 44, 1, 1, {_player}, false)
  161. itemPutter(gray glass pane, 5, 1, 4, {_player}, true)
  162. itemPutter(gray glass pane, 14, 9, 3, {_player}, true)
  163. itemPutter(gray glass pane, 42, 1, 2, {_player}, true)
  164.  
  165. function reloadRecipes():
  166. loop indexes of {customRecipe::*}:
  167. loop 9 times:
  168. if "%{customRecipe::%loop-value-1%::material::%loop-number%}%" is "0 air":
  169. set {_material::%loop-number%} to air
  170. else:
  171. set {_material::%loop-number%} to {customRecipe::%loop-value-1%::material::%loop-number%}
  172. if "%indexes of {customRecipe::%loop-value%::*}%" contains "shaped":
  173. register new shaped recipe for {customRecipe::%loop-value%::shaped::product} parsed as item using {_material::1}, {_material::2}, {_material::3}, {_material::4}, {_material::5}, {_material::6}, {_material::7}, {_material::8}, {_material::9}
  174. else:
  175. register new shapeless recipe for {customRecipe::%loop-value%::shapeless::product} parsed as item using {_material::1}, {_material::2}, {_material::3}, {_material::4}, {_material::5}, {_material::6}, {_material::7}, {_material::8}, {_material::9}
  176. loop all items:
  177. register new shaped recipe for paper named "&d&lレシピペーパー &3%loop-value%" using paper, paper, paper, paper, type of loop-item, paper, paper, paper, paper
  178.  
  179. function openRecipesListMenu(player: player):
  180. set {_player} to {_player}
  181. open chest with 6 rows named "&a&lRecipes &e&lList" to {_player}
  182. wait 1 tick
  183. loop indexes of {customRecipe::*}:
  184. if {customRecipe::%loop-value%::shaped::product} is set:
  185. set {_item} to {customRecipe::%loop-value%::shaped::product}
  186. else:
  187. set {_item} to {customRecipe::%loop-value%::shapeless::product}
  188. set {_int} to (loop-value parsed as integer) - 1
  189. set lore of {_item} to "" and "&7レシピを消去する &8--- &c&lShif + 右クリック"
  190. itemPutter({_item}, {_int}, 1, 1, {_player}, false)
  191.  
  192. function openRecipeMaterialMenu(player: player, title :text, index: integer):
  193. set {_player} to {_player}
  194. open chest with 5 rows named "&b%{_title}%" to {_player}
  195. wait 1 tick
  196. itemPutter(white glass pane, 0, 1, 5, {_player}, true)
  197. itemPutter(white glass pane, 9, 9, 3, {_player}, true)
  198. itemPutter(white glass pane, 13, 9, 3, {_player}, true)
  199. itemPutter(white glass pane, 36, 1, 5, {_player}, true)
  200. itemPutter(white glass pane, 15, 1, 3, {_player}, true)
  201. itemPutter(white glass pane, 24, 0, 1, {_player}, true)
  202. itemPutter(white glass pane, 26, 0, 1, {_player}, true)
  203. itemPutter(white glass pane, 33, 1, 3, {_player}, true)
  204. itemPutter(gray glass pane, 5, 1, 4, {_player}, true)
  205. itemPutter(gray glass pane, 14, 9, 3, {_player}, true)
  206. itemPutter(gray glass pane, 41, 1, 4, {_player}, true)
  207. if {customRecipe::%{_index}%::shaped::product} is set:
  208. set {_item} to {customRecipe::%{_index}%::shaped::product}
  209. else:
  210. set {_item} to {customRecipe::%{_index}%::shapeless::product}
  211. itemPutter({_item}, 25, 1, 1, {_player}, true)
  212. itemPutter({customRecipe::%{_index}%::material::1}, 10, 1, 1, {_player}, true)
  213. itemPutter({customRecipe::%{_index}%::material::2}, 11, 1, 1, {_player}, true)
  214. itemPutter({customRecipe::%{_index}%::material::3}, 12, 1, 1, {_player}, true)
  215. itemPutter({customRecipe::%{_index}%::material::4}, 19, 1, 1, {_player}, true)
  216. itemPutter({customRecipe::%{_index}%::material::5}, 20, 1, 1, {_player}, true)
  217. itemPutter({customRecipe::%{_index}%::material::6}, 21, 1, 1, {_player}, true)
  218. itemPutter({customRecipe::%{_index}%::material::7}, 28, 1, 1, {_player}, true)
  219. itemPutter({customRecipe::%{_index}%::material::8}, 29, 1, 1, {_player}, true)
  220. itemPutter({customRecipe::%{_index}%::material::9}, 30, 1, 1, {_player}, true)
  221.  
  222. function itemPutter(item: item, start: integer, interval: integer, time: integer, player: player, unstealable: boolean):
  223. loop {_time} times:
  224. if {_unstealable} is true:
  225. format slot {_start} of {_player} with {_item} to be unstealable
  226. else:
  227. set slot {_start} of {_player}'s current inventory to {_item}
  228. add {_interval} to {_start}
Advertisement
Add Comment
Please, Sign In to add comment