UNOBTANIUM

MegaPipeWooden

Jun 18th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. -- MEGA WOODEN PIPE 0.1.0
  2.  
  3. local speed = 0.5
  4. local routine = 180
  5. local timeRemaining = 10
  6.  
  7.  
  8. os.setComputerLabel("MegaPipeWooden")
  9. if not fs.exists("bee") then
  10.  shell.run("pastebin","get","7geFYhut","bee")
  11. end
  12. if not fs.exists("princess") then
  13.  shell.run("pastebin","get","5GLf6ZCB","princess")
  14. end
  15. if not fs.exists("comb") then
  16.  shell.run("pastebin","get","YUrtgM6X","comb")
  17. end
  18. term.clear()
  19. term.setCursorPos(1,1)
  20.  
  21. local bee = paintutils.loadImage("bee")
  22. local comb = paintutils.loadImage("comb")
  23. local princess = paintutils.loadImage("princess")
  24.  
  25. rednet.open("top")
  26.  
  27. local monitor = peripheral.wrap("back")
  28. term.redirect(monitor)
  29.  
  30.  
  31. function clear()
  32.  term.clear()
  33.  term.setCursorPos(1,1)
  34. end
  35.  
  36.  
  37. function saveTime()
  38.  local file = fs.open("MegaPipeTime", "w")
  39.   file.writeLine(timeRemaining)
  40.  file.close()
  41. end
  42.  
  43. function loadTime()
  44.  if not fs.exists("MegaPipeTime") then timeRemaining = 10 return end
  45.  local file = fs.open("MegaPipeTime", "r")
  46.   timeRemaining = tonumber(file.readLine())
  47.  file.close()
  48. end
  49.  
  50.  
  51.  
  52. function run()
  53.  if timeRemaining > 0 then
  54.   timeRemaining = timeRemaining - 1
  55.   sleep(1)
  56.   saveTime()
  57.   return
  58.  end
  59.  
  60.  timeRemaining = routine/2
  61.  saveTime()
  62.  local amountBees = math.ceil(math.random()*3)
  63.  local amountItems = math.floor(math.random()*3)
  64.  
  65.  for i=1,amountBees do
  66.   local beeImage = princess
  67.   if i>1 then
  68.    beeImage = bee
  69.   end
  70.   for x=-30, 1, 2 do
  71.    term.clear()
  72.    paintutils.drawImage(beeImage, x, 4)
  73.    sleep(speed)
  74.   end
  75.  
  76.   for y=4,-14, -1 do
  77.    term.clear()
  78.    paintutils.drawImage(beeImage, 1, y)
  79.    sleep(speed)
  80.    if y == -6 then
  81.     if i == 1 then
  82.      rednet.broadcast(textutils.serialize({"MegaPipeWoodenSegment","princess"}))
  83.     else
  84.      rednet.broadcast(textutils.serialize({"MegaPipeWoodenSegment","bee"}))
  85.     end
  86.    end
  87.   end
  88.   sleep(3)
  89.  end
  90.  
  91.  for i=1,amountItems do
  92.   for x=-30, 1, 2 do
  93.    term.clear()
  94.    paintutils.drawImage(comb, x, 4)
  95.    sleep(speed)
  96.   end
  97.  
  98.   for y=4,-14, -1 do
  99.    term.clear()
  100.    paintutils.drawImage(comb, 1, y)
  101.    sleep(speed)
  102.    if y == -6 then
  103.     rednet.broadcast(textutils.serialize({"MegaPipeWoodenSegment","comb"}))
  104.    end
  105.   end
  106.   sleep(3)
  107.  end
  108.  timeRemaining = routine
  109.  saveTime()
  110. end
  111.  
  112.  
  113.  
  114.  
  115.  
  116. loadTime()
  117. while true do
  118.  run()
  119. end
Advertisement
Add Comment
Please, Sign In to add comment