Zeldaboy111

Mine reset ]|[ Skript #459

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