Advertisement
scottrot1

Code1

Oct 17th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. local arg1 = ...
  2. local id = {}
  3. local meta = {}
  4. local name = {}
  5. local files = {[1]="dump"}
  6. local i = 0
  7. local dictionary = {}
  8.  
  9. for x=1,#files do
  10.  
  11. local file = fs.open(files[x],"r")
  12.  
  13. repeat
  14. i=i+1
  15. local line = file:readLine()
  16. id[i] = line
  17. line = file:readLine()
  18. meta[i] = line
  19. line = file:readLine()
  20. name[i] = line
  21. until not line
  22.  
  23. end
  24.  
  25. local table = {["id"]=id,["meta"]=meta,["name"]=name}
  26.  
  27. local search = arg1
  28. local idlist = ""
  29. local recursionCheck = ""
  30.  
  31. for i=1,#table["id"] do
  32. --dictionary[table["id"][i].."~"..table["meta"][i]]=table["name"][i]
  33. if string.find(string.upper(table["name"][i]),string.upper(search)) then
  34. idlist = idlist..table["id"][i].."~"..table["meta"][i].." "
  35. end
  36. end
  37.  
  38. local file = fs.open("idlist","w")
  39. file.write(idlist)
  40. file.close()
  41. --file = fs.open("dictionary","w")
  42. --file.write(textutils.serialise(dictionary))
  43. --file.close()
  44.  
  45. local me = peripheral.wrap("left")
  46. local available = me.getAvailableItems()
  47. local id = {}
  48. local meta = {}
  49. local size = {}
  50. local table = {["id"]=id,["meta"]=meta,["size"]=size}
  51.  
  52. for i,table in pairs(available) do
  53. for k,item in pairs(table) do
  54. if(k=="size" or k=="fingerprint") then
  55. if type(item) == "table" then
  56. id[i]=item["id"]
  57. meta[i]=item["dmg"]
  58. else
  59. size[i]=item
  60. end
  61. end
  62. end
  63. end
  64.  
  65. local file = fs.open("idlist","r")
  66. local idlist = file.readAll()
  67. file.close()
  68. file = fs.open("dictionary","r")
  69. local dictionary = textutils.unserialise(file.readAll())
  70. file.close()
  71.  
  72. for i=1,#table["id"] do
  73. local idstring = table["id"][i].."~"..table["meta"][i]
  74. if string.find(idlist,idstring) then
  75. print(dictionary[idstring].." x "..table["size"][i])
  76. end
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement