Advertisement
Larvix

progressBar

Nov 13th, 2024 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. modem = peripheral.wrap("bottom")
  2. for i = 1,10 do
  3.     modem.open(i)
  4. end
  5.  
  6. self = "turtle_226"
  7. tank = "industrialforegoing:black_hole_tank_tile_6"
  8. spawner = peripheral.wrap("industrialforegoing:mob_duplicator_tile_35")
  9. sensor = peripheral.wrap("right")
  10. tool = peripheral.wrap("industrialforegoing:black_hole_unit_tile_224")
  11. dump = peripheral.wrap("railcraft:chest_void_2")
  12.  
  13. function spawn(wave)
  14.     spawner.pullFluid(tank,8000,"essence")
  15.     turtle.select(wave)
  16.     redstone.setOutput("front",true)
  17.     spawner.pullItems(self,11)
  18.     sleep(0.2)
  19.     turtle.place()
  20.     spawner.pushItems(self,7)
  21.     redstone.setOutput("front",false)
  22. end
  23.  
  24. function clearWither()
  25.     tool.pushItems(self,1,16,1)
  26.     turtle.select(16)
  27.     turtle.place()
  28.     dump.pullItems(self,16)
  29.     turtle.select(1)
  30. end
  31.  
  32. function dumpStars()
  33.     if turtle.getItemCount(12) > 0 then
  34.         dump.pullItems(self,12)
  35.     end
  36. end
  37.  
  38. function getMsg()
  39.     while true do
  40.         msg = {os.pullEvent("modem_message")}
  41.         wave = msg[3]
  42.         prog = msg[4]
  43.     end
  44. end
  45.  
  46. function manageBar()
  47.     while true do
  48.         if (wave and prog) then
  49.             spawn(wave)
  50.             currentWave = wave
  51.             while sensor.getMetaByName("WitherBoss") do
  52.                 if wave ~= currentWave then
  53.                     clearWither()
  54.                 else
  55.                     if ((sensor.getMetaByName("WitherBoss").health/3) > prog) then
  56.                         turtle.attack()
  57.                     end
  58.                 end
  59.             end
  60.             dumpStars()
  61.         elseif sensor.getMetaByName("WitherBoss") then
  62.             clearWither()
  63.         else
  64.             sleep()
  65.         end
  66.     end
  67. end
  68.  
  69. parallel.waitForAll(getMsg,manageBar)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement