RandomShovel

[CC][OpenPeripheral] Inventory Scanner

Mar 29th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. --[[  Config  ]]--
  2.  
  3. whitelist = true
  4. defaultPlayer = "RandomShovel"
  5.  
  6.  
  7. --[[  Variables  ]]--
  8.  
  9. local sensor = peripheral.wrap("top")
  10.  
  11.  
  12. --[[  Tables  ]]--
  13.  
  14. whitelist = {}
  15.  
  16.  
  17. --[[  Get Nearby Players  ]]--
  18.  
  19. nplay = sensor.getPlayerNames()
  20.  
  21.  
  22. --[[  Get Whitelist  ]]--
  23.  
  24. if fs.exists("dwlist") then
  25.  file = fs.open("dwlist", "r")
  26.  for line in io.lines("dwlist") do
  27.   table.insert(whitelist, line)
  28.  end
  29.  file.close()
  30. else
  31.  file = fs.open("dwlist", "w")
  32.  file.write(defaultPlayer)
  33.  file.close()
  34. end
  35.  
  36.  
  37. --[[  Main  ]]--
  38.  
  39. for a=1, #nplay do
  40.  if whitelist then
  41.   for d = 1, #whitelist do
  42.    if nplay[a] == whitelist[d] then
  43.     printError("Player "..nplay[a].." is whitelisted!")
  44.     protected = true
  45.     break
  46.    else
  47.     curPlay = sensor.getPlayerData(nplay[a])
  48.     protected = false
  49.    end
  50.   end
  51.  else
  52.   curPlay = sensor.getPlayerData(nplay[a])
  53.  end
  54.  if not protected then
  55.   for b=1, #curPlay["inventory"] do
  56.    if curPlay["inventory"][b]["name"] ~= "empty" then
  57.     print("Current Player: "..nplay[a])
  58.     print("Name: "..curPlay["inventory"][b]["name"])
  59.     print("Raw Name: "..curPlay["inventory"][b]["rawName"])
  60.     print("Item ID: "..curPlay["inventory"][b]["id"])
  61.     if curPlay["inventory"][b]["ench"][1] ~= nil then
  62.      print("Enchantments:")
  63.      for c=1, #curPlay["inventory"][b]["ench"] do
  64.       print("["..c.."] "..curPlay["inventory"][b]["ench"][c])
  65.      end
  66.     end
  67.     sleep(2)
  68.     term.clear()
  69.     term.setCursorPos(1, 1)
  70.    else
  71.    end
  72.   end
  73.  end
  74. end
Advertisement
Add Comment
Please, Sign In to add comment