Zeldaboy111

Toggle-able loop ]|[ Skript #460

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