I was working on some chat commands for my game, when I wondered: Is there a way to do something like this?
local string = ";kill me"
To get the output:
Args = {"kill", "me"}
I have heard of using string.gmatch, but I am not quite familiar with gmatch. Any help?
gmatch kinda sorta works like pairs, in that you need to use in when you iterate through it.
for word in string.gmatch("Hello2!,- Lua user", "[^%s]+") do print(word) end
gmatch will pass back to word the snipped bits of a string (The first arguement) that's specified by the pattern (The second arguement) In this case, the pattern is, %s which is all spaces, [^%s] which means anything that is NOT a white space, [^%s]+ which means anything that is NOT a white space, until another match is found.
For long term success read up on the library here h e r e ranOutOfLetters and here