Advertisement
CaptainSpaceCat

Inscriber V3

Jun 14th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.99 KB | None | 0 0
  1. local tArgs = {...}
  2. rSide = "right"
  3.  
  4.  
  5. function getType(str)
  6.   if str == "logic" or str == "l" then
  7.     return 2
  8.   elseif str == "calculation" or str == "c" then
  9.     return 3
  10.   elseif str == "engineering" or str == "e" then
  11.     return 4
  12.   end
  13. end
  14.  
  15.  
  16. function inscribe(slot, num)
  17.   insertPress(1)
  18.   insertMaterials(5, num)
  19.   removeProduct(9, num)
  20.   grabPress(1)
  21.   insertPress(slot)
  22.   insertMaterials(slot+4, num)
  23.   removeProduct(slot+8, num)
  24.   grabPress(slot)
  25.   craftMatrix(slot+8, num)
  26.   removeProduct(slot+12, num)
  27.   print("Completed!")
  28. end
  29.  
  30. function insertMaterials(slot, num)
  31.   if num == 1 then
  32.     print("Inserting " .. num .. " material in slot " .. slot)
  33.   else
  34.     print("Inserting " .. num .. " materials in slot " .. slot)
  35.   end
  36.   turtle.select(slot)
  37.   for i = 1, num do
  38.     while not turtle.drop(1) do
  39.     end
  40.   end
  41.   sleep(.5)
  42. end
  43.  
  44. function removeProduct(slot, num)
  45.   if num == 1 then
  46.     print("Removing " .. num .. " product to slot " .. slot)
  47.   else
  48.     print("Removing " .. num .. " products to slot " .. slot)
  49.   end
  50.   turtle.select(slot)
  51.   sleep((num-1)*5.5+1)
  52.   for i = 1, num do
  53.     while not turtle.suckUp(1) do
  54.     end
  55.   end
  56. end
  57.  
  58. function insertPress(slot)
  59.   print("Inserting press in slot " .. slot)
  60.   turtle.select(slot)
  61.   turtle.dropUp()
  62. end
  63.  
  64. function grabPress(slot)
  65.   print("Retrieving press to slot " .. slot)
  66.   turtle.select(slot)
  67.   rs.setAnalogOutput(rSide, 15)
  68.   while not turtle.suckUp() do
  69.   end
  70.   rs.setAnalogOutput(rSide, 0)
  71.   sleep(.5)
  72. end
  73.  
  74. function craftMatrix(slot, num)
  75.   if num == 1 then
  76.     print("Crafting " .. num .. " type " .. (slot-8) .. " matrix")
  77.   else
  78.     print("Crafting " .. num .. " type " .. (slot-8) .. " matrices")
  79.   end
  80.   turtle.select(9)
  81.   turtle.dropDown()
  82.   turtle.select(slot)
  83.   turtle.dropUp()
  84.   turtle.select(13)
  85.   for i = 1, num do
  86.     while not turtle.drop(1) do
  87.     end
  88.   end
  89. end
  90.  
  91. rs.setAnalogOutput(rSide, 0)
  92. for i = 1, #tArgs/2 do
  93.   inscribe(getType(tArgs[2*i-1]), tArgs[2*i])
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement