Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("top")
- local buckets = 0
- local nextSave = 0
- local function enableDrainer(enable)
- redstone.setOutput("bottom", enable)
- end
- if mon.isColor() then
- mon.setTextColor(colors.yellow)
- end
- mon.clear()
- mon.setCursorPos(1,1)
- mon.write(" CowDrainer 9000")
- mon.setCursorPos(1,2)
- mon.write("------------------")
- if mon.isColor() then
- mon.setTextColor(colors.lightGray)
- end
- mon.setCursorPos(1,4)
- mon.write("Aus Kuh gepresst:")
- local file = fs.open("drainedbuckets", "r")
- if file then
- buckets = buckets + file.readLine()
- file.close()
- end
- if mon.isColor() then
- mon.setTextColor(colors.cyan)
- end
- mon.setCursorPos(2,5)
- mon.write(tostring(buckets).." Eimer")
- enableDrainer(false)
- while true do
- -- while lever is down
- while redstone.getInput("left") do
- enableDrainer(true)
- os.pullEvent("redstone")
- -- if signal from turtle
- if redstone.getInput("back") then
- buckets = buckets +10
- nextSave = nextSave +1
- if (nextSave > 10) then
- file = fs.open("drainedbuckets", "w")
- file.write(buckets)
- file.close()
- nextSave = 0
- end
- mon.clearLine()
- mon.setCursorPos(2,5)
- mon.write(tostring(buckets).." Eimer")
- end
- end
- enableDrainer(false)
- os.pullEvent("redstone")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement