Advertisement
xKevinn

ME Retriever

Oct 4th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. print("ME-retriever online.")
  4. print("")
  5. print("Activity log:")
  6.  
  7. chat = peripheral.wrap("top")
  8. me = peripheral.wrap("left")
  9.  
  10. totalCount = 0
  11. while true do  
  12.     Event,Person,Message = os.pullEvent("chat")
  13.     local string = {}
  14.  
  15.     for var in Message:gmatch("%w+") do
  16.         table.insert(string,var)
  17.     end
  18.    
  19.     intCheckQty = tonumber(string[3])
  20.     intCheckID = tonumber(string[2])
  21.    
  22.     if intCheckID == nil then
  23.         intCheckID = 0
  24.     end
  25.    
  26.     if string[4] ~= nil then
  27.         intCheckMetadata = tonumber(string[4])
  28.         if intCheckMetadata == nil then
  29.             intCheckMetadata = 0
  30.         end
  31.         intCheckID = (intCheckMetadata * 32768) + intCheckID
  32.     end
  33.  
  34.     if string[4] == nil then
  35.         intCheckMetadata = 0
  36.     end
  37.  
  38.     if string[1] == "gimme" and intCheckID > 0 then
  39.         totalCount = totalCount + 1
  40.         me.retrieve(intCheckID,intCheckQty,1)
  41.         if intCheckMetadata ~= 0 then
  42.             final = (intCheckQty.."x of "..string[2]..":"..intCheckMetadata)
  43.         else
  44.             final = (intCheckQty.."x of "..string[2])
  45.         end
  46.         print(totalCount..". "..Person.." retrieved "..final)
  47.     end
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement