Advertisement
Guest User

asdf

a guest
Feb 10th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. local flowrate = 100 --flow rate of the conduit in millibuckets/tick
  2. local sleeprate = 0.075 --length of a minecraft tick in seconds
  3. local magicnumber = 50
  4.  
  5. function experienceToLiquid(xp)
  6. return xp * 20
  7. end
  8.  
  9. function getExperienceForLevel(level)
  10. if level == 0 then return 0 end
  11.  
  12. if level > 0 and level < 16 then
  13. return level * 17
  14. end
  15. if level > 15 and level < 31 then
  16. return 1.5 * math.pow(level, 2) - 29.5 * level + 360
  17. end
  18.  
  19. return 3.5 * math.pow(level, 2) - 151.5 * level + 2220
  20. end
  21.  
  22. function getLiquidForLevel(level)
  23. return experienceToLiquid(getExperienceForLevel(level))
  24. end
  25.  
  26. function toggleRedstone(side, time)
  27. redstone.setOutput(side, true)
  28. sleep(time)
  29. redstone.setOutput(side, false)
  30. end
  31.  
  32. local args = {...} --command line args
  33.  
  34. if not args[1] then
  35. print("Usage: getlvl <level>")
  36. return
  37. end
  38.  
  39. local liquidLevel = getLiquidForLevel(tonumber(args[1])) - magicnumber
  40. local ticks = liquidLevel / flowrate
  41.  
  42. local tank = peripheral.wrap("left")
  43. local totalTankLiquid = 0
  44.  
  45. print("XP: " .. liquidLevel .. "mB")
  46. print("Ticks: " .. ticks)
  47.  
  48. while true do
  49. toggleRedstone("right", sleeprate)
  50.  
  51. if tank.getTankInfo()[1].contents ~= nil then
  52. totalTankLiquid = totalTankLiquid + tank.getTankInfo()[1].contents.amount
  53. end
  54.  
  55. if totalTankLiquid > liquidLevel then break end
  56.  
  57. toggleRedstone("back", 0.2)
  58. end
  59.  
  60. toggleRedstone("back", 1.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement