JereTheJuggler

slimyFerns.lua

Nov 26th, 2021 (edited)
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. ItemThresholds={
  2.     bonemeal=64,
  3.     enderDust=64,
  4.     gunpowder=64
  5. }
  6.  
  7. ItemNames={
  8.     bonemeal="minecraft:bone_meal",
  9.     enderDust="appliedenergistics2:ender_dust",
  10.     gunpowder="minecraft:gunpowder"
  11. }
  12.  
  13. Peripherals={
  14.     bonemealDrawer=nil,
  15.     enderDustDrawer=nil,
  16.     gunpowderDrawer=nil,
  17.     wrapAll=function(self)
  18.         for _,name in ipairs(peripheral.getNames()) do
  19.             local t = peripheral.getType(name)
  20.             if t == "standardDrawer" then
  21.                 local drawer = peripheral.wrap(name)
  22.                 drawer.name = name
  23.                 local item = drawer.getItemDetail(1)
  24.                 if item.name == ItemNames.bonemeal then
  25.                     self.bonemealDrawer = drawer
  26.                 elseif item.name == ItemNames.enderDust then
  27.                     self.enderDustDrawer = drawer
  28.                 elseif item.name == ItemNames.gunpowder then
  29.                     self.gunpowderDrawer = drawer
  30.                 end
  31.             end
  32.         end
  33.         if self.bonemealDrawer == nil then
  34.             error("Could not find bonemeal drawer")
  35.         elseif self.enderDustDrawer == nil then
  36.             error("Could not find ender dust drawer")
  37.         elseif self.gunpowderDrawer == nil then
  38.             error("Could not find gunpowder drawer")
  39.         end
  40.     end
  41. }
  42.  
  43. function setColorOutput(color,output)
  44.     if output then
  45.         redstone.setBundledOutput("bottom",colors.combine(redstone.getBundledOutput("bottom"),color))
  46.     else
  47.         redstone.setBundledOutput("bottom",colors.subtract(redstone.getBundledOutput("bottom"),color))
  48.     end
  49. end
  50.  
  51. Peripherals:wrapAll()
  52.  
  53. Checks={
  54.     {
  55.         perip=Peripherals.bonemealDrawer,
  56.         threshold=ItemThresholds.bonemeal,
  57.         color=colors.blue
  58.     },{
  59.         perip=Peripherals.enderDustDrawer,
  60.         threshold=ItemThresholds.enderDust,
  61.         color=colors.purple
  62.     },{
  63.         perip=Peripherals.gunpowderDrawer,
  64.         threshold=ItemThresholds.gunpowder,
  65.         color=colors.lime
  66.     }
  67. }
  68.  
  69. while true do
  70.     for _,check in ipairs(Checks) do
  71.         setColorOutput(check.color,check.perip.getItemDetail(1).count >= check.threshold)
  72.     end
  73.     sleep(5)
  74. end
Add Comment
Please, Sign In to add comment