Advertisement
Guest User

startup

a guest
Feb 27th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. local monitor = peripheral.wrap("left")
  2. term.redirect(monitor)
  3. local rain = {}
  4. local maxX, maxY = term.getSize()
  5. function newrain()
  6.   local axis = math.random(1,2) == 1 and true or false
  7.   local template = {
  8.   x = axis == true and math.random(1,maxX) or maxX,
  9.   y = axis == false and math.random(1,maxY) or 1,
  10.   color = colors.blue,
  11.   velo = math.random(1,4) == 4 and 2 or 1
  12.   }
  13.   table.insert(rain,template)
  14. end
  15.  
  16. function redraw(bool)
  17.   term.setBackgroundColor(bool == true and colors.white or colors.black)
  18.   term.clear()
  19.   for i,v in ipairs(rain) do
  20.     term.setCursorPos(v.x,v.y)
  21.     term.setTextColor(v.color)
  22.     term.write("/")
  23.     v.x = v.x - v.velo
  24.     v.y = v.y + v.velo
  25.     if v.y > maxX or v.x < 1 then
  26.       table.remove(rain,i)
  27.     end
  28.   end
  29. end
  30.  
  31. local boolean
  32. local light = 0
  33. while true do
  34.     for i=1,3 do
  35.         newrain()
  36.     end
  37.     if boolean == true then
  38.         light = light + 1
  39.         if light == 5 then
  40.             boolean = false
  41.             light = 0
  42.         end
  43.     else
  44.         boolean = math.random(1,40) == 1 and true or false
  45.         if boolean == true and commands then
  46.             commands.exec("playsound ambient.weather.thunder"..math.random(1,3).." @p")
  47.         end
  48.     end
  49.     redraw(boolean)
  50.     sleep(0.01)
  51.     if commands then
  52.         commands.exec("playsound ambient.weather.rain"..math.random(1,4).." @p")
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement