summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid McMackins II <contact@mcmackins.org>2017-02-17 08:18:15 -0600
committerDavid McMackins II <contact@mcmackins.org>2017-02-17 08:18:15 -0600
commit6c921f6a75e72386ad348de21920d05cab3e4fa1 (patch)
tree9dbf683950e653fe3754b96e2034b7ca4dd44570
parentdc47ab4345d71304570a07b77924476f3c4503a7 (diff)
Add string split function to string type
-rw-r--r--client.lua4
-rw-r--r--util.lua8
2 files changed, 6 insertions, 6 deletions
diff --git a/client.lua b/client.lua
index 7a2001b..cdfc099 100644
--- a/client.lua
+++ b/client.lua
@@ -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
diff --git a/util.lua b/util.lua
index 12f57c1..711e841 100644
--- a/util.lua
+++ b/util.lua
@@ -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