Megaddd

Megaddd - my list functions - ComputerCraft

Jun 12th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. --file to be saved as 'mlf' in root
  2.  
  3. function sepPairs(vInput,mode)
  4.     local a = {}
  5.     local b = {}
  6.     local index = 1
  7.     for i,o in pairs(vInput) do
  8.         a[index] = i
  9.         b[index] = o
  10.         index = index + 1
  11.     end
  12.     if mode == nil or mode == 2 then
  13.         return b
  14.     else
  15.         return a
  16.     end
  17. end
  18.  
  19. function matchArgs(maInput,separators)
  20.     local maTemp = {}
  21.     for i in string.gmatch(maInput,separators) do
  22.         table.insert(maTemp,i)
  23.     end
  24.     return maTemp
  25. end
  26.  
  27. function findMember(member, memberList)
  28.     if memberList[1] ~= nil then
  29.         local foundAtIndex = 0
  30.         for i=#memberList,1,-1 do
  31.             foundAtIndex = foundAtIndex + 1
  32.             if tostring(member) == tostring(memberList[i]) then
  33.                 return #memberList - foundAtIndex + 1
  34.             end
  35.         end
  36.         local members
  37.         status, memberList = pcall(sepPairs(memberList,1))
  38.         local foundAtIndex = 0
  39.         for i=#memberList,1,-1 do
  40.             foundAtIndex = foundAtIndex + 1
  41.             if member == memberList[i] then
  42.                 return foundAtIndex
  43.             end
  44.         end
  45.         return nil
  46.     else
  47.         return nil
  48.     end
  49. end
  50.  
  51.  
  52. function getUUID(xIn)
  53.     local m = nil
  54.     for b in string.gmatch(xIn,":") do
  55.         m = b
  56.     end
  57.     if m == ":" then
  58.         local tmeta = {}
  59.         for i in string.gmatch(xIn,"%d+") do
  60.             table.insert(tmeta,i)
  61.         end
  62.         local idm = tonumber(tmeta[1])
  63.         local meta = tonumber(tmeta[2])
  64.         local out = nil
  65.         if meta and idm then
  66.             out = idm + (meta * 32768)
  67.         end
  68.         return out
  69.     else
  70.         return xIn
  71.     end
  72. end
Advertisement
Add Comment
Please, Sign In to add comment