Advertisement
FakoTheGreat

Shop List

May 21st, 2014
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. mon = peripheral.wrap("monitor_1")
  2. snsr = peripheral.wrap("right")
  3.  
  4. local shoppers = {}
  5. local shopperCount = 0
  6. local myNames
  7.  
  8. mon.setTextScale(.5)
  9.  
  10. local function checkShoppers (newName)
  11.   local oldShopper = false
  12.   for k,v in ipairs(shoppers) do
  13.     if v == newName then
  14.       oldShopper = true
  15.     end
  16.   end
  17.  
  18.   return oldShopper
  19. end
  20.  
  21. local function considerShopper (shopper)
  22.   if shopperCount == 0 then
  23.     shoppers[1] = shopper
  24.     shopperCount = 1
  25.   else
  26.     if not checkShoppers(shopper) then
  27.       shopperCount = shopperCount + 1
  28.       shoppers[shopperCount] = shopper
  29.     end
  30.   end
  31. end
  32.  
  33. local function displayShoppers ()
  34.   mon.clear()
  35.   mon.setCursorPos(1,1)
  36.   mon.setTextColor(colors.yellow)
  37.   mon.write("Recent Patrons:")
  38.   for a,b in ipairs(shoppers) do
  39.     mon.setTextColor(colors.yellow)
  40.     mon.setCursorPos(1,a+1)
  41.     mon.write("-")
  42.     if b == "Speedynutty68" or b == "ringgeest11" or b == "Flaskee" or b == "nixeagle" or b == "rivrippa" then
  43.       mon.setTextColor(colors.purple)
  44.     elseif b == "slightlynamed" then
  45.       mon.setTextColor(colors.green)
  46.     elseif b == "Professor29" or b=="Sovereignty89" then
  47.       mon.setTextColor(colors.lightBlue)
  48.     elseif b == "zenkmander" then
  49.       mon.setTextColor(colors.gray)
  50.     elseif b == "protobender" then
  51.       mon.setTextColor(colors.orange)
  52.     elseif b == "jaxory" then
  53.       mon.setTextColor(colors.cyan)
  54.     else
  55.       mon.setTextColor(colors.white)
  56.     end
  57.     mon.write(b)
  58.   end
  59. end
  60.  
  61. while true do
  62.   myNames = snsr.getPlayerNames()
  63.  
  64.   for a,b in pairs(myNames) do
  65.     considerShopper(b)
  66.   end
  67.  
  68.   displayShoppers()
  69.  
  70.   os.sleep(.5)
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement