Advertisement
InTesting

CFrame Shortener (ModuleScript)

Dec 13th, 2019
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1. --[[Use strings
  2.     ie
  3.     '0, -0.699999988, -0.199999973, -1, 0, 0, 0, 0.965925753, 0.258819073, 0, 0.258819073, -0.965925753'
  4.     No "CFrame.new"
  5.     returns a smaller string or a table of smaller strings depending on the amount of args.
  6. --]]
  7. local function String_Shortener(...)
  8.     local a_Table,end_table,Steps={...},{},{
  9.         --// Remove spaces
  10.         Step_1=function(s)local whole_string='';for a=1,s:len()do
  11.             local letter = s:sub(a,a);if letter~=' 'then
  12.             whole_string=whole_string..letter;end;end;return whole_string;
  13.         end;
  14.         --// Remove First Leading Zero if its in the ones digit if the number is not 0 and its
  15.         --// Between 1 and -1.
  16.         Step_2=function(s)local Last_Argument,whole_string,At_End=1,'',false;
  17.             repeat local End_String='';
  18.                 local Comma_Arg,SC_Arg=string.find(s,',',Last_Argument)or s:len(),
  19.                     string.find(s,';',Last_Argument)or s:len();
  20.                 local End_Letter=(Comma_Arg>SC_Arg and SC_Arg)or(Comma_Arg<SC_Arg and
  21.                     Comma_Arg)or s:len()+1;
  22.                 local number_string=s:sub(Last_Argument,End_Letter-1);
  23.                 local number=tonumber(number_string);
  24.                 if number then
  25.                     local Is_Negative,new_number=(number<0 and'-')or'','';
  26.                     if number~=0 and number<1 and number>-1 then
  27.                         --Range: -1<number<1, number~=0
  28.                         local Positive_Number=tostring(math.abs(number));
  29.                         new_number=(Positive_Number:sub(1,1)=='0'and
  30.                             Positive_Number:sub(2))or tostring(math.abs(number));
  31.                     else new_number=tostring(math.abs(number));end;
  32.                     End_String=whole_string..Is_Negative..new_number..',';
  33.                 else End_String=whole_string..number_string..',';end;
  34.                 local Check=End_String:sub(End_String:len()-1);
  35.                 if Check==',,'then break;end;
  36.                 whole_string=End_String;Last_Argument=End_Letter+1;wait();
  37.             until At_End;
  38.             if whole_string:sub(whole_string:len())==','then
  39.                 whole_string=whole_string:sub(1,whole_string:len()-1);end;
  40.             return whole_string;
  41.         end;
  42.         };
  43.  
  44.     for _,v in pairs(a_Table)do v=tostring(v);
  45.         if v:sub(1,4)=='Enum'then local dot=(function()local last_pos,temp_var=1,nil;repeat
  46.             temp_var=string.find(v,'%.',last_pos);if temp_var then
  47.                 last_pos=temp_var+1;end;wait();
  48.             until not temp_var or workspace:FindFirstChild'Stop';return last_pos;end)();
  49.             table.insert(end_table,"'"..v:sub(dot).."'")
  50.         else local End_v=v;for _,c in pairs(Steps)do
  51.                 End_v=c(End_v); --// Apply all functions.
  52.             end;table.insert(end_table,End_v);
  53.         end;
  54.     end;
  55.     return(#end_table==1 and unpack(end_table))or end_table;
  56. end;
  57.  
  58. return String_Shortener
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement