diff options
author | David McMackins II <contact@mcmackins.org> | 2017-02-17 08:18:15 -0600 |
---|---|---|
committer | David McMackins II <contact@mcmackins.org> | 2017-02-17 08:18:15 -0600 |
commit | 6c921f6a75e72386ad348de21920d05cab3e4fa1 (patch) | |
tree | 9dbf683950e653fe3754b96e2034b7ca4dd44570 | |
parent | dc47ab4345d71304570a07b77924476f3c4503a7 (diff) |
Add string split function to string type
-rw-r--r-- | client.lua | 4 | ||||
-rw-r--r-- | util.lua | 8 |
2 files changed, 6 insertions, 6 deletions
@@ -93,7 +93,7 @@ function Client:getrooms() local rooms = {} for _,line in ipairs(r) do - line = split(line, ' ') + line = line:split(' ') table.insert(rooms, line[2]) end @@ -146,7 +146,7 @@ function Client:_move(kind, dx, dy) return nil end - r = split(r[1], ' ') + r = r[1]:split(' ') if r[1] ~= 'Y' then return false end @@ -19,14 +19,14 @@ function string:startswith(pattern) return self:sub(1, pattern:len()) == pattern end -function split(s, delim) +function string:split(delim) local out = {} local last = 1 - for i = 1, #s do - local c = s:sub(i, i) + for i = 1, #self do + local c = self:sub(i, i) if c == delim then - table.insert(out, s:sub(last, i - 1)) + table.insert(out, self:sub(last, i - 1)) last = i + 1 end end |