southpole

Crafter

Jul 7th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. --Computer Controlled Crafter by Southp0le
  2. --..with only few recipes.
  3.  
  4. -----------
  5. --Options--
  6. -----------
  7. t = peripheral.wrap("right")
  8.  
  9.  
  10. -------------
  11. --Functions--
  12. -------------
  13. function get(slot)
  14.   ID, amount = t.get(slot)
  15.   if amount>0 then
  16.     if ID>32768 then
  17.       ID=ID%32768
  18.     end
  19.   end
  20.   return ID,amount
  21. end
  22.  
  23. function pulser()
  24.   redstone.setOutput("back",true)
  25.   sleep(0.3)
  26.   redstone.setOutput("back",false)
  27.   sleep(0.3)
  28. end
  29.  
  30. function craft()
  31.   for a=0, 17,1 do
  32.     bolean = false
  33.     while t.craft(a) do
  34.       t.craft(a)
  35.       bolean = true
  36.     end
  37.     if bolean==true then break end
  38.   end
  39. end
  40.  
  41.  
  42.  
  43. ---------
  44. --Cycle--
  45. ---------
  46. while true do
  47.   sleep(5)
  48.   for slot=0,17,1 do
  49.     get(slot)
  50.     if amount>0 then
  51.       if ID==12 or ID==21260 or ID==287 or ID==26350 or ID==1 then
  52.     --xx.
  53.     --xx.
  54.     --...
  55.         t.setPattern(slot,slot,nil,slot,slot,nil,nil,nil,nil)
  56.         craft()
  57.      
  58.       elseif ID==26347 then
  59.     --.x.
  60.     --x.x
  61.     --.x.
  62.         t.setPattern(nil,slot,nil,slot,nil,slot,nil,slot,nil)
  63.         craft()
  64.          
  65.       elseif ID==25286 then
  66.     --xxx
  67.     --xxx
  68.     --xxx
  69.         t.setPattern(slot,slot,slot,slot,slot,slot,slot,slot,slot)
  70.         craft()
  71.  
  72.       elseif ID==13401 then
  73.     --x.x
  74.     --.x.
  75.     --x.x
  76.         t.setPattern(slot,nil,slot,nil,slot,nil,slot,nil,slot)
  77.         craft()
  78.  
  79.       elseif ID==98 then
  80.     --..x
  81.     --.xx
  82.     --xxx
  83.         t.setPattern(nil,nil,slot,nil,slot,slot,slot,slot,slot)
  84.         craft()
  85.    
  86.       elseif ID==296 then
  87.     --xxx
  88.     --...
  89.     --...
  90.         t.setPattern(slot,slot,slot,nil,nil,nil,nil,nil,nil)
  91.         craft()
  92.    
  93.       elseif  ID==37 or ID==38 or ID==1307 then
  94.     ---x..
  95.     --...
  96.     --...
  97.         t.setPattern(slot,nil,nil,nil,nil,nil,nil,nil,nil)
  98.         craft()
  99.  
  100.       else
  101.         print("Error: unknown item for crafting")
  102.         print("Cleaning-Process startet..")
  103.         for i=0,slot+1,1 do
  104.           pulser()
  105.         end
  106.       end
  107.       pulser()
  108.     end
  109.   end
  110. end
Advertisement
Add Comment
Please, Sign In to add comment