Spiker985

FTB - Ender Chest Color Assigner

Jun 14th, 2017
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. local hopperSide = "top"
  2. local proxySide = "back"
  3. local rednetSide = "left"
  4. local extractionColor = colors.green
  5. local annihilationPlaneColor = colors.blue
  6. local itemName = "Oak Sapling"
  7.  
  8. local hopper = peripheral.wrap(hopperSide)
  9. local proxy = peripheral.wrap(proxySide)
  10. local name = {}
  11.  
  12. function doWork()
  13.   for i = 1, hopper.getInventorySize() do
  14.     if hopper.getStackInSlot(i) ~= nil then
  15.         if hopper.getStackInSlot(i).display_name ~= itemName then
  16.             name["original"] = hopper.getStackInSlot(i).display_name
  17.             index1 = string.find(name["original"], ",") - 1
  18.             name["color1"] = string.sub(name["original"], 0, index1)
  19.             index2 = string.find(name["original"], ",", index1+3) - 1
  20.             name["color2"] = string.sub(name["original"], index1+3, index2)
  21.             name["color3"] = string.sub(name["original"], index2+3)
  22.            
  23.             print("Set colors")
  24.             proxy.setColorNames(name["color1"], name["color2"], name["color3"])
  25.            
  26.             print("Turn on plane")
  27.             rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), annihilationPlaneColor))
  28.             sleep(1)
  29.            
  30.             print("Turn off plane, turn on extract")
  31.             rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), annihilationPlaneColor))
  32.             rs.setBundledOutput(rednetSide, colors.combine(rs.getBundledOutput(rednetSide), extractionColor))
  33.             sleep(1)
  34.            
  35.             print("Turn off extract")
  36.             rs.setBundledOutput(rednetSide, colors.subtract(rs.getBundledOutput(rednetSide), extractionColor))
  37.         end
  38.     end
  39.   end
  40. end
  41.  
  42. while true do
  43.     sleep(5)
  44.     if hopper.getStackInSlot(1) ~= nil then doWork() end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment