0something0

Lua Weather Script

Aug 20th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.72 KB | None | 0 0
  1. print("Weather script loaded")
  2.  
  3. --setup
  4. WeatherChange = "Random" --Amount of time in seconds before weather changes. Use String "Random" to set it to random.
  5.  
  6. LocationX = 0
  7. LocationY = 400
  8. LocationZ = 0 --Location
  9.  
  10. SizeX = 2048
  11. SizeY = 250
  12. SizeZ = 2048 --Size
  13.  
  14. local CloudParticle = script.Parent.CloudParticle --Defines CloudParticle
  15. local CloudPart = script.Parent --Defines CloudPart
  16. local RainParticle = script.Parent.RainParticle
  17. script.Parent = workspace.CloudPart --Puts script into CloudPart
  18. math.randomseed( os.time() ) --Seeds math.random using OS time
  19. WeatherChange = math.random(10, 60)
  20.  
  21. function WeatherChangeAlart ()
  22. Instance.new("Explosion", script.Parent)
  23. end
  24.  
  25. function RandomWeatherChangeTime () --Function for Random WeatherChange Time
  26. if WeatherChange == "Random" then --checks if WeatherChange variable is set to random
  27. WeatherChange = math.random(10, 60) --Min/Max time until next WeatherChange
  28. end
  29. print ("time until next WeatherChange is: " .. WeatherChange)
  30. end
  31.  
  32. --Cloud Direction Chooser
  33. function RandomCloudDirection ()
  34. print("Begin RandomCloudDirection Loop")
  35. CloudDirection = math.random(1, 4)--Randomly Generates number with numbers corrosponding to directions
  36. if CloudDirection == 1 then
  37. CloudParticle.EmissionDirection = "Front"
  38. WeatherChangeAlart()
  39. print("CloudDirection: Front")
  40. elseif CloudDirection == 2 then
  41. CloudParticle.EmissionDirection = "Back"
  42. WeatherChangeAlart()
  43. print("CloudDirection: Back")
  44. elseif CloudDirection == 3 then
  45. CloudParticle.EmissionDirection = "Left"
  46. WeatherChangeAlart()
  47. print("CloudDirection: Left")
  48. elseif CloudDirection == 4 then
  49. CloudParticle.EmissionDirection = "Right"
  50. WeatherChangeAlart()
  51. print("CloudDirection: Right")
  52. end
  53. print("End RandomCloudDirection Loop")
  54. end
  55.  
  56. function Cloudiness () --Function to change cloudiness
  57. print ("Begin Cloudiness Loop")
  58. CloudParticle.Rate = math.random(0, 200) --Choose between Cloudiness of 0-100
  59. print ("Cloudiness: " .. CloudParticle.Rate) --display Cloudiness
  60. print ("end Cloudiness Loop")
  61. end
  62.  
  63. function Lightning()
  64. Instance.new("Part", script.Parent)
  65. script.Parent.Part.Anchored = true
  66. print("Created LightingPart")
  67. local LightningPart = script.Parent.Part
  68. LightningPart.Position = Vector3.new(
  69. math.random(LocationX-(SizeX/2), LocationX+(SizeX/2)),
  70. LocationY,--Y postion doesn't really matter
  71. math.random(LocationZ-(SizeZ/2), LocationZ+(SizeZ/2))
  72. --Minium position for part is the location of the CloudPart minus half the size of the cloudpart,
  73. --Max postion is the location of the CloudPart plus half the size of the cloudpart
  74. )
  75. LightningPart.Material = "Neon"
  76. LightningPart.Color = Color3.fromRGB(255,255,255)
  77. end
  78.  
  79. function precipitation()
  80. print ("Begin precipitation loop")
  81. if math.random(1, 4) == 4 then
  82. RainParticle.Enabled = true
  83. CloudParticle.Rate = 200
  84. CloudParticle.Color = ColorSequence.new(Color3.fromRGB(100,100,100))
  85. Lightning()
  86. print("precipitating")
  87. end
  88. print ("end precipitation loop")
  89. end
  90.  
  91. function CloudColor()
  92. print ("Changing CloudColor")
  93. CloudParticle.Color = ColorSequence.new(Color3.fromRGB(200-CloudParticle.Rate/2,200-CloudParticle.Rate/2,200-CloudParticle.Rate/2 ))
  94. --changes color of the cloud based on how cloudy it is
  95. end
  96.  
  97. --Script for CloudPart
  98. CloudPart.Name = "CloudPart" --Makes sure name is the part Cloud
  99. CloudPart.Anchored = true --Anchors part
  100. CloudPart.Position = Vector3.new(LocationX, 400, LocationZ) --Places it at location specified by the variable(for some reason the vars above doesnt actuall work so you are going to have to set them manually)
  101. print(LocationY)
  102. print (CloudPart.Position)
  103. CloudPart.Size = Vector3.new(SizeX, -100, SizeZ) --Sizes it to the dimensions specified by the variable
  104. CloudPart.CanCollide = false --removes colliders
  105. print("Part Created!")
  106.  
  107. --Script for CloudParticle
  108. CloudParticle.Name = "CloudParticle" --Makes sure name is CloudParticle
  109. CloudParticle.Texture = "rbxassetid://258128463" --Fetches texture
  110. CloudParticle.Lifetime = NumberRange.new(WeatherChange,WeatherChange)
  111. CloudParticle.Size = NumberSequence.new(500)
  112. print("Particle Created!")
  113.  
  114. --script for RainParticle
  115. RainParticle.Name = "RainParticle" --Makes sure name is RainParticle
  116. RainParticle.Texture = "rbxassetid://242967670" --Fetches texture
  117. RainParticle.Rate = 100000001504746621987668885504100000001504746621987668885504.000
  118. RainParticle.Enabled = false
  119.  
  120. while true do
  121. print ("_________________________________________________")
  122. RandomCloudDirection()
  123. print("Changing Cloud Direction")
  124. Cloudiness ()
  125. print("Changing Cloudiness")
  126. RandomWeatherChangeTime()
  127. precipitation()
  128. print("Changing precipitation")
  129. CloudColor()
  130. wait(WeatherChange)
  131. end
Add Comment
Please, Sign In to add comment