Advertisement
MinoCraft72

Botania Mana Generator

May 22nd, 2022 (edited)
1,308
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Mana Generator Program V2 by MinoCraft72
  2. -- Coded & Tested with:
  3.    -- MineCraft 1.8.9 - MineCraft 1.18.2
  4.    -- ComputerCraft 1.79 - CC-Tweaked 1.100.5
  5.    -- Botania Unofficial r1.8-299 - Botania 1.18.2-431
  6.  
  7. -- Config:
  8.  
  9.   rsOutput = "right" -- dispenser activation
  10.   compSide = "left"  -- comparator side
  11.   detect_m = "top" -- not used
  12.   genType = "entro" -- Can use "endo" or "entro"
  13.   flower = 4 -- numbers of flowers
  14.   waitT = 40 -- waiting time between 2 drop (20s -> Endo ; 40s -> Entro)
  15.   rsRun = 12 -- analogique redstone signal to generate mana
  16.   pulseT = 2 -- drop timer setting (1s -> Endo ; 2s -> Entro)
  17.  
  18.  
  19.   useMon = true -- set to true if using monitor
  20.   monSide = "monitor_0" -- monitor side
  21.  
  22. -- Prog:
  23.  
  24.   function comparator()
  25.    rsIn = rs.getAnalogInput(compSide)
  26.     if rsIn < rsRun then
  27.      genMana = true
  28.     elseif rsIn == 15 then
  29.      genMana = false
  30.     end    
  31.    print(genMana)
  32.   end
  33.  
  34.   function dropItem()
  35.     if genMana then
  36.      term.setCursorPos(1,5)
  37.       for n = 1,flower do
  38.        sleep(0)
  39.        term.setTextColor(colors.orange)  
  40.        term.clearLine()
  41.        print("Item dropped for Flower #"..n)
  42.        rs.setOutput(rsOutput,true)
  43.        sleep(1)
  44.        rs.setOutput(rsOutput,false)
  45.        sleep(pulseT)
  46.       end
  47.      sleep(3)
  48.     end
  49.   end
  50.  
  51.   function dropTimer()
  52.     for t = waitT, 0, -1 do
  53.      term.setCursorPos(1,4)
  54.      term.clearLine()
  55.      term.setTextColor(colors.white)
  56.      write("Waiting Time: ")
  57.      term.setTextColor(colors.orange)
  58.      print(t)
  59.         monitor()
  60.      sleep(1)
  61.     end    
  62.   end  
  63.  
  64.   function entropinum()
  65.     if genMana then
  66.       for f = 1,flower do
  67.        rs.setOutput(rsOutput,true)
  68.        sleep(1)
  69.        rs.setOutput(rsOutput,false)
  70.        sleep(pulseT)
  71.        print(f)
  72.       end
  73.      sleep(10)    
  74.     end
  75.   end
  76.  
  77.   function screen()
  78.    term.clear()
  79.    term.setTextColor(colors.white)
  80.    write("Mana Pool: ")
  81.    percent = math.ceil((100 * rs.getAnalogInput(compSide))/ 15)
  82.    term.setTextColor(colors.orange)
  83.    write(percent.."% - ("..rs.getAnalogInput(compSide)..")")
  84.     for l = 5, (5+flower) do
  85.      term.setCursorPos(1,l)
  86.      term.clearLine()
  87.     end
  88.    term.setTextColor(colors.white)
  89.   end
  90.  
  91.   function monitor()
  92.     if useMon then
  93.      mon = peripheral.wrap(monSide)
  94.      xMax,yMax = mon.getSize()
  95.      mon.clear()
  96.      term.setCursorPos(1,1)
  97.      mon.setCursorPos(1,1)
  98.      mon.write("Mana")
  99.      --print(xMax..","..yMax)
  100.      percent = math.ceil((100 * rs.getAnalogInput(compSide))/ 15)
  101.      lineMax = yMax - rs.getAnalogInput(compSide)
  102.       if percent >= 0 and percent < 25 then
  103.        textColor = colors.red
  104.       elseif percent >= 25 and percent < 50 then
  105.        textColor = colors.orange
  106.       elseif percent >= 50 and percent < 75 then
  107.        textColor = colors.yellow
  108.       elseif percent >= 75 then
  109.        textColor = colors.blue
  110.       end
  111.       if percent > 0 then
  112.        pLine = lineMax+1
  113.       else
  114.        pLine = lineMax
  115.       end
  116.       for i = lineMax,yMax do
  117.        mon.setCursorPos(1,i)
  118.        mon.setBackgroundColor(colors.lightBlue)
  119.        mon.write("       ")
  120.       end
  121.      mon.setCursorPos(2,pLine)
  122.      mon.setTextColor(textColor)
  123.      mon.write(percent.."%")
  124.      mon.setBackgroundColor(colors.black)
  125.      mon.setTextColor(colors.white)
  126.     end
  127.   end
  128.  
  129. while true do
  130.  sleep(0)
  131.  term.clear()
  132.  term.setCursorPos(1,3)
  133.  comparator()
  134.  screen()
  135.  monitor()
  136.   if genType == "endo" then
  137.    dropItem()
  138.    dropTimer()
  139.   elseif genType == "entro" then
  140.    entropinum()
  141.   end
  142.  term.setTextColor(colors.white)
  143.  sleep(0.5)
  144. end
  145.  
Advertisement
RAW Paste Data Copied
Advertisement