Advertisement
Marlingaming

CC Tweaked Digitial Items Manager

Feb 11th, 2022 (edited)
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. local tArg = {...}
  2.  
  3. local digitizer = peripheral.find("item_digitizer")
  4.  
  5. function Digitize()
  6. local itemID = digitizer.digitize()
  7. local file = fs.open("ItemList","a")
  8. file.writeLine(itemID)
  9. file.close()
  10. end
  11.  
  12. function Physic(item)
  13. local Content
  14. local file = fs.open("ItemList","a")
  15. local Found = false
  16. repeat
  17. Content = file.readLine()
  18. if Found == false and Content ~= "empty" then
  19. local Item = digitizer.dataID(Content)
  20. if Item.displayName == item then
  21. Found = true
  22. digitizer.rematerialize(Content)
  23. file.ClearLine()
  24. file.writeLine("empty")
  25. end
  26. end
  27. until Content == nil
  28. file.close()
  29. return Found
  30. end
  31.  
  32.  
  33. function ListItems()
  34. term.clear()
  35. term.setCursorPos(1,1)
  36. local file = fs.open("ItemList","r")
  37. local Contents
  38. repeat
  39. Contents = file.readLine()
  40. print(Contents)
  41. until Contents == nil
  42. end
  43.  
  44. if tArg[1] == "Dig" then
  45. Digitize()
  46. elseif tArg[1] == "List" then
  47. ListItems()
  48. elseif tArg[1] == "Phy" then
  49. print("item found? ",Physic(tArg[2]))
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement