Advertisement
GooGoo

checkMana - ComputerCraft Computer Program

Apr 21st, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. --[[
  2. Botania mana pool checker. version 1.0 by ThaWade.
  3. Use with dropCoal program found > http://pastebin.com/cwak5D9S
  4. --You could add for example a leftInput, rightOutput and control two turtles with one computer.
  5. ]]
  6. local inputSide = "front"--side the computer is getting redstone signal from comparator.
  7. local outputSide = "back"--side the computer is outputing to the turtle.
  8. local recheckTime = 60--time the turtle waits between rechecks once it determines a redstone state.
  9. local timesRan = 0--just for my personal amusement. Can be removed along with lines 29 and 30. If you don't like it.
  10.  
  11. function clearTerm()
  12.     term.clear()
  13.     term.setCursorPos(1,1)
  14. end
  15.  
  16. function checkManaPool()
  17.     if redstone.getAnalogInput(inputSide) < 15 then
  18.         print("Mana pool not full. Turning ON Redstone signal.")
  19.         redstone.setOutput(outputSide,true)--turn on redstone signal
  20.     elseif redstone.getAnalogInput(inputSide) == 15 then--elseif mana pool is full then
  21.         print("Mana pool full. Turning OFF Redstone signal.")
  22.         redstone.setOutput(outputSide,false)
  23.     end
  24. end
  25.  
  26. while true do
  27.     clearTerm()
  28.     checkManaPool()
  29.     timesRan = timesRan + 1
  30.     print("Times ran: " ..timesRan)
  31.     print("Sleeping... recheck in " ..recheckTime.. " seconds.")
  32.     sleep(recheckTime)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement