Zeldaboy111

Toggle-able loop ]|[ Skript #458

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