Zeldaboy111

Mine regeneration / Toggleable loop ]|[ Skript #457

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