daily pastebin goal
41%
SHARE
TWEET

startup

a guest Sep 13th, 2017 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local chests = peripheral.wrap("bottom")
  2. local recipes =
  3. {
  4.   Mutandis = {"Mandrake Root", "Exhale of the Horned One", "Egg"},
  5.   Mutandis_Extremis = {"Nether Wart", "Mutandis"},
  6.   Otherwhere_Chalk = {"Nether Wart", "Tear of the Goddess", "Ender Pearl", "Ritual Chalk"},
  7.   Infernal_Chalk = {"Nether Wart", "Blaze Powder", "Ritual Chalk"},
  8.   Golden_Chalk = {"Mandrake Root", "Gold Nugget", "Ritual Chalk"},
  9.   Drop_of_Luck = {"Mandrake Root", "Nether Wart", "Tear of the Goddess", "Refined Evil", "Mutandis Extremis"}
  10. }
  11. local items_left = {}
  12. local items_right = {}
  13. local FoundRecipe = {false, "N/A"}
  14. local interval =
  15. {
  16.   Mutandis = 8,
  17.   Mutandis_Extremis = 8,
  18.   Otherwhere_Chalk = 30,
  19.   Infernal_Chalk = 20,
  20.   Golden_Chalk = 20,
  21.   Drop_of_Luck = 44, --halved
  22.   SystemReboot = 16
  23. }
  24. local Error_left = true
  25.  
  26. function CheckIfExists(query, Table)
  27.   local Exists = false
  28.   for key, value in pairs(Table) do
  29.     if(query == value) then
  30.       Exists = true
  31.       break
  32.     end
  33.   end
  34.   return Exists
  35. end
  36.  
  37. for i=1, 10 do
  38.   if(type(chests.callRemote("tile_extrautils_chestfull_name_4","getStackInSlot",i)) ~= "nil") then
  39.     items_left[#items_left + 1] = chests.callRemote("tile_extrautils_chestfull_name_4", "getStackInSlot",i).display_name
  40.   end
  41. end
  42.  
  43. for i=1, 10 do
  44.   if(type(chests.callRemote("tile_extrautils_chestfull_name_5","getStackInSlot",i)) ~= "nil") then
  45.     items_right[#items_right + 1] = chests.callRemote("tile_extrautils_chestfull_name_5","getStackInSlot",i).display_name
  46.   end
  47. end
  48.  
  49. for product, list in pairs(recipes) do
  50.   --print(product.." | "..tostring(#items))
  51.   FoundRecipe[1] = true
  52.   FoundRecipe[2] = product
  53.   if(#items_left == #list) then
  54.     for i=1, #items_left do
  55.       FoundRecipe[1] = FoundRecipe[1] and CheckIfExists(items_left[i], list)
  56.       --print(items_left[i].." | "..tostring(CheckIfExists(items_left[i], list)))
  57.     end
  58.   end
  59.  
  60.   if(FoundRecipe[1] == true) and (#items_left == #list) then
  61.     print("Left chest: Found recipe - "..FoundRecipe[2])
  62.     sleep(0.5)
  63.     print("Transfering items..")
  64.     rs.setAnalogOutput("left",14)
  65.     for i=1, #items_left do
  66.       chests.callRemote("tile_extrautils_chestfull_name_4","pushItemIntoSlot","EAST",i,1,i)
  67.       --chest.pushItemIntoSlot("EAST",i,1,i)
  68.       sleep(0.2)
  69.     end
  70.     sleep(2)
  71.     rs.setAnalogOutput("left",0)
  72.     sleep(interval[FoundRecipe[2]])
  73.     Error_left = false
  74.     break
  75.   end
  76. end
  77.  
  78. if(Error_left) then
  79.   print("Left chest: No valid recipe found!")
  80. end
  81.  
  82. local FoundRecipe = {false, "N/A"}
  83.  
  84. for product, list in pairs(recipes) do
  85.   --print(product.." | "..tostring(#items))
  86.   FoundRecipe[1] = true
  87.   FoundRecipe[2] = product
  88.   if(#items_right == #list) then
  89.     for i=1, #items_right do
  90.       FoundRecipe[1] = FoundRecipe[1] and CheckIfExists(items_right[i], list)
  91.       --print(items_right[i].." | "..tostring(CheckIfExists(items_right[i], list)))
  92.     end
  93.   end
  94.  
  95.   if(FoundRecipe[1] == true) and (#items_right == #list) then
  96.     print("Right chest: Found recipe - "..FoundRecipe[2])
  97.     sleep(0.5)
  98.     print("Transfering items..")
  99.     rs.setAnalogOutput("right",14)
  100.     for i=1, #items_right do
  101.       chests.callRemote("tile_extrautils_chestfull_name_5","pushItemIntoSlot","EAST",i,1,i)
  102.       --chest.pushItemIntoSlot("EAST",i,1,i)
  103.       sleep(0.2)
  104.     end
  105.     sleep(2)
  106.     rs.setAnalogOutput("right",0)
  107.     sleep(interval[FoundRecipe[2]])
  108.     os.reboot()
  109.   end
  110. end
  111.  
  112. print("Right chest: No valid recipe found!")
  113.  
  114. sleep(interval.SystemReboot)
  115. os.reboot()
  116.  
  117.  
  118.  
  119. --local chest_left = peripheral.wrap("left")
  120. --for k,v in pairs(chest_left) do
  121. --  print(tostring(k).." | "..tostring(v))
  122. --end
  123. --chest_left.callRemote(
  124. --"tile_extrautils_chestfull_name_3",
  125. --"pushItemIntoSlot","EAST",1,1,1)
  126.  
  127.  
  128. --print(CheckIfExists("Eg",recipes.Mutandis))
  129.  
  130. --for k,v in pairs(items) do
  131.   --print(k.." | "..v)
  132. --end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top