Zeldaboy111

Mine Functie {4/4} ]|[ Skript #325

Jul 3rd, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.25 KB | None | 0 0
  1. #GUI when clicking on it
  2. function checkQuarry(p: Player, loc: Location) :: boolean:
  3. set {_below} to block 1 meters below {_loc}
  4. if block at {_below} is not dropper:
  5. return false
  6. set {_detected} to false
  7. if block at location 1 meters north of {_below} is hopper:
  8. if block at location 1 meters south of {_below} is chest:
  9. if block at location 2 meters south of {_below} is chest:
  10. set {_detected} to true
  11. set {quarry.chestDetect.%{_loc}%} to south
  12. else if block at location 1 meters east of {_below} is hopper:
  13. if block at location 1 meters west of {_below} is chest:
  14. if block at location 2 meters west of {_below} is chest:
  15. set {_detected} to true
  16. set {quarry.chestDetect.%{_loc}%} to west
  17. else if block at location 1 meters south of {_below} is hopper:
  18. if block at location 1 meters north of {_below} is chest:
  19. if block at location 2 meters north of {_below} is chest:
  20. set {_detected} to true
  21. set {quarry.chestDetect.%{_loc}%} to north
  22. else if block at location 1 meters west of {_below} is hopper:
  23. if block at location 1 meters east of {_below} is chest:
  24. if block at location 2 meters east of {_below} is chest:
  25. set {_detected} to true
  26. set {quarry.chestDetect.%{_loc}%} to east
  27.  
  28. return {_detected}
  29.  
  30. function quarryGUI(p: Player, loc: Location):
  31. set {quarry.open.%{_p}%} to {_loc}
  32. open chest with 5 rows named "Quarry" to {_p}
  33. wait 2 ticks
  34. set {_count} to 45
  35. loop 9 times:
  36. set slot loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  37. set slot {_count} - loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  38.  
  39. loop 4 times:
  40. set slot 9*loop-value of {_p}'s current inventory to gray stained glass pane named "&8"
  41. set slot 9*loop-value - 1 of {_p}'s current inventory to gray stained glass pane named "&8"
  42.  
  43. #RESET SLOT
  44.  
  45. if {quarry.list.%{_loc}%.enabled} is true:
  46. set slot 21 of {_p}'s current inventory to lime shulker box named "&aEnabled"
  47. set slot 23 of {_p}'s current inventory to red shulker box named "&cDisable"
  48. else:
  49. set slot 21 of {_p}'s current inventory to lime shulker box named "&aEnable"
  50. set slot 23 of {_p}'s current inventory to red shulker box named "&cDisabled"
  51.  
  52. function mine(loc: Location, startLoc: Location):
  53. set {_mine} to true
  54. set {_chest} to block at {quarry.chest.%{_loc}%}
  55. if {quarry.row.%{_loc}%} is not set:
  56. set {quarry.row.%{_loc}%} to 0
  57. if {quarry.colmn.%{_loc}%} is not set:
  58. set {quarry.colmn.%{_loc}%} to 0
  59. if {quarry.depth.%{_loc}%} is not set:
  60. set {quarry.depth.%{_loc}%} to 0
  61. while {quarry.list.%{_loc}%.enabled}:
  62.  
  63. if {_mine}:
  64. wait 3 ticks
  65. #wait 7 seconds
  66. else:
  67. #wait 30 ticks
  68. wait 1 ticks
  69.  
  70.  
  71. set {_mine} to false
  72. if {quarry.row.%{_loc}%} is not set:
  73. set {quarry.row.%{_loc}%} to 0
  74. if {quarry.colmn.%{_loc}%} is not set:
  75. set {quarry.colmn.%{_loc}%} to 0
  76. if {quarry.depth.%{_loc}%} is not set:
  77. set {quarry.depth.%{_loc}%} to 0
  78.  
  79. if {quarry.row.%{_loc}%} >= 6:
  80. set {quarry.row.%{_loc}%} to 0
  81. if {quarry.colmn.%{_loc}%} <= 4:
  82. add 1 to {quarry.colmn.%{_loc}%}
  83. if {quarry.chestDetect.%{_loc}%} is north:
  84. set {quarry.current.%{_loc}%} to location 1 meters east and 6 meters north of {quarry.current.%{_loc}%}
  85. else if {quarry.chestDetect.%{_loc}%} is east:
  86. set {quarry.current.%{_loc}%} to location 1 meters north and 6 meters east of {quarry.current.%{_loc}%}
  87. else if {quarry.chestDetect.%{_loc}%} is south:
  88. set {quarry.current.%{_loc}%} to location 1 meters west and 6 meters south of {quarry.current.%{_loc}%}
  89. else if {quarry.chestDetect.%{_loc}%} is west:
  90. set {quarry.current.%{_loc}%} to location 1 meters south and 6 meters west of {quarry.current.%{_loc}%}
  91.  
  92. else:
  93. set {quarry.colmn.%{_loc}%} to 0
  94. if y-coordinate of {quarry.current.%{_loc}%} > 0:
  95. add 1 to {quarry.depth.%{_loc}%}
  96. set {quarry.current.%{_loc}%} to location {quarry.depth.%{_loc}%} meters below {_startLoc}
  97. else:
  98. set {quarry.list.%{_loc}%.enabled} to false
  99. delete {quarry.current.%{_loc}%}
  100. #else:
  101. add 1 to {quarry.row.%{_loc}%}
  102. if {quarry.chestDetect.%{_loc}%} is north:
  103. set {quarry.current.%{_loc}%} to location 1 meters south of {quarry.current.%{_loc}%}
  104. else if {quarry.chestDetect.%{_loc}%} is east:
  105. set {quarry.current.%{_loc}%} to location 1 meters west of {quarry.current.%{_loc}%}
  106. else if {quarry.chestDetect.%{_loc}%} is south:
  107. set {quarry.current.%{_loc}%} to location 1 meters north of {quarry.current.%{_loc}%}
  108. else if {quarry.chestDetect.%{_loc}%} is west:
  109. set {quarry.current.%{_loc}%} to location 1 meters east of {quarry.current.%{_loc}%}
  110.  
  111. if checkQuarry("" parsed as an offline player, {_loc}) is false:
  112. stop
  113. set {_b} to block at {quarry.current.%{_loc}%}
  114. add {_b} to {_chest}'s inventory
  115. set block at {quarry.current.%{_loc}%} to air
  116.  
  117. set {_mine} to true
  118.  
  119. on rightclick on daylight detector:
  120. if checkQuarry(player, location of clicked block):
  121. cancel event
  122. quarryGUI(player, location of clicked block)
  123.  
  124. on inventory click:
  125. if inventory name of player's current inventory is "Quarry":
  126. cancel event
  127. if clicked slot is 21:
  128. if name of clicked item is "&aEnable":
  129. set {quarry.list.%{quarry.open.%player%}%.enabled} to true
  130. set slot 21 of player's current inventory to lime shulker box named "&aEnabled"
  131. set slot 23 of player's current inventory to red shulker box named "&cDisable"
  132. play "ENTITY_PLAYER_LEVELUP" to player at volume 10
  133. if {quarry.chest.%{quarry.open.%player%}%} is not set:
  134. if {quarry.chestDetect.%{quarry.open.%player%}%} is north:
  135. set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters north of {quarry.open.%player%}
  136.  
  137. else if {quarry.chestDetect.%{quarry.open.%player%}%} is east:
  138. set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters east of {quarry.open.%player%}
  139.  
  140. else if {quarry.chestDetect.%{quarry.open.%player%}%} is south:
  141. set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters south of {quarry.open.%player%}
  142.  
  143. else if {quarry.chestDetect.%{quarry.open.%player%}%} is west:
  144. set {quarry.chest.%{quarry.open.%player%}%} to location 1 meters below and 1 meters west of {quarry.open.%player%}
  145.  
  146. if {quarry.current.%{_quarry}%} is not set:
  147. if {quarry.chestDetect.%{_quarry}%} is north:
  148. set {quarry.current.%{_quarry}%} to location 4 meters north and 1 meters east and 2 meters below {_quarry}
  149. else if {quarry.chestDetect.%{_quarry}%} is east:
  150. set {quarry.current.%{_quarry}%} to location 4 meters east and 1 meters north and 2 meters below {_quarry}
  151. else if {quarry.chestDetect.%{_quarry}%} is south:
  152. set {quarry.current.%{_quarry}%} to location 4 meters south and 1 meters west and 2 meters below {_quarry}
  153. else if {quarry.chestDetect.%{_quarry}%} is west:
  154. set {quarry.current.%{_quarry}%} to location 4 meters west and 1 meters south and 2 meters below {_quarry}
  155.  
  156. set {quarry.startLoc.%{_quarry}%} to {quarry.current.%{_quarry}%}
  157. if {quarry.list::*} doesn't contain {_quarry}:
  158. add {_quarry} to {quarry.list::*}
  159.  
  160. mine({_quarry}, {quarry.startLoc.%{_quarry}%})
  161.  
  162. else:
  163. play "ENTITY_ITEM_BREAK" to player at volume 10
  164. else if clicked slot is 23:
  165. if name of clicked item is "&cDisable":
  166. delete {quarry.list.%{quarry.open.%player%}%.enabled}
  167. set slot 21 of player's current inventory to lime shulker box named "&aEnable"
  168. set slot 23 of player's current inventory to red shulker box named "&cDisabled"
  169. #CHECK SET AND SET INTO VARIABLE
  170. play "ENTITY_PLAYER_LEVELUP" to player at volume 10
  171. else:
  172. play "ENTITY_ITEM_BREAK" to player at volume 10
  173.  
  174. on disable:
  175. loop {quarry.list::*}:
  176. if {quarry.list.%loop-value%.enabled} is true:
  177. set {quarry.list.%loop-value%.enabled} to false
  178. set {quarry.list.%loop-value%.forceEnabled} to true
  179. else:
  180. set {quarry.list.%loop-value%.forceEnabled} to false
  181.  
  182. on enable:
  183. loop {quarry.list::*}:
  184. if {quarry.list.%loop-value%.forceEnabled} is not false:
  185. set {quarry.list.%loop-value%.enabled} to true
  186. set {quarry.list.%loop-value%.forceEnabled} to false
  187. mine(loop-value, {quarry.startLoc.%loop-value%})
Add Comment
Please, Sign In to add comment