ProfesseurCraft

Système feu artifice aléatoire avec Skript

Jan 1st, 2015
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. variables:
  2. {firework} = false
  3. {loopStarted} = false
  4.  
  5. #-----------------------------------------------------------------
  6. # Système de sélection de zone
  7. #-----------------------------------------------------------------
  8.  
  9. on leftclick with stick:
  10. if player has stick named "&4&lSuperStick":
  11. cancel event
  12. set {a} to event-location
  13. message "<yellow>Point A ajouté"
  14. on rightclick with stick:
  15. if player has stick named "&4&lSuperStick":
  16. if {a} is set:
  17. set {_b} to event-location
  18. message "<yellow>Point B ajouté"
  19. set {_a.x} to round x-coord of {a}
  20. set {_a.y} to round y-coord of {a}
  21. set {_a.z} to round z-coord of {a}
  22. set {_b.x} to round x-coord of {_b}
  23. set {_b.y} to round y-coord of {_b}
  24. set {_b.z} to round z-coord of {_b}
  25.  
  26. if {_a.x} is smaller than {_b.x}:
  27. set {_ab.x} to "%{_a.x}%,%{_b.x}%"
  28. else:
  29. set {_ab.x} to "%{_b.x}%,%{_a.x}%"
  30.  
  31. if {_a.y} is smaller than {_b.y}:
  32. set {_ab.y} to "%{_a.y}%,%{_b.y}%"
  33. else:
  34. set {_ab.y} to "%{_b.y}%,%{_a.y}%"
  35.  
  36. if {_a.z} is smaller than {_b.z}:
  37. set {_ab.z} to "%{_a.z}%,%{_b.z}%"
  38. else:
  39. set {_ab.z} to "%{_b.z}%,%{_a.z}%"
  40.  
  41. set {area} to "%{_ab.x}%,%{_ab.y}%,%{_ab.z}%"
  42.  
  43. delete {a}
  44.  
  45.  
  46.  
  47. else:
  48. message "<pink>Veuillez d'abord sélectionner le point A"
  49.  
  50. #-----------------------------------------------------------------
  51. # Activation / désactivation du feu d'artifice
  52. #-----------------------------------------------------------------
  53.  
  54. command /toggleFirework:
  55. aliases: /tf
  56. trigger:
  57. if {firework} is false:
  58. set {firework} to true
  59. else:
  60. set {firework} to false
  61.  
  62. #-----------------------------------------------------------------
  63. # Si le feu d'artifice est activé, cela génère des feux d'artifice aléatoires
  64. # à l'intérieur de la zone que vous aurez sélectionné.
  65. #-----------------------------------------------------------------
  66. every 5 ticks:
  67. if {area} is set:
  68. if {firework} is true:
  69.  
  70. set {_area.coords::*} to {area} split at ","
  71. loop {_area.coords::*}:
  72. set {_area.coord_%loop-index%} to loop-value parsed as number
  73.  
  74. set {_x} to random number between {_area.coord_1} and {_area.coord_2}
  75. set {_y} to random number between {_area.coord_3} and {_area.coord_4}
  76. set {_z} to random number between {_area.coord_5} and {_area.coord_6}
  77.  
  78. set {_lifeTime} to random integer between 0 and 40
  79. set {_flight} to random integer between 0 and 3
  80.  
  81. set {_flicker} to random integer between 0 and 1
  82. set {_trail} to random integer between 0 and 1
  83. set {_type} to random integer between 0 and 4
  84.  
  85. set {_numberOfColors} to random integer between 1 and 10
  86.  
  87. set {_i} to 0
  88.  
  89. while {_i} is smaller than {_numberOfColors}:
  90. set {_r} to random integer between 0 and 255
  91. set {_g} to random integer between 0 and 255
  92. set {_b} to random integer between 0 and 255
  93.  
  94. set {_decimalColor} to {_b} + 256 * {_g} + 65536 * {_r}
  95. add "%{_decimalColor}%" to {_colors::*}
  96. set {_i} to {_i} + 1
  97.  
  98. set {_colors} to join {_colors::*} with ","
  99.  
  100. execute console command "/summon FireworksRocketEntity %{_x}% %{_y}% %{_z}% {LifeTime:%{_lifeTime}%,FireworksItem:{id:fireworks,Count:1,tag:{Fireworks:{Flight:%{_flight}%,Explosions:[{Flicker:%{_flicker}%,Trail:%{_trail}%,Type:%{_type}%,Colors:[%{_colors}%]}]}}}}"
  101.  
  102. #-----------------------------------------------------------------
  103. # Give du baton qui sert à la sélection de la zone pour le feu d'artifice
  104. #-----------------------------------------------------------------
  105. command /superStick:
  106. aliases: /ss
  107. trigger:
  108. execute player command "/give %player% stick 1 {display:{Name:&4&lSuperStick}}"
Advertisement
Add Comment
Please, Sign In to add comment