Advertisement
60E1CluBSteP127

computercraft x botania mana farm

Feb 15th, 2025 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | Gaming | 0 0
  1. -- Installation: pastebin get bm6bkTFL manafarm.lua
  2.  
  3. local flower = "right"
  4. local pool = "left"
  5. local alarm = "back"
  6. local out = "top"
  7.  
  8. --[[
  9. Maximum fill level of the pool
  10. Time constant (seconds per level)
  11. --]]
  12.  
  13. local pool_maxlvl = 14
  14. local flower_tconst = 20
  15.  
  16. -- Reset all outputs
  17. rs.setOutput(alarm,false)
  18. rs.setOutput(out,false)
  19.  
  20. -- Feed lava to the flower as long as the pool is not full
  21. while rs.getAnalogInput(pool) < pool_maxlvl do
  22.     -- Turn output on -> give one lava)
  23.     rs.setOutput(out,true)
  24.     sleep(1)
  25.     rs.setOutput(out,false)
  26.     sleep(8) -- slower pump so increased time to 8s
  27.     -- Wait for the flower to output the timeout length
  28.     -- Disregard any events while the flower is outputting zero
  29.     while not rs.getInput(flower) do os.pullEvent("redstone") end
  30.     -- Calculate timeout length and wait for it + 10 secs
  31.     local waitTime = rs.getAnalogInput(flower) * flower_tconst + 10
  32.     print(string.format('Waiting %u s',waitTime))
  33.     sleep(waitTime)
  34. end
  35.  
  36. -- If the pool fills, sound the alarm
  37. rs.setOutput(alarm,true)
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement