diff options
author | David Walter Seikel | 2014-05-16 10:32:42 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-16 10:32:42 +1000 |
commit | fa0f42fc9d2277aed457de1ad693135d5506bcab (patch) | |
tree | ac5039a2eae6d627abc18ab15d8669df0d48b4a8 /lib | |
parent | Fix llListReplaceList(), I think. (diff) | |
download | SledjHamr-fa0f42fc9d2277aed457de1ad693135d5506bcab.zip SledjHamr-fa0f42fc9d2277aed457de1ad693135d5506bcab.tar.gz SledjHamr-fa0f42fc9d2277aed457de1ad693135d5506bcab.tar.bz2 SledjHamr-fa0f42fc9d2277aed457de1ad693135d5506bcab.tar.xz |
Implement llCSV2List().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/LSL.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/LSL.lua b/lib/LSL.lua index 0356056..2d96603 100644 --- a/lib/LSL.lua +++ b/lib/LSL.lua | |||
@@ -589,6 +589,37 @@ function --[[string]] LSL.llList2CSV(--[[list]] l) | |||
589 | return LSL.llDumpList2String(l, ", ") | 589 | return LSL.llDumpList2String(l, ", ") |
590 | end | 590 | end |
591 | 591 | ||
592 | function --[[list]] LSL.llCSV2List(--[[string]] text) | ||
593 | local result = {} | ||
594 | local i = 1 | ||
595 | local b = 1 | ||
596 | local len = string.len(text) | ||
597 | local s, e | ||
598 | |||
599 | -- Apparently llCSV2List() really is this dumb. http://lslwiki.net/lslwiki/wakka.php?wakka=llCSV2List | ||
600 | repeat | ||
601 | s, e = string.find(text, ', ', b, true) | ||
602 | if s then | ||
603 | local temp = string.sub(text, b, s - 1) | ||
604 | local s1, e1 = string.find(temp, '<', 1, true) | ||
605 | |||
606 | -- Skip commas enclosed in <>, even if it's just garbage. | ||
607 | if s1 then | ||
608 | local s2, e2 = string.find(text, '>', b + e1, true) | ||
609 | if s1 then | ||
610 | temp = string.sub(text, b, e2) | ||
611 | e = e2 | ||
612 | end | ||
613 | end | ||
614 | result[i] = temp | ||
615 | i = i + 1 | ||
616 | b = e + 1 | ||
617 | end | ||
618 | until nil == s | ||
619 | |||
620 | return result | ||
621 | end | ||
622 | |||
592 | function --[[float]] LSL.llList2Float(--[[list]] l,--[[integer]] index) | 623 | function --[[float]] LSL.llList2Float(--[[list]] l,--[[integer]] index) |
593 | local result = tonumber(l[index]) | 624 | local result = tonumber(l[index]) |
594 | if nil == result then result = 0.0 end | 625 | if nil == result then result = 0.0 end |