Advertisement
FakoTheGreat

Inventory List PoC

Apr 28th, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 KB | None | 0 0
  1. --Change to match the side or modem name for sensor.
  2. local sensorLoc = "right"
  3.  
  4. --Change to match the side or modem name for monitor.
  5. local monitorLoc = "bottom"
  6.  
  7. --Enter player names to check here. Only works when
  8. --player is online, and names are case-sensitive.
  9. local watchList = {"ringgeest11","Professor29"}
  10.  
  11. --How long to show each inventory before moving on.
  12. local cycleDelay = 5
  13.  
  14.  
  15. --Used by the program, do not adjust.
  16. local snsr = peripheral.wrap(sensorLoc)
  17. local mon = peripheral.wrap(monitorLoc)
  18. local curSpot = 1
  19.  
  20. local function displayInventory (vicName)
  21.   vic = snsr.getPlayerData(vicName)
  22.   for i,j in ipairs(vic["inventory"]) do
  23.     if i < 10 then
  24.       mon.setCursorPos(2,i+2)
  25.     elseif i < 21 then
  26.       mon.setCursorPos(1,i+2)
  27.     else
  28.       mon.setCursorPos(40,i-18)
  29.     end
  30.     local name = j["name"]
  31.     print(name)
  32.     mon.setTextColor(colors.yellow)
  33.     mon.write(tostring(i)..": ")
  34.     mon.setTextColor(colors.white)
  35.     mon.write(name)
  36.   end
  37. end
  38.  
  39. while true do
  40.   if snsr.getPlayerData(watchList[curSpot]) ~= nil then
  41.     mon.clear()
  42.     mon.setTextColor(colors.red)
  43.     mon.setCursorPos(1,1)
  44.     mon.write(watchList[curSpot])
  45.     displayInventory(watchList[curSpot])
  46.     os.sleep(cycleDelay)
  47.   end
  48.   curSpot = curSpot+1
  49.   if curSpot > #watchList then
  50.     curSpot = 1
  51.   end
  52.   os.sleep(0.125)
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement