Advertisement
Haybale100

[OC] BloodCtrl

Sep 18th, 2018
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.75 KB | None | 0 0
  1. --[[
  2. BloodCtrl
  3. Automated Blood Magic Slate Creation
  4. Version: 0.1.1
  5. Author: Haybale100
  6. License: CC BY 4.0
  7.  
  8. How to use: https://oc.cil.li/index.php?/topic/1736-bloodctrl-v01-automated-blood-magic-slate-creation/
  9. ]]
  10.  
  11. -- Variables --
  12. -- You can change these as needed
  13.  
  14. BloodAltarTier = 5  -- Change manually depending on your Altar level, Default: 5 (Tier: V)
  15.  
  16. slateBCount = 8 -- Blank Slates, Default: 8
  17. slateRCount = 8 -- Reinforced Slates, Default: 8
  18. slateICount = 8 -- Imbued Slates, Default: 4
  19. slateDCount = 8 -- Demonic Slates, Default: 4
  20. slateECount = 2 -- Etherial Slates, Default: 1
  21.  
  22. chestSide = sides.top   -- Default: sides.top (1)
  23. stoneSide = sides.back   -- Default: 2 (Back)
  24. altarSide = sides.right   --Default: 4 (Right)
  25. reserveTankSide = sides.left    --Default: 5 (Left), this is only used if a tank is detected
  26.  
  27. rsInputSide = sides.bottom --Default: 4 (Right), This is right of a computer with a Redstone card or right of a Redstone I/O block
  28.  
  29. stoneSlot = 10  --Default: 10 (Slot 10 is the first export slot for a Refined Storage Interface, Change this as needed)
  30.  
  31. -- Altar slots do not need to be changed, unless WayOfTime add additional inventory slots or tanks to the Blood Altar
  32. altarSlot = 1  
  33. altarTank = 1
  34.  
  35. -- 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)
  36. slateBSlot = 1
  37. slateRSlot = 2
  38. slateISlot = 3
  39. slateDSlot = 4
  40. slateESlot = 5
  41.  
  42.  
  43.  
  44.  
  45. --||    DON'T CHANGE ANYTHING BELOW UNLESS YOU KNOW WHAT YOUR DOING!    ||
  46.  
  47. -- Global Declares --
  48. component = require("component")
  49. transpose = component.transposer
  50. term = require("term")
  51. rs = component.redstone
  52. gpu = component.gpu
  53. sides = require("sides")
  54. colors = require("colors")
  55.  
  56. stackInfo = {}
  57.  
  58. itemInfo = {
  59.     {
  60.         name = "Blank Slate",
  61.         blood = 1000,
  62.         tier = 1
  63.     },
  64.     {
  65.         name = "Reinforced Slate",
  66.         blood = 2000,
  67.         tier = 2
  68.     },
  69.     {
  70.         name = "Imbued Slate",
  71.         blood = 5000,
  72.         tier = 3
  73.     },
  74.     {
  75.         name = "Demonic Slate",
  76.         blood = 15000,
  77.         tier = 4
  78.     },
  79.     {
  80.         name = "Ethereal Slate",
  81.         blood = 30000,
  82.         tier = 5
  83.     }  
  84. }
  85.  
  86. function SetStackInfoBasic()
  87.     stackInfo[1] = transpose.getStackInSlot(chestSide, slateBSlot)
  88. end
  89.  
  90. function SetStackInfoReinforced()
  91.     stackInfo[2] = transpose.getStackInSlot(chestSide, slateRSlot)
  92. end
  93.  
  94. function SetStackInfoImbued()
  95.     stackInfo[3] = transpose.getStackInSlot(chestSide, slateISlot)
  96. end
  97.  
  98. function SetStackInfoDemonic()
  99.     stackInfo[4] = transpose.getStackInSlot(chestSide, slateDSlot)
  100. end
  101.  
  102. function SetStackInfoEthereal()
  103.     stackInfo[5] = transpose.getStackInSlot(chestSide, slateESlot)
  104. end
  105.  
  106. function SetDefaultStackInfo()
  107.     if pcall(SetStackInfoBasic) then ;
  108.     else
  109.         stackInfo[1].label = itemInfo[1].name
  110.         stackInfo[1].size = 0
  111.     end
  112.     if pcall(SetStackInfoReinforced) then ;
  113.     else
  114.         stackInfo[2].label = itemInfo[2].name
  115.         stackInfo[2].size = 0
  116.     end
  117.     if pcall(SetStackInfoImbued) then ;
  118.     else
  119.         stackInfo[3].label = itemInfo[3].name
  120.         stackInfo[3].size = 0
  121.     end
  122.     if pcall(SetStackInfoDemonic) then ;
  123.     else
  124.         stackInfo[4].label = itemInfo[4].name
  125.         stackInfo[4].size = 0
  126.     end
  127.     if pcall(SetStackInfoEthereal) then ;
  128.     else
  129.         stackInfo[5].label = itemInfo[5].name
  130.         stackInfo[5].size = 0
  131.     end
  132. end
  133.  
  134. function getTankInfo()
  135.     tInfo = transpose.getFluidInTank(altarSide)
  136.     tankAmount = tInfo[1].amount
  137.     tankCapacity = tInfo[1].capacity
  138.     tankPercent = (tankAmount / tankCapacity) * 100
  139.  
  140.     if term.isAvailable() then
  141.       term.clearLine()
  142.       term.write(string.format("Current Blood Level: %.2f %%, %.0d mb / %.0d mb\n", tankPercent, tankAmount, tankCapacity))
  143.     end
  144. end
  145.  
  146. function getReserveTankInfo()
  147.     rTInfo = transpose.getFluidInTank(reserveTankSide)
  148.     if rTInfo.n > 0 then
  149.         rTankAmount = rTInfo[1].amount
  150.         rTankCapacity = rTInfo[1].capacity
  151.         rTPercent = (rTankAmount / rTankCapacity) * 100
  152.        
  153.         if term.isAvailable() then
  154.             term.clearLine()
  155.             term.write(string.format("Reserve Blood Level: %.2f %%, %.0d mb / %.0d mb\n", rTPercent, rTankAmount, rTankCapacity))
  156.         end
  157.     else
  158.         if term.isAvailable() then
  159.             term.write("No Reserve Tank Detected\n")
  160.         end
  161.     end
  162. end
  163.  
  164. function WriteRSBlood()
  165.     if term.isAvailable() then
  166.         term.clearLine()
  167.         term.write("Blood Creation: ")
  168.         if rs.getInput(rsInputSide) == 0 then
  169.             term.write("True \n")
  170.         else
  171.             term.write("False\n")
  172.         end
  173.     end
  174. end
  175.  
  176. function BlankSlate()
  177.     local crafting = true
  178.     --Move 1 stone from Interface to Blood Altar
  179.     transpose.transferItem(stoneSide, altarSide, 1, stoneSlot, altarSlot)
  180.     while crafting do
  181.         writeToTerm()
  182.         term.write(itemInfo[1].name.."\n")
  183.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[1].name then
  184.             crafting = false
  185.             --Move 1 Blank Slate from Blood Altar to Chest
  186.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateBSlot)
  187.         end
  188.     end
  189. end
  190.    
  191. function ReinforcedSlate()
  192.     local crafting = true
  193.     --Move 1 Blank Slate from Chest to Blood Altar
  194.     transpose.transferItem(chestSide, altarSide, 1, slateBSlot, altarSlot)
  195.     while crafting do
  196.         writeToTerm()
  197.         term.write(itemInfo[2].name.."\n")
  198.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[2].name then
  199.             crafting = false
  200.             --Move 1 Reinforced Slate from Blood Altar to Chest
  201.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateRSlot)
  202.         end
  203.     end
  204. end
  205.    
  206. function ImbuedSlate()
  207.     local crafting = true
  208.     --Move 1 Reinforced Slate from Chest to Blood Altar
  209.     transpose.transferItem(chestSide, altarSide, 1, slateRSlot, altarSlot)
  210.     while crafting do
  211.         writeToTerm()
  212.         term.write(itemInfo[3].name.."\n")
  213.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[3].name then
  214.             crafting = false
  215.             --Move 1 Imbued Slate from Blood Altar to Chest
  216.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateISlot)
  217.         end
  218.     end
  219. end
  220.    
  221. function DemonicSlate()
  222.     local crafting = true
  223.     --Move 1 Imbued Slate from Chest to Blood Altar
  224.     transpose.transferItem(chestSide, altarSide, 1, slateISlot, altarSlot)
  225.     while crafting do
  226.         writeToTerm()
  227.         term.write(itemInfo[4].name.."\n")
  228.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[4].name then
  229.             crafting = false
  230.             --Move 1 Demonic Slate from Blood Altar to Chest
  231.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateDSlot)
  232.         end
  233.     end
  234. end
  235.  
  236. function EtherealSlate()
  237.     local crafting = true
  238.     --move 1 Demonic Slate from chest to Blood Altar
  239.     transpose.transferItem(chestSide, altarSide, 1, slateDSlot, altarSlot)
  240.     while crafting do
  241.        
  242.         if transpose.getStackInSlot(altarSide, altarSlot).label == itemInfo[5].name then
  243.             crafting = false
  244.             --Move 1 Ethereal Slate from Blood Altar to Chest
  245.             transpose.transferItem(altarSide, chestSide, 1, altarSlot, slateESlot)
  246.         end
  247.     end
  248. end
  249.  
  250. function writeToTerm()
  251.     term.setCursor(1,1)
  252.     getTankInfo()
  253.     getReserveTankInfo()
  254.     WriteRSBlood()
  255.     term.clearLine()
  256.     term.write("Making: ")
  257. end
  258.  
  259.  
  260. term.clear()
  261. while true do
  262.     SetDefaultStackInfo()
  263.     writeToTerm(" ")
  264.    
  265.     currentTank = transpose.getFluidInTank(altarSide, altarTank).amount
  266.    
  267.     if BloodAltarTier >= itemInfo[1].tier and stackInfo[1].label == itemInfo[1].name and stackInfo[1].size < slateBCount and currentTank >= itemInfo[1].blood then
  268.         BlankSlate()
  269.     elseif BloodAltarTier >= itemInfo[2].tier and stackInfo[2].label == itemInfo[2].name and stackInfo[2].size < slateRCount and currentTank >= itemInfo[2].blood then
  270.         ReinforcedSlate()
  271.     elseif BloodAltarTier >= itemInfo[3].tier and stackInfo[3].label == itemInfo[3].name and stackInfo[3].size < slateICount and currentTank >= itemInfo[3].blood then
  272.         ImbuedSlate()
  273.     elseif BloodAltarTier >= itemInfo[4].tier and stackInfo[4].label == itemInfo[4].name and stackInfo[4].size < slateDCount and currentTank >= itemInfo[4].blood then
  274.         DemonicSlate()
  275.     elseif BloodAltarTier >= itemInfo[5].tier and stackInfo[5].label == itemInfo[5].name and stackInfo[5].size < slateECount and currentTank >= itemInfo[5].blood then
  276.         EtherealSlate()
  277.     end
  278. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement