Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- splits (text) up into (chunkSize) pieces
- -- will try break on spaces if possible
- function u.splitByChunk(text, chunkSize)
- local result = {}
- local posText = 1
- local ixResult = 1
- local more = true
- local safety = 99
- text, _ = text:gsub("\n"," ")
- while more or safety < 1 do
- safety = safety - 1
- local sub = text:sub(posText, posText+chunkSize -1)
- if posText + chunkSize >= text:len() then
- more = false
- result[ixResult] = sub
- else
- local posBreak = string.find(sub, " [^ ]*$") or chunkSize
- sub = text:sub(posText, posText+posBreak -1)
- result[ixResult] = sub
- posText = posText + posBreak
- ixResult = ixResult + 1
- end
- end
- return result
- end
- function cnl_mb_imm.setr_desc(desc)
- send("setr desc")
- local text = u.splitByChunk(desc:trim(),80)
- for i = 1,#text do send(text[i]:trim()) end
- send("@")
- end
- function cnl_mb_imm.format(txt)
- txt = txt:gsub("\n"," ")
- txt = u.splitByChunk(txt.trim(),80)
- for i = 1,#txt do send(text[i]:trim()) end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement