Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1.     -- String com todos os parametros
  2.     -- #123, @um dois tres, !true, ?math.pi
  3.     -- retorna a tabela com os tipos certos
  4.     getWithType = function(a)
  5.         local values = string.split(a or "","[^,]+")
  6.        
  7.         local out = {}
  8.        
  9.         for k,v in next,values do
  10.             local icon,value = string.match(v,"([@?#!])(.*)")
  11.             if icon and value then 
  12.                 if icon == "#" then
  13.                     out[#out + 1] = tonumber(value)
  14.                 elseif icon == "@" then
  15.                     out[#out + 1] = string.trim(tostring(value))
  16.                 elseif icon == "!" then
  17.                     out[#out + 1] = value == "true"
  18.                 elseif icon == "?" then
  19.                     out[#out + 1] = system.loadTable(value)
  20.                 end
  21.             end
  22.         end
  23.        
  24.         return out
  25.     end
  26.  
  27.     tfm.exec.print = function(str) print(str) end
  28.  
  29.     local f = system.loadTable("tfm.exec.print")
  30.     f = type(f) == "function" and f or tfm.exec.chatMessage
  31.  
  32.     p = "@teste"
  33.     local args = getWithType(table.concat(p," ",function(k,v)
  34.             return (table.find({"#","@","!","?"},string.sub(v,1,1)) and "," or "") .. v
  35.     end))
  36.     f(table.unpack(args))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement