Advertisement
Jousway

StringToLuaCommand.Lua 2

Oct 10th, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function StringToCmd(self, CallFunction, t1, t2)
  2.     for c in string.gmatch(CallFunction(t1,t2), "(.-);") do
  3.         b = {};
  4.         b[1] = string.match(c, "(.-),");
  5.         b[2] = string.match(c, ",(.-),");
  6.        
  7.         if not b[2] then
  8.             b[2] = string.match(c, ",(.+)");
  9.         end;
  10.        
  11.         b[3] = string.match(c, ",.-,(.-),");
  12.         if not b[3] then
  13.             b[3] = string.match(c, ",.-,(.+)");
  14.         end;
  15.        
  16.         b[4] = string.match(c, ",.-,.-,(.-),");
  17.         if not b[4] then
  18.             b[4] = string.match(c, ",.-,.-,(.+)");
  19.         end;
  20.        
  21.         b[5] = string.match(c, ",.-,.-,.-,(.+)")
  22.        
  23.         v2 = 0;
  24.         for i=1,#b do
  25.             v = string.match(b[i], "(%w+)");
  26.             if not v2 then v2 = 0; end;        
  27.             for c2 in string.gmatch(b[i], "%+(%w+)") do
  28.                 if c2 then
  29.                     v2 = v2 + c2;
  30.                     b[i] = v + v2;
  31.                 end;
  32.             end;
  33.             for c2 in string.gmatch(b[i], "%-(%w+)") do
  34.                 if c2 then
  35.                     v2 = v2 - c2;
  36.                     b[i] = v - v2;
  37.                 end;
  38.             end;
  39.         end;       
  40.        
  41.         if b[5] then
  42.             self[b[1]](self,b[2],b[3],b[4],b[5]);
  43.         elseif b[4] then
  44.             self[b[1]](self,b[2],b[3],b[4]);
  45.         elseif b[3] then
  46.             self[b[1]](self,b[2],b[3]);
  47.         elseif b[2] then
  48.             self[b[1]](self,b[2]);
  49.         else
  50.             self[b[1]](self);
  51.         end;
  52.     end;
  53. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement