Advertisement
Guest User

Untitled

a guest
Jul 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.61 KB | None | 0 0
  1. local com = require("component")
  2. local inv_c = com.inventory_controller
  3. local craft = com.crafting.craft
  4. local robot = com.robot
  5. local term = require("term")
  6. --local rSlots = {1, 2, 3, 5, 6, 7, 9, 10, 11}
  7.  
  8. local side = 3
  9. local outSide = 0
  10.  
  11. local function getCoin()
  12.   term.clear()
  13.   print("Search coin..")
  14.   local slots = inv_c.getInventorySize(side)
  15.   if slots ~= nil then
  16.     while true do
  17.       for slotN = 1, slots do
  18.         local slot = inv_c.getStackInSlot(side, slotN)
  19.         if slot ~= nil and string.find(slot.name, "Currency:") ~= nil then
  20.           term.clear()
  21.           print("Getting coin..")
  22.           robot.select(1)
  23.           inv_c.suckFromSlot(side, slotN)
  24.           return
  25.         end            
  26.       end
  27.     end
  28.   end
  29. end
  30.  
  31. local stop = false
  32.  
  33. local function clearAll()
  34.   term.clear()
  35.   print("Clearing...")
  36.   for i = 1, 16 do
  37.     local s = inv_c.getStackInInternalSlot(n)
  38.     if s ~= nil then
  39.       if s.name == "Currency:Penny" then
  40.         robot.select(n)
  41.         robot.drop(outSide)
  42.       else
  43.         robot.select(n)
  44.         robot.drop(side)
  45.       end
  46.     end
  47.   end
  48. end
  49.  
  50. robot.select(1)
  51. clearAll()
  52.  
  53. while not stop do
  54.   while robot.count(1) > 0 do
  55.     term.clear()
  56.     print("Crafting...")
  57.     robot.select(13)
  58.     craft(240)
  59.     for i = 13, 16 do
  60.       local slot = inv_c.getStackInInternalSlot(i)
  61.       if slot ~= nil then
  62.         if slot.name == "Currency:Penny" then
  63.           robot.select(i)
  64.           robot.drop(outSide)
  65.         else
  66.           robot.select(i)
  67.           robot.drop(side)
  68.         end
  69.       end
  70.     end
  71.   end
  72.   getCoin()
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement