Advertisement
stormtrooper28

snake GUI.2

Mar 29th, 2015
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.98 KB | None | 0 0
  1. #
  2. # Snake!
  3. #
  4.  
  5.  
  6. function snakeGamePadUP(p: player):
  7. while {snake.dir.%{_p}%} is "UP":
  8. set {_slot.old} to {snake.slot.%{_p}%}
  9. {snake.dir.%{_p}%} is "UP"
  10. subtract 9 from {snake.slot.%{_p}%}
  11. broadcast "%{snake.dir.%{_p}%}%: from %{_slot.old}% to %{snake.slot.%{_p}%}%"
  12. if {snake.slot.%{_p}%} is less than 0:
  13. broadcast "%{_p}% lost %{snake.slot.%{_p}%}%"
  14. close {_p}'s inventory
  15. # check for out of bounds
  16. if {_p}'s slot {snake.slot.%{_p}%} is not cookie:
  17. add 1 to {snake.points.%{_p}%}
  18. # set the goal to random slot
  19. send "Point added" to {_p}
  20. #else:
  21. format slot {_slot.old} of {_p} with cookie to run ""
  22. format slot {snake.slot.%{_p}%} of {_p} with {snake.head.up} to run ""
  23. wait 20 ticks
  24.  
  25. function snakeGamePadDOWN(p: player):
  26. while {snake.dir.%{_p}%} is "DOWN":
  27. set {_slot.old} to {snake.slot.%{_p}%}
  28. {snake.dir.%{_p}%} is "DOWN"
  29. add 9 to {snake.slot.%{_p}%}
  30. broadcast "%{snake.dir.%{_p}%}%: from %{_slot.old}% to %{snake.slot.%{_p}%}%"
  31. if {snake.slot.%{_p}%} is greater than 53:
  32. broadcast "%{_p}% lost %{snake.slot.%{_p}%}%"
  33. close {_p}'s inventory
  34. # check for out of bounds
  35. if {_p}'s slot {snake.slot.%{_p}%} is not cookie:
  36. add 1 to {snake.points.%{_p}%}
  37. # set the goal to random slot
  38. send "Point added" to {_p}
  39. #else:
  40. format slot {_slot.old} of {_p} with cookie to run ""
  41. format slot {snake.slot.%{_p}%} of {_p} with {snake.head.down} to run ""
  42. wait 20 ticks
  43.  
  44. function snakeGamePadLEFT(p: player):
  45. while {snake.dir.%{_p}%} is "LEFT":
  46. set {_slot.old} to {snake.slot.%{_p}%}
  47. {snake.dir.%{_p}%} is "LEFT"
  48. subtract 1 from {snake.slot.%{_p}%}
  49. broadcast "%{snake.dir.%{_p}%}%: from %{_slot.old}% to %{snake.slot.%{_p}%}%"
  50. if {_slot.old} is 0 or 9 or 18 or 27 or 36 or 45:
  51. broadcast "%{_p}% lost %{snake.slot.%{_p}%}%"
  52. close {_p}'s inventory
  53. # check for out of bounds
  54. if {_p}'s slot {snake.slot.%{_p}%} is not cookie:
  55. add 1 to {snake.points.%{_p}%}
  56. # set the goal to random slot
  57. send "Point added" to {_p}
  58. #else:
  59. format slot {_slot.old} of {_p} with cookie to run ""
  60. format slot {snake.slot.%{_p}%} of {_p} with {snake.head.left} to run ""
  61. wait 20 ticks
  62.  
  63. function snakeGamePadRIGHT(p: player):
  64. while {snake.dir.%{_p}%} is "RIGHT":
  65. set {_slot.old} to {snake.slot.%{_p}%}
  66. {snake.dir.%{_p}%} is "RIGHT"
  67. add 1 to {snake.slot.%{_p}%}
  68. broadcast "%{snake.dir.%{_p}%}%: from %{_slot.old}% to %{snake.slot.%{_p}%}%"
  69. if {_slot.old} is 8 or 17 or 26 or 35 or 44 or 53:
  70. broadcast "%{_p}% lost %{snake.slot.%{_p}%}%"
  71. close {_p}'s inventory
  72. # check for out of bounds
  73. if {_p}'s slot {snake.slot.%{_p}%} is not cookie:
  74. add 1 to {snake.points.%{_p}%}
  75. # set the goal to random slot
  76. send "Point added" to {_p}
  77. #else:
  78. format slot {_slot.old} of {_p} with cookie to run ""
  79. format slot {snake.slot.%{_p}%} of {_p} with {snake.head.right} to run ""
  80. wait 20 ticks
  81.  
  82. command /snake:
  83. aliases: /snake!
  84. trigger:
  85. set {snake.head} to a green wool named "&6&lSnakeHead" with lore "&1&lThis is the head of your snake! ||&1&lUse it to eat rats for points. ||&1&lYour tail will grow as you eat! ||&1&lTry to get the longest tail!"
  86. set {snake.head.up} to a redstone torch named "&6&lSnakeHead" with lore "&1&lThis is the head of your snake! ||&1&lUse it to eat rats for points. ||&1&lYour tail will grow as you eat! ||&1&lTry to get the longest tail!"
  87. set {snake.head.down} to a tripwire hook named "&6&lSnakeHead" with lore "&1&lThis is the head of your snake! ||&1&lUse it to eat rats for points. ||&1&lYour tail will grow as you eat! ||&1&lTry to get the longest tail!"
  88. set {snake.head.left} to a flint and steel named "&6&lSnakeHead" with lore "&1&lThis is the head of your snake! ||&1&lUse it to eat rats for points. ||&1&lYour tail will grow as you eat! ||&1&lTry to get the longest tail!"
  89. set {snake.head.right} to an arrow named "&6&lSnakeHead" with lore "&1&lThis is the head of your snake! ||&1&lUse it to eat rats for points. ||&1&lYour tail will grow as you eat! ||&1&lTry to get the longest tail!"
  90. open chest with 7 rows named " &l&oSnake!" to player
  91. wait 1 tick
  92. set {snake.inv.%player%} to true
  93. set {_slots} to 7 * 9
  94. loop {_slots} times:
  95. {snake.inv.%player%} is true
  96. set {_num} to loop-number - 1
  97. format slot {_num} of player with a cake to be unstealable
  98. set {snake.slot.%player%} to 22
  99. format slot 22 of player with {snake.head} to run ""
  100. format slot 54 of player with a redstone torch named "&9&lUP" with lore "&3Click me to face up!" to be unstealable # "snakeGamePad %player% UP"
  101. format slot 55 of player with a tripwire hook named "&9&lDown" with lore "&3Click me to face down!" to be unstealable # to run "snakeGamePad %player% DOWN"
  102. format slot 56 of player with a Flint and Steel named "&9&lLEFT" with lore "&3Click me to face left!" to be unstealable # to run "snakeGamePad %player% LEFT"
  103. format slot 57 of player with an arrow named "&9&lRIGHT" with lore "&3Click me to face right!" to be unstealable # to run "snakeGamePad %player% RIGHT"
  104. format slot 62 of player with a red wool named "&4&lQUIT" with lore "&3Click me to quit!||There is no way to save a game!" to close
  105. wait 1 tick
  106. format slot 40 of player with apple to run "?"
  107. if 1 is 2:
  108. loop {_slots} times:
  109. {snake.inv.%player%} is true
  110. set {_num} to loop-number - 1
  111. format slot {_num} of player with a cookie to be unstealable
  112. wait 1 ticks
  113. format slot {_num} of player with air to be unstealable
  114. if {_num} is less than 0:
  115. broadcast "%player% has lost"
  116. if {_num} is greater than 52:
  117. broadcast "%player% has lost"
  118. close player's inventory
  119.  
  120.  
  121. on inventory close:
  122. {snake.inv.%player%} is true:
  123. set {snake.inv.%player%} to false
  124. delete {snake.dir.%player%}
  125.  
  126. on inventory click:
  127. {snake.inv.%player%} is true:
  128. if event-item is a redstone torch named "&9&lUP" with lore "&3Click me to face up!":
  129. set {snake.dir.%player%} to "UP"
  130. snakeGamePadUP(player)
  131. if event-item is a tripwire hook named "&9&lDown" with lore "&3Click me to face down!":
  132. set {snake.dir.%player%} to "DOWN"
  133. snakeGamePadDOWN(player)
  134. if event-item is a Flint and Steel named "&9&lLEFT" with lore "&3Click me to face left!":
  135. set {snake.dir.%player%} to "LEFT"
  136. snakeGamePadLEFT(player)
  137. if event-item is an arrow named "&9&lRIGHT" with lore "&3Click me to face right!":
  138. set {snake.dir.%player%} to "RIGHT"
  139. snakeGamePadRIGHT(player)
  140.  
  141.  
  142.  
  143.  
  144. command /snakeGamePad <player> <text>:
  145. trigger:
  146. set {snake.dir.%arg-player%} to arg 2
  147. if arg 2 is "UP":
  148. broadcast "%{snake.dir.%arg-player%}%: Stops"
  149. stop
  150.  
  151. set {snake.dir.%arg-player%} to arg 2
  152. if arg 2 is "DOWN":
  153. broadcast "%{snake.dir.%arg-player%}%: Stops at %{snake.slot.%arg-player%}%"
  154. stop
  155.  
  156. if arg 2 is "LEFT":
  157. broadcast "%{snake.dir.%arg-player%}%: Stops"
  158. stop
  159.  
  160. if arg 2 is "RIGHT":
  161. broadcast "%{snake.dir.%arg-player%}%: Stops"
  162. stop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement