Advertisement
CaptainSpaceCat

Inscriber V2

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