Advertisement
hypnotizd

Hypno's Blood Magic Code BETA ;-)

Apr 15th, 2015
4,122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.02 KB | None | 0 0
  1. ----------------------------------------------------------
  2. -- Hypno's Blood Magic Code BETA ;-)                    --
  3. --                                                      --
  4. -- Minecraft HermitCraft FTB Infinity Episode TBA       --
  5. -- https://www.youtube.com/watch?v=TBA                  --
  6. --                                                      --
  7. -- YouTube Channel http://youtube.com/hypnotizd         --
  8. ----------------------------------------------------------
  9.  
  10. --    BACK: Blood Altar
  11. --   FRONT: Redstone signal INPUT
  12. --    LEFT: Redstone signal OUTPUT
  13. -- MONITOR: Recommended, but optional.
  14. --          Connect using modem/network cable or
  15. --          directly touching computer
  16.  
  17. local mon = {}
  18. local hasMon = false
  19. local hasRMon = false
  20. local rMonName = ""
  21. local directions = {"top", "bottom", "front", "back", "left", "right"}
  22. local hasBA = false
  23. local bADir = ""
  24. local altar = peripheral.wrap("back")
  25. local monitor = peripheral.wrap("top")
  26.  
  27. local function findPeripherals()
  28.   for k, v in pairs(peripheral.getNames()) do
  29.     if string.find(v, "monitor") then
  30.       hasMon = true
  31.       hasRMon = true
  32.       rMonName = v
  33.       print("INFO: Found remote "..v)
  34.       os.sleep(1)
  35.     end
  36.   end
  37. end
  38.  
  39. local function findMon()
  40.   if hasRMon then return end
  41.   for k, v in pairs(directions) do
  42.     local p = peripheral.wrap(v)
  43.     if p ~= nil then
  44.       if string.find(peripheral.getType(v), "monitor") then
  45.         mon = p
  46.         hasMon = true
  47.         return
  48.       end
  49.     end
  50.   end
  51.   print("WARNING: No monitor detected!")
  52.   os.sleep(5)
  53. end
  54.  
  55. local function monClear()
  56.   if hasMon then
  57.     if hasRMon then
  58.       peripheral.call(rMonName, "setCursorPos", 1, 1)
  59.       peripheral.call(rMonName, "clear")
  60.       peripheral.call(rMonName, "setTextScale", 1)
  61.     else
  62.       mon.setCursorPos(1, 1)
  63.       mon.clear()
  64.       mon.setTextScale(1)
  65.     end
  66.   else
  67.     term.clear()
  68.     term.setCursorPos(1, 1)
  69.   end
  70. end
  71.  
  72. local function monWrite(x, y, text)
  73.   if hasMon then
  74.     if hasRMon then
  75.       peripheral.call(rMonName, "setCursorPos", x, y)
  76.       peripheral.call(rMonName, "write", text)
  77.     else
  78.       mon.setCursorPos(x, y)
  79.       mon.write(text)
  80.     end
  81.   else
  82.     term.setCursorPos(x, y)
  83.     term.write(text)
  84.   end
  85. end
  86.  
  87. local function init()
  88.   term.clear()
  89.   term.setCursorPos(1, 1)
  90.   findPeripherals()
  91.   findMon()
  92.   monClear()
  93. end
  94.  
  95. local function displayInfo()
  96.   local capacity = altar.getInfo().capacity
  97.   local type = altar.getInfo().contents.rawName
  98.   local amount = altar.getInfo().contents.amount
  99.  
  100.   monClear()
  101.   monWrite(1,1,type..":")
  102.   monWrite(1,2,amount.."/"..capacity)
  103. end
  104.  
  105. local function getRedstoneInput()
  106.   return rs.getAnalogInput("front")
  107. end
  108.  
  109. init()
  110.  
  111. while true do
  112.   displayInfo()
  113.   local strength = getRedstoneInput()
  114.  
  115.   if (strength < 5) then
  116.     local i = 15
  117.     rs.setOutput("left", true)
  118.     os.sleep(.5)
  119.     rs.setOutput("left", false)
  120.     while i > 0 do
  121.       displayInfo()
  122.       i = i - 1
  123.       os.sleep(1)
  124.     end
  125.   end
  126.   os.sleep(1)
  127. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement