Advertisement
gamerred

autostock.lua

Jan 25th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. local term = require("term")
  4. local clearint = 10
  5. local n = 0
  6. local cc= clearint
  7. local gpu = component.gpu
  8. local max = 32
  9. local nn=0
  10. local a = {}
  11. local b = {}
  12. local bb = {}
  13.  
  14. local rs = component.block_refinedstorage_interface
  15.  
  16. term.clear()
  17.  
  18. local items = {
  19.     {store=64  ,name = "minecraft:diamond",         damage=0,  label = "Diamond"},
  20.     {store=128 ,name = "minecraft:ender_pearl",     damage=0,  label = "Ender Pearl"},
  21.     {store=64  ,name = "enderio:item_alloy_ingot",  damage=1,  label = "Energetic Alloy"},
  22.     {store=64  ,name = "thermalfoundation:material",damage=162,label = "Invar Ingot"},
  23.     {store=64  ,name = "minecraft:iron_ingot",      damage=0,  label = "Iron Ingot"},
  24.     {store=64  ,name = "minecraft:gold_ingot",      damage=0,  label = "Gold Ingot"},
  25.     {store=256 ,name = "tconstruct:edible",         damage=10, label = "Monster Jerky"},
  26.     {store=64  ,name = "enderio:item_alloy_ingot",  damage=5,  label = "Pulsating Iron"},
  27.     {store=1024,name = "minecraft:stonebrick",      damage=0,  label = "Stone Brick"},
  28.     {store=64  ,name = "enderio:item_alloy_ingot",  damage=2,  label = "Vibrant Alloy"}
  29. }
  30.  
  31. while(true) do
  32. local count = #rs.getTasks()
  33.     for i,stack in ipairs(items) do
  34.         if(rs.hasPattern(stack)) then
  35.             local rsStack = rs.getItem(stack)
  36.  
  37.             local toCraft = stack.store;
  38.             if(rsStack ~= nil) then
  39.                 toCraft = toCraft - rsStack.size
  40.             end
  41.  
  42.             if(toCraft > 0) then
  43. n = n + 1
  44.  
  45. if(n >= clearint) then
  46. n = 0
  47. --term.clear()
  48. end
  49.  
  50. local data = "Trying to craft "..toCraft.." more "..stack.label
  51. if(count == 0) then
  52. if(toCraft >= max) then
  53. rs.scheduleTask(stack, max)
  54. else
  55.                 rs.scheduleTask(stack, toCraft)
  56. end
  57. end
  58.             end
  59.         else
  60.             --print("Missing pattern for: " .. stack.label)
  61.         end
  62. if(c ~= n) then
  63. c = n
  64. if((clearint-n) <= 3) then
  65. --print("clearing in " .. (clearint-n).." more interations")
  66. end
  67. end
  68.  
  69. for t,datad in ipairs(items) do
  70. a[t] = datad.label
  71. bb[t] = (datad.store-rs.getItem(datad).size)
  72.  
  73. if(bb[t] < 0) then
  74. b[t] = "Over by "..(-bb[t])
  75. elseif(bb[t]>t) then
  76. b[t] = "Under by "..bb[t]
  77. else
  78. b[t] = "At"
  79. end
  80.  
  81. if(#a[t] > nn) then
  82. nn = #a[t]+1
  83. end
  84. gpu.set(1,t,a[t]..string.rep(" ",nn-#a[t]).."|"..b[t]..string.rep(" ",30-#b[t]))
  85. end
  86.     end
  87.  
  88.     os.sleep(5)
  89. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement