aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMartin Peach <mrpeach@users.sourceforge.net>2014-07-21 18:46:54 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 14:28:31 +0200
commit587333d0b28fbf115783c3de34bc6bf271e06a9d (patch)
treec7b09d31dd16cad3f7e07581ed58118b1de8f7c2 /examples
parent349e81ecd8ec307c187c0ff4abf0788f381a3087 (diff)
replaced deprecated(Lua5.1) and missing(Lua5.2) table.getn() with the length operator # to obtain length of tables.
svn path=/trunk/externals/loaders/pdlua/; revision=17330
Diffstat (limited to 'examples')
-rw-r--r--examples/list-pak.pd_lua3
-rw-r--r--examples/list-unpack.pd_lua3
-rw-r--r--examples/peekbag.pd_lua9
3 files changed, 10 insertions, 5 deletions
diff --git a/examples/list-pak.pd_lua b/examples/list-pak.pd_lua
index 1651582..5964b33 100644
--- a/examples/list-pak.pd_lua
+++ b/examples/list-pak.pd_lua
@@ -48,7 +48,8 @@ function ListPak:in_n(i, sel, atoms)
-- insert selector
self.stored[i] = sel
else
- if table.getn(atoms) > 0 then
+-- if table.getn(atoms) > 0 then
+ if #(atoms) > 0 then
self.stored[i] = atoms[1]
end
end
diff --git a/examples/list-unpack.pd_lua b/examples/list-unpack.pd_lua
index 08b635c..ebddc45 100644
--- a/examples/list-unpack.pd_lua
+++ b/examples/list-unpack.pd_lua
@@ -50,7 +50,8 @@ function ListUnpack:in_1(sel, atoms)
-- also unpack selector of anythings
table.insert(atoms, 1, sel)
end
- local size = math.min(self.outlets, table.getn(atoms))
+-- local size = math.min(self.outlets, table.getn(atoms))
+ local size = math.min(self.outlets, #(atoms))
for i=size, 1, -1 do
self:Outlet(i, atoms[i])
end
diff --git a/examples/peekbag.pd_lua b/examples/peekbag.pd_lua
index 15e4791..c37a0a3 100644
--- a/examples/peekbag.pd_lua
+++ b/examples/peekbag.pd_lua
@@ -14,7 +14,8 @@ function PeekBag:in_1_float(f)
if self.add then
table.insert(self.bag, f)
else
- for i=table.getn(self.bag),1,-1 do
+-- for i=table.getn(self.bag),1,-1 do
+ for i = #(self.bag), 1, -1 do
if self.bag[i]==f then
table.remove(self.bag, i)
break
@@ -59,9 +60,11 @@ end
function PeekBag:in_1_aslist()
-- print all values of array as list
- if table.getn(self.bag) == 1 then
+-- if table.getn(self.bag) == 1 then
+ if #(self.bag) == 1 then
self:outlet(1, "float", {self.bag[1]})
- elseif table.getn(self.bag) > 1 then
+-- elseif table.getn(self.bag) > 1 then
+ elseif #(self.bag) > 1 then
self:outlet(1, "list", self.bag)
end
end