Advertisement
BobMe

string comma to table thing

Sep 20th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. --Made by Memo1332/Denizen Donut you HECC
  2.  
  3. -- This could be used as arguments for chat based commands; which it is in new MAH, however it is opensource and free to use
  4. unlike the other new MAH scripts that are protected by copyright.
  5.  
  6. function seperatevars(x,sign)
  7. local tab = {}
  8. local tat = {}
  9. for i=1,#x do
  10. if string.sub(x,i,i) == sign then
  11. table.insert(tab,i)
  12. end
  13. end
  14. for i=1,#tab do
  15. if i ~= 1 and i ~= #tab then
  16. table.insert(tat,string.sub(x,tab[i]+1,tab[i+1]-1))
  17. elseif i == #tab then
  18. table.insert(tat,string.sub(x,tab[i]+1))
  19. elseif i == 1 then
  20. table.insert(tat,string.sub(x,1,tab[i]-1))
  21. end
  22. end
  23. return tat
  24. end
  25.  
  26. local kek = seperatevars("nani,not nani,actually; yes nani,no. not nani.,AAAAAAAAAAAAAAAAAAAAAAAAAA",",")
  27.  
  28. if kek ~= nil then
  29. for i=1,#kek do
  30. print(kek[i])
  31. end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement