Advertisement
neo34rd

chests.lua

Apr 30th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. function loadValidChests()
  2. local file = fs.open("chest_string_type", "r")
  3. local fileData = {}
  4. line = nil
  5. repeat
  6. line = file.readLine()
  7. if line ~= nil then
  8. fileData[line] = true
  9. end
  10. until line == nil
  11. file.close()
  12. return fileData
  13. end
  14.  
  15.  
  16. function isValidChest(chestType, validChestList)
  17. if validChestList[chestType] ~= nil then
  18. return true
  19. else
  20. return false
  21. end
  22. end
  23.  
  24.  
  25. function getAdjChests(validChestList)
  26. local c = {}
  27. print("Peripherals attached...")
  28. plist = peripheral.getNames()
  29. for i = 1, #plist do
  30. peripheralType = peripheral.getType(plist[i])
  31. print(" ", plist[i], " type: ", peripheralType)
  32. if isValidChest(peripheralType, validChestList) then
  33. c[plist[i]] = peripheral.wrap(plist[i])
  34. end
  35. end
  36. return c
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement