Wassaa

bloody

May 12th, 2020
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.81 KB | None | 0 0
  1. -- Global Declares --
  2. component = require("component")
  3. transpose = component.transposer
  4. term = require("term")
  5. rs = component.redstone
  6. gpu = component.gpu
  7. colors = require("colors")
  8. sides = require("sides")
  9.  
  10. -- Variables --
  11. -- You can change these as needed
  12.  
  13. BloodAltarTier = 1  -- Change manually depending on your Altar level, Default: 5 (Tier: V)
  14.  
  15. slateBCount = 16 -- Blank Slates, Default: 8
  16. slateRCount = 8 -- Reinforced Slates, Default: 8
  17. slateICount = 8 -- Imbued Slates, Default: 4
  18. slateDCount = 8 -- Demonic Slates, Default: 4
  19. slateECount = 2 -- Etherial Slates, Default: 1
  20.  
  21. chestSide = sides.top   -- Default: sides.top (1)
  22. stoneSide = sides.north   -- Default: 2 (Back)
  23. altarSide = sides.west   --Default: 4 (Right)
  24. reserveTankSide = sides.east    --Default: 5 (Left), this is only used if a tank is detected
  25.  
  26. rsInputSide = sides.bottom --Default: 4 (Right), This is right of a computer with a Redstone card or right of a Redstone I/O block
  27.  
  28. stoneSlot = 2  --Default: 10 (Slot 10 is the first export slot for a Refined Storage Interface, Change this as needed)
  29.  
  30. -- Altar slots do not need to be changed, unless WayOfTime add additional inventory slots or tanks to the Blood Altar
  31. altarSlot = 1  
  32. altarTank = 1
  33.  
  34. -- Slate Slots below are the first 5 slots of a chest, change these if you are not using any type of regular chest (NOT tested with other mods like Iron Chests)
  35. slateBSlot = 1
  36. slateRSlot = 2
  37. slateISlot = 3
  38. slateDSlot = 4
  39. slateESlot = 5
  40.  
  41. stackInfo = {}
  42.  
  43. itemInfo = {
  44.     {
  45.         name = "Blank Slate",
  46.         blood = 1000,
  47.         tier = 1
  48.     },
  49.     {
  50.         name = "Reinforced Slate",
  51.         blood = 2000,
  52.         tier = 2
  53.     },
  54.     {
  55.         name = "Imbued Slate",
  56.         blood = 5000,
  57.         tier = 3
  58.     },
  59.     {
  60.         name = "Demonic Slate",
  61.         blood = 15000,
  62.         tier = 4
  63.     },
  64.     {
  65.         name = "Ethereal Slate",
  66.         blood = 30000,
  67.         tier = 5
  68.     }  
  69. }
  70. slateSlot = {
  71.     [1] = slateBSlot,
  72.     [2] = slateRSlot,
  73.     [3] = slateISlot,
  74.     [4] = slateDSlot,
  75.     [5] = slateESlot,
  76. }
  77.  
  78. function setNull(i)
  79.     stackInfo[i].label = itemInfo[i].name
  80.     stackInfo[i].size = 0
  81. end
  82.  
  83. function setStackInfo()
  84.     for i=1, 5 do
  85.         stackInfo[i] = {}
  86.         if transpose.getStackInSlot(chestSide, slateSlot[i]) then
  87.             stackInfo[i].size = transpose.getStackInSlot(chestSide, slateSlot[i]).size
  88.             stackInfo[i].label = transpose.getStackInSlot(chestSide, slateSlot[i]).label
  89.         else
  90.             setNull(i)
  91.         end
  92.     end
  93. end
  94.  
  95. function getTankInfo()
  96.     tInfo = transpose.getFluidInTank(altarSide)
  97.     tankAmount = tInfo[1].amount
  98.     tankCapacity = tInfo[1].capacity
  99.     tankPercent = (tankAmount / tankCapacity) * 100
  100.  
  101.     if term.isAvailable() then
  102.       term.clearLine()
  103.       term.write(string.format("Current Blood Level: %.2f %%, %.0d mb / %.0d mb\n", tankPercent, tankAmount, tankCapacity))
  104.     end
  105. end
  106.  
  107. function getReserveTankInfo()
  108.     rTInfo = transpose.getFluidInTank(reserveTankSide)
  109.     if rTInfo.n > 0 then
  110.         rTankAmount = rTInfo[1].amount
  111.         rTankCapacity = rTInfo[1].capacity
  112.         rTPercent = (rTankAmount / rTankCapacity) * 100
  113.        
  114.         if term.isAvailable() then
  115.             term.clearLine()
  116.             term.write(string.format("Reserve Blood Level: %.2f %%, %.0d mb / %.0d mb\n", rTPercent, rTankAmount, rTankCapacity))
  117.         end
  118.     else
  119.         if term.isAvailable() then
  120.             term.write("No Reserve Tank Detected\n")
  121.         end
  122.     end
  123. end
  124.  
  125. function WriteRSBlood()
  126.     if term.isAvailable() then
  127.         term.clearLine()
  128.         term.write("Blood Creation: ")
  129.         if rs.getInput(rsInputSide) == 0 then
  130.             term.write("True \n")
  131.         else
  132.             term.write("False\n")
  133.         end
  134.     end
  135. end
  136.  
  137. function BlankSlate()
  138.     local crafting = true
  139.     --Move 1 stone from Interface to Blood Altar
  140.     transpose.transferItem(stoneSide, altarSide, 1, stoneSlot, altarSlot)
  141.     while crafting do
  142.         writeToTerm()
  143.         term.write(itemInfo[1].name.."\n")
  144.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[1].name then
  145.             crafting = false
  146.             --Move 1 Blank Slate from Blood Altar to Chest
  147.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateBSlot)
  148.         end
  149.     end
  150. end
  151.    
  152. function ReinforcedSlate()
  153.     local crafting = true
  154.     --Move 1 Blank Slate from Chest to Blood Altar
  155.     transpose.transferItem(chestSide, altarSide, 1, slateBSlot, altarSlot)
  156.     while crafting do
  157.         writeToTerm()
  158.         term.write(itemInfo[2].name.."\n")
  159.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[2].name then
  160.             crafting = false
  161.             --Move 1 Reinforced Slate from Blood Altar to Chest
  162.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateRSlot)
  163.         end
  164.     end
  165. end
  166.    
  167. function ImbuedSlate()
  168.     local crafting = true
  169.     --Move 1 Reinforced Slate from Chest to Blood Altar
  170.     transpose.transferItem(chestSide, altarSide, 1, slateRSlot, altarSlot)
  171.     while crafting do
  172.         writeToTerm()
  173.         term.write(itemInfo[3].name.."\n")
  174.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[3].name then
  175.             crafting = false
  176.             --Move 1 Imbued Slate from Blood Altar to Chest
  177.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateISlot)
  178.         end
  179.     end
  180. end
  181.    
  182. function DemonicSlate()
  183.     local crafting = true
  184.     --Move 1 Imbued Slate from Chest to Blood Altar
  185.     transpose.transferItem(chestSide, altarSide, 1, slateISlot, altarSlot)
  186.     while crafting do
  187.         writeToTerm()
  188.         term.write(itemInfo[4].name.."\n")
  189.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[4].name then
  190.             crafting = false
  191.             --Move 1 Demonic Slate from Blood Altar to Chest
  192.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateDSlot)
  193.         end
  194.     end
  195. end
  196.  
  197. function EtherealSlate()
  198.     local crafting = true
  199.     --move 1 Demonic Slate from chest to Blood Altar
  200.     transpose.transferItem(chestSide, altarSide, 1, slateDSlot, altarSlot)
  201.     while crafting do
  202.        
  203.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[5].name then
  204.             crafting = false
  205.             --Move 1 Ethereal Slate from Blood Altar to Chest
  206.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateESlot)
  207.         end
  208.     end
  209. end
  210.  
  211. function writeToTerm()
  212.     term.setCursor(1,1)
  213.     getTankInfo()
  214.     getReserveTankInfo()
  215.     WriteRSBlood()
  216.     term.clearLine()
  217.     term.write("Making: ")
  218. end
  219.  
  220.  
  221. term.clear()
  222. repeat
  223.     setStackInfo()
  224.     writeToTerm(" ")
  225.     currentTank = transpose.getFluidInTank(altarSide, altarTank).amount
  226.    
  227.     if BloodAltarTier >= itemInfo[1].tier and stackInfo[1].label == itemInfo[1].name and stackInfo[1].size < slateBCount and currentTank >= itemInfo[1].blood then
  228.         BlankSlate()
  229.     elseif BloodAltarTier >= itemInfo[2].tier and stackInfo[2].label == itemInfo[2].name and stackInfo[2].size < slateRCount and currentTank >= itemInfo[2].blood then
  230.         ReinforcedSlate()
  231.     elseif BloodAltarTier >= itemInfo[3].tier and stackInfo[3].label == itemInfo[3].name and stackInfo[3].size < slateICount and currentTank >= itemInfo[3].blood then
  232.         ImbuedSlate()
  233.     elseif BloodAltarTier >= itemInfo[4].tier and stackInfo[4].label == itemInfo[4].name and stackInfo[4].size < slateDCount and currentTank >= itemInfo[4].blood then
  234.         DemonicSlate()
  235.     elseif BloodAltarTier >= itemInfo[5].tier and stackInfo[5].label == itemInfo[5].name and stackInfo[5].size < slateECount and currentTank >= itemInfo[5].blood then
  236.         EtherealSlate()
  237.     end
  238. until event.pull(1) == "interrupted"
Add Comment
Please, Sign In to add comment