summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCiaran Gultnieks <ciaran@ciarang.com>2014-03-12 18:23:16 +0000
committerCiaran Gultnieks <ciaran@ciarang.com>2014-03-12 18:28:38 +0000
commit5220d391b8853ad421e270a07d8e06982e23e35f (patch)
treeccd7fac4e2ed6432318777e45ba9818758333597
parentb8eeca4f8318c56985243a024a8888e0694e933e (diff)
Replace chunk of unnecessary code with gmatch
-rw-r--r--digilines_lcd/init.lua25
1 files changed, 1 insertions, 24 deletions
diff --git a/digilines_lcd/init.lua b/digilines_lcd/init.lua
index bcd9e47..fa02197 100644
--- a/digilines_lcd/init.lua
+++ b/digilines_lcd/init.lua
@@ -141,34 +141,11 @@ local NUMBER_OF_LINES = 5
local LINE_HEIGHT = 14
local CHAR_WIDTH = 5
-string_to_array = function(str)
- local tab = {}
- for i=1,string.len(str) do
- table.insert(tab, string.sub(str, i,i))
- end
- return tab
-end
-
-string_to_word_array = function(str)
- local tab = {}
- local current = 1
- tab[1] = ""
- for _,char in ipairs(string_to_array(str)) do
- if char ~= " " then
- tab[current] = tab[current]..char
- else
- current = current+1
- tab[current] = ""
- end
- end
- return tab
-end
-
create_lines = function(text)
local line = ""
local line_num = 1
local tab = {}
- for _,word in ipairs(string_to_word_array(text)) do
+ for word in string.gmatch(text, "%S+") do
if string.len(line)+string.len(word) < LINE_LENGTH and word ~= "|" then
if line ~= "" then
line = line.." "..word