I'm trying to write some Lua scripts in [ofelia] and I don't know how to create an array, since arrays in Lua are written with curly brackets, which are not allowed in Pd.
For example, I'd like to create an array like this:
local tab = {}
and then populate it like this:
for i=1,161 do tab[i] = ofRandom(0,255) end
Any ideas?
Hi Alexandros,
You can write this in an object box, and send a bang to it:
ofelia f; local tab = ofTable(); for i = 1, 161 do tab[i] = ofRandom(0, 255) end; return(tab);
Le sam. 22 août 2020 à 17:48, Alexandros adrcki@gmail.com a écrit :
I'm trying to write some Lua scripts in [ofelia] and I don't know how to create an array, since arrays in Lua are written with curly brackets, which are not allowed in Pd.
For example, I'd like to create an array like this:
local tab = {}
and then populate it like this:
for i=1,161 do tab[i] = ofRandom(0,255) end
Any ideas?
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Hello!
If you are in ofelia 3 you can script like you did double clicking in ofelia object and writing your script.
In ofelia object you can use ofTable() or to interact with pd arrays ofArray() see patch example.
Em sáb., 22 de ago. de 2020 às 12:48, Alexandros adrcki@gmail.com escreveu:
I'm trying to write some Lua scripts in [ofelia] and I don't know how to create an array, since arrays in Lua are written with curly brackets, which are not allowed in Pd.
For example, I'd like to create an array like this:
local tab = {}
and then populate it like this:
for i=1,161 do tab[i] = ofRandom(0,255) end
Any ideas?
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
Hadn't noticed ofTable(), thanks! I am writing the scripts straight into the ofelia object. I guess you mean single clicking, since with a single click the editor opens up.
Thanks for the example too!
On 22/8/20 7:32 μ.μ., Esteban Viveros wrote:
Hello!
If you are in ofelia 3 you can script like you did double clicking in ofelia object and writing your script.
In ofelia object you can use ofTable() or to interact with pd arrays ofArray() see patch example.
Em sáb., 22 de ago. de 2020 às 12:48, Alexandros <adrcki@gmail.com mailto:adrcki@gmail.com> escreveu:
I'm trying to write some Lua scripts in [ofelia] and I don't know how to create an array, since arrays in Lua are written with curly brackets, which are not allowed in Pd. For example, I'd like to create an array like this: local tab = {} and then populate it like this: for i=1,161 do tab[i] = ofRandom(0,255) end Any ideas? _______________________________________________ Pd-list@lists.iem.at <mailto:Pd-list@lists.iem.at> mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
-- Esteban Viveros
www.estebanviveros.com http://www.estebanviveros.com
Yes Alexandros you're right! Single click! Thanks!
Em seg., 24 de ago. de 2020 às 12:07, Alexandros adrcki@gmail.com escreveu:
Hadn't noticed ofTable(), thanks! I am writing the scripts straight into the ofelia object. I guess you mean single clicking, since with a single click the editor opens up.
Thanks for the example too! On 22/8/20 7:32 μ.μ., Esteban Viveros wrote:
Hello!
If you are in ofelia 3 you can script like you did double clicking in ofelia object and writing your script.
In ofelia object you can use ofTable() or to interact with pd arrays ofArray() see patch example.
Em sáb., 22 de ago. de 2020 às 12:48, Alexandros adrcki@gmail.com escreveu:
I'm trying to write some Lua scripts in [ofelia] and I don't know how to create an array, since arrays in Lua are written with curly brackets, which are not allowed in Pd.
For example, I'd like to create an array like this:
local tab = {}
and then populate it like this:
for i=1,161 do tab[i] = ofRandom(0,255) end
Any ideas?
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
-- Esteban Viveros
www.estebanviveros.com