Kingdaro

weather prediction thing

Dec 30th, 2011
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. --spring + summer
  2.  
  3. forecast = {
  4.     'sunny',
  5.     'partly cloudy',
  6.     'mostly cloudy',
  7.     'overcast',
  8.     'sunny',
  9.     'light rain',
  10.     'rain',
  11.     'heavy rain with a chance of lightning'
  12. }
  13.  
  14. while true do
  15.     clouds = math.random(4)
  16.     precip = math.random(2)
  17.     temp = math.random(70,90)
  18.  
  19.     cmd = io.read()
  20.     if cmd == 'exit' then
  21.         break
  22.     end
  23.  
  24.     local v = clouds*precip
  25.  
  26.     temp = temp + ((v-4<0) and math.random((v-4)*3,0) or math.random(0,(v-4)*3))
  27.  
  28.     print(
  29.         "Today's weather will be " ..
  30.         forecast[v] ..
  31.         " with a temperature of " ..
  32.         temp ..
  33.         "."
  34.     )
  35. end
Advertisement
Add Comment
Please, Sign In to add comment