Advertisement
npexception

milk.tankturtle.pc

Mar 3rd, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local mon = peripheral.wrap("top")
  2. local buckets = 0
  3. local nextSave = 0
  4.  
  5. local function enableDrainer(enable)
  6.   redstone.setOutput("bottom", enable)
  7. end
  8.  
  9. if mon.isColor() then
  10.   mon.setTextColor(colors.yellow)
  11. end
  12.  
  13. mon.clear()
  14. mon.setCursorPos(1,1)
  15. mon.write(" CowDrainer 9000")
  16. mon.setCursorPos(1,2)
  17. mon.write("------------------")
  18. if mon.isColor() then
  19.   mon.setTextColor(colors.lightGray)
  20. end
  21. mon.setCursorPos(1,4)
  22. mon.write("Aus Kuh gepresst:")
  23.  
  24. local file = fs.open("drainedbuckets", "r")
  25. if file then
  26.   buckets = buckets + file.readLine()
  27.   file.close()
  28. end
  29.  
  30. if mon.isColor() then
  31.   mon.setTextColor(colors.cyan)
  32. end
  33.  
  34. mon.setCursorPos(2,5)
  35. mon.write(tostring(buckets).." Eimer")
  36.  
  37. enableDrainer(false)
  38.  
  39. while true do
  40.   -- while lever is down
  41.   while redstone.getInput("left") do
  42.     enableDrainer(true)
  43.     os.pullEvent("redstone")
  44.     -- if signal from turtle
  45.     if redstone.getInput("back") then
  46.       buckets = buckets +10
  47.       nextSave = nextSave +1
  48.       if (nextSave > 10) then
  49.         file = fs.open("drainedbuckets", "w")
  50.         file.write(buckets)
  51.         file.close()
  52.         nextSave = 0
  53.       end
  54.       mon.clearLine()
  55.       mon.setCursorPos(2,5)
  56.       mon.write(tostring(buckets).." Eimer")
  57.     end
  58.   end
  59.   enableDrainer(false)
  60.   os.pullEvent("redstone")
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement