Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Installation: pastebin get bm6bkTFL manafarm.lua
- local flower = "right"
- local pool = "left"
- local alarm = "back"
- local out = "top"
- --[[
- Maximum fill level of the pool
- Time constant (seconds per level)
- --]]
- local pool_maxlvl = 14
- local flower_tconst = 20
- -- Reset all outputs
- rs.setOutput(alarm,false)
- rs.setOutput(out,false)
- -- Feed lava to the flower as long as the pool is not full
- while rs.getAnalogInput(pool) < pool_maxlvl do
- -- Turn output on -> give one lava)
- rs.setOutput(out,true)
- sleep(1)
- rs.setOutput(out,false)
- sleep(8) -- slower pump so increased time to 8s
- -- Wait for the flower to output the timeout length
- -- Disregard any events while the flower is outputting zero
- while not rs.getInput(flower) do os.pullEvent("redstone") end
- -- Calculate timeout length and wait for it + 10 secs
- local waitTime = rs.getAnalogInput(flower) * flower_tconst + 10
- print(string.format('Waiting %u s',waitTime))
- sleep(waitTime)
- end
- -- If the pool fills, sound the alarm
- rs.setOutput(alarm,true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement