Zeldaboy111

Resetting Mines Af! ]|[ Skript #461

Oct 24th, 2021
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.07 KB | None | 0 0
  1. options:
  2. prefix: &6Mines&8:&7
  3. mineResetDelay: 300
  4.  
  5. on quit:
  6. delete {mine.user.%uuid of player%.isConfirmingMine}
  7. delete {mine.user.%uuid of player%.isShowingMine}
  8. loop {mine.user.%uuid of player%.fallingBlocks::*}:
  9. kill loop-value
  10.  
  11. on disable:
  12. loop all players:
  13. delete {mine.user.%uuid of loop-player%.isConfirmingMine}
  14. delete {mine.user.%uuid of loop-player%.isShowingMine}
  15. loop {mine.user.%uuid of loop-player%.fallingBlocks::*}:
  16. kill loop-value-2
  17.  
  18. if {mine.isLoopingMines} is true:
  19. set {mine.loopingMinesStopped} to true
  20. set {mine.disableTime} to now
  21.  
  22. on enable:
  23. if difference between {mine.disableTime} and now >= 10 seconds:
  24. delete {mine.isLoopingMines}
  25. while {mine.isLoopingMines} is true:
  26. wait 5 ticks
  27. set {mine.looping.currentDelay} to 0
  28. if {mine.loopingMinesStopped} is true:
  29. delete {mine.loopingMinesStopped}
  30. delete {mine.isLoopingMines}
  31. startLoopingMines()
  32.  
  33. function startLoopingMines():
  34. if {mine.isLoopingMines} or {mine.loopingMinesStopped} is true:
  35. stop
  36. else if {mine.list::*} is empty:
  37. stop
  38.  
  39. set {mine.isLoopingMines} to true
  40. while {mine.isLoopingMines} is true:
  41. if {mine.loopingMinesStopped} is true:
  42. delete {mine.isLoopingMines}
  43. set {mine.looping.currentDelay} to 0
  44. stop
  45. else if {mine.list::*} is empty:
  46. delete {mine.isLoopingMines}
  47. set {mine.looping.currentDelay} to 0
  48. stop
  49. add 1 to {mine.looping.currentDelay}
  50. if {mine.looping.currentDelay} >= {@mineResetDelay}:
  51. loop {mine.list::*}:
  52. resetMine(loop-value)
  53. broadcast "{@prefix} All mines have been reset!"
  54. set {mine.looping.currentDelay} to 0
  55. else if "%{mine.looping.currentDelay}/60%" doesn't contain ".":
  56. broadcast "{@prefix} The mines will reset in &e%({@mineResetDelay}-{mine.looping.currentDelay}) / 60% &eminutes&7."
  57. else if {@mineResetDelay}-{mine.looping.currentDelay} < 60:
  58. if {@mineResetDelay}-{mine.looping.currentDelay} is 30 or 15 or 10 or 5:
  59. broadcast "{@prefix} The mines will reset in &e%{@mineResetDelay}-{mine.looping.currentDelay}% &eseconds&7."
  60. wait 20 ticks
  61. command /reset:
  62. trigger:
  63. loop {mine.list::*}:
  64. resetMine(loop-value)
  65.  
  66.  
  67.  
  68. function resetMine(id: String):
  69. set {_location} to {mine.%{_id}%.location}
  70. loop {mine.%{_id}%.depth} times:
  71. loop {mine.%{_id}%.width} times:
  72. loop {mine.%{_id}%.length} times:
  73. set {_selectedLocation} to location -1+loop-value-1 meters below, -1+loop-value-2 meters east and -1+loop-value-3 meters north of {_location}
  74. if block at {_selectedLocation} is air:
  75. if chance of 1.3%:
  76. set block at {_selectedLocation} to diamond ore
  77. else if chance of 0.1%:
  78. set block at {_selectedLocation} to emerald ore
  79. else if chance of 3.7%:
  80. set block at {_selectedLocation} to lapis ore
  81. else if chance of 5.8%:
  82. set block at {_selectedLocation} to redstone ore
  83. else if chance of 5.5%:
  84. set block at {_selectedLocation} to gold ore
  85. else if chance of 13.2%:
  86. set block at {_selectedLocation} to iron ore
  87. else if chance of 18.9%:
  88. set block at {_selectedLocation} to coal ore
  89. else:
  90. set block at {_selectedLocation} to stone
  91.  
  92. command /mine [<text>] [<text>] [<text>] [<text>] [<text>]:
  93. aliases: /mines
  94. trigger:
  95. if executor is not a player:
  96. send "{@prefix} This command can only be executed by a player."
  97. else if arg-1 is "create":
  98. if arg-2 is not set:
  99. send "{@prefix} Invalid Usage! &e/mine create <id> <length> <depth> <width>&7."
  100. else if {mine.list::*} contains arg-2 in lower case:
  101. send "{@prefix} A mine with the id &e%arg-2 in lower case% &7already exists."
  102. else if {mine.user.%uuid of player%.isConfirmingMine} is true:
  103. send "{@prefix} You are already creating a mine. Either cancel or confirm the mine first."
  104. else if isNotANumber(player, arg-3, "<length>", "<depth>", "<width>"), isNotANumber(player, arg-4, arg-3, "<depth>", "<width>") or isNotANumber(player, arg-5, arg-3, arg-4, "<width>") is false:
  105. stop
  106. else:
  107. set {mine.user.%uuid of player%.isConfirmingMine} to true
  108. set {mine.user.%uuid of player%.location} to location of block at location of player
  109. set {mine.user.%uuid of player%.id} to arg-2 in lower case
  110. set {mine.user.%uuid of player%.length} to arg-3 parsed as an integer
  111. set {mine.user.%uuid of player%.depth} to arg-4 parsed as an integer
  112. set {mine.user.%uuid of player%.width} to arg-5 parsed as an integer
  113. showMineToConfirm(player)
  114. send "{@prefix} Please confirm you want to create a mine with as parameters &e%arg-3% &e%arg-4% &e%arg-5%&7."
  115. send "{@prefix} To confirm, please type &e/mine <confirm | cancel>&7."
  116.  
  117. else if arg-1 is "delete":
  118. if arg-2 is not set:
  119. send "{@prefix} Invalid Usage! &e/mine delete <id> <length> <depth> <width>&7."
  120. else if {mine.list::*} doesn't contain arg-2 in lower case:
  121. send "{@prefix} A mine with the id &e%arg-2 in lower case% &7does not exist."
  122. else:
  123. set {_id} to arg-2 in lower case
  124. remove {_id} from {mine.list::*}
  125. send "{@prefix} The mine &e%{_id}% &7has been deleted!"
  126. else if arg-1 is "confirm":
  127. if {mine.user.%uuid of player%.isConfirmingMine} is not true:
  128. send "{@prefix} Invalid Usage! &e/mine <create | delete> <id> <length> <depth> <width>&7."
  129. else:
  130. if {mine.list::*} contains {mine.user.%uuid of player%.id}:
  131. send "{@prefix} A mine with the id &e%arg-2 in lower case% &7already exists."
  132. delete {mine.user.%uuid of player%.isConfirmingMine}
  133. delete {mine.user.%uuid of player%.isShowingMine}
  134. else:
  135.  
  136. loop {mine.user.%uuid of player%.fallingBlocks::*}:
  137. set health of loop-value to 0
  138. kill loop-value
  139. add {mine.user.%uuid of player%.id} to {mine.list::*}
  140. set {_id} to {mine.user.%uuid of player%.id}
  141. set {mine.%{_id}%.location} to {mine.user.%uuid of player%.location}
  142. set {mine.%{_id}%.length} to {mine.user.%uuid of player%.length}+1
  143. set {mine.%{_id}%.depth} to {mine.user.%uuid of player%.depth}+1
  144. set {mine.%{_id}%.width} to {mine.user.%uuid of player%.width}+1
  145. delete {mine.user.%uuid of player%.isConfirmingMine}
  146. send "{@prefix} You have created the mine &e%{_id}%&7!"
  147. resetMine({_id})
  148. startLoopingMines()
  149. else if arg-1 is "cancel":
  150. if {mine.user.%uuid of player%.isConfirmingMine} is not true:
  151. send "{@prefix} Invalid Usage! &e/mine <create | delete> <id> <length> <depth> <width>&7."
  152. else:
  153. delete {mine.user.%uuid of player%.isConfirmingMine}
  154. delete {mine.user.%uuid of player%.isShowingMine}
  155. send "{@prefix} You have cancelled creating the mine."
  156. loop {mine.user.%uuid of player%.fallingBlocks::*}:
  157. kill loop-value
  158. else:
  159. send "{@prefix} Invalid Usage! &e/mine <create | delete> <id> <length> <depth> <width>&7."
  160.  
  161. function isNotANumber(player: Player, input: String, length: String, depth: String, width: String) :: Boolean:
  162. if {_input} parsed as an integer is not set:
  163. send "{@prefix} Invalid Usage! &e/mine create <id> %{_length}% &e%{_depth}% &e%{_width}%&7." to {_player}
  164. return false
  165. return true
  166.  
  167. function showMineToConfirm(player: Player):
  168. set {_uuid} to uuid of {_player}
  169. if {mine.user.%{_uuid}%.isShowingMine} is true:
  170. stop
  171. set {mine.user.%{_uuid}%.isShowingMine} to true
  172. set {_locationOffsetNorth::*} to 0, 0, {mine.user.%{_uuid}%.length} and {mine.user.%{_uuid}%.length}
  173. set {_locationOffsetEast::*} to 0, {mine.user.%{_uuid}%.width}, {mine.user.%{_uuid}%.width} and 0
  174. loop 8 times:
  175. if loop-value < 5:
  176. spawn falling sea lantern at location {_locationOffsetNorth::%loop-value%} meters north and {_locationOffsetEast::%loop-value%} meters east of {mine.user.%{_uuid}%.location}
  177. else:
  178. spawn falling sea lantern at location {mine.user.%{_uuid}%.depth} meters below, {_locationOffsetNorth::%loop-value - 4%} meters north and {_locationOffsetEast::%loop-value - 4%} meters east of {mine.user.%{_uuid}%.location}
  179.  
  180. set {_entity} to spawned entity
  181. hide {_entity} for all players
  182. show {_entity} to {_player}
  183. add {_entity} to {mine.user.%{_uuid}%.fallingBlocks::*}
  184. add "{NoGravity:1b,Invulnerable:1b}" to nbt of {_entity}
  185.  
  186.  
  187.  
  188.  
Advertisement
Add Comment
Please, Sign In to add comment