Advertisement
Guest User

test_jonas

a guest
Jun 18th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. commands = {}
  2. commands.stringtable = function(input)
  3. local table2 = {}
  4. local f = 1
  5. for i=1,string.len(input) do
  6.     if input:byte(i) == 32 then
  7.         f = f + 1
  8.         goto done
  9.     else
  10.         if f % 2 == 0 then
  11.             if input:byte(i) < 48 or input:byte(i) > 57 then
  12.                 table2[f] = nil
  13.                 f = f+1
  14.             end
  15.         end
  16.         if table2[f] == nil then
  17.             table2[f] = input:sub(i, i)
  18.         else
  19.             table2[f] = table2[f]..input:sub(i, i)
  20.         end
  21.     end
  22.     ::done::
  23. end
  24. return table2, f
  25. end
  26.  
  27. while true do
  28. print("Awaiting command: ")
  29. local input = io.read()
  30. if input == "close" then break end
  31. local table2, f = commands.stringtable(input)
  32. for i, v in ipairs(table2) do
  33. print("Your command was: "..v)
  34. end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement