irnotbeowulf

vending machine

May 4th, 2021 (edited)
768
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mon = peripheral.find("monitor")
  2. chat = peripheral.find("playerDetector")
  3. router = peripheral.find("modularrouters:item_router")
  4. storage = peripheral.find("rsBridge")
  5. barrel = peripheral.find("metalbarrels:diamond_tile")
  6. barrelName = "metalbarrels:diamond_tile_0"
  7. routerName = "modularrouters:item_router_0"
  8. local function eject()
  9.     rs.setAnalogOutput("right",5)
  10.     sleep(4)
  11.     rs.setAnalogOutput("right",0)
  12. end
  13.  
  14. local function dispense(item)
  15.     if router.getItemDetail(1) then
  16.         eject()
  17.     else
  18.         storage.exportItemToChest(barrel.getItemDetail(3), routerName)
  19.     end
  20. end
  21. local function getBarrel(slot)
  22.     if barrel.getItemDetail(slot) then
  23.     return barrel.getItemDetail(slot)
  24.     else return nil
  25.     end
  26. end
  27. local function getInput()
  28.     if router.getItemDetail(1) then
  29.         return router.getItemDetail(1)
  30.     else return nil
  31.     end
  32. end
  33. local function testInput()
  34.     local input = getInput()
  35.     local price = getBarrel(1)
  36.     if input.name == price.name then
  37.         if input.count >= price.count then
  38.             storage.importItemFromChest(input, routerName)
  39.             dispense()
  40.         else print("insufficient")
  41.         end
  42.     else
  43.         print("wrong item")
  44.         eject()
  45.     end
  46. end
  47. while true do
  48. testInput()
  49. sleep(1)
  50. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×