-
Notifications
You must be signed in to change notification settings - Fork 11
/
pdluax-help.pd
67 lines (67 loc) · 4.82 KB
/
pdluax-help.pd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#N canvas 550 126 560 399 10;
#X declare -lib pdlua;
#X text 56 237 See also:;
#X obj 120 236 pdlua;
#X obj 363 64 declare -lib pdlua;
#X obj 306 4 cnv 15 250 40 empty empty empty 12 13 0 18 #7c7c7c #e0e4dc 0;
#N canvas 382 141 749 319 (subpatch) 0;
#X coords 0 -1 1 1 252 42 2 100 100;
#X restore 305 3 pd;
#X obj 315 18 cnv 10 10 10 empty empty Load\ externals\ written\ in\ Lua 0 6 2 20 #7c7c7c #e0e4dc 0;
#X obj 3 3 cnv 15 301 42 empty empty pdluax 20 20 2 37 #e0e0e0 #000000 0;
#N canvas 0 22 450 278 (subpatch) 0;
#X coords 0 1 100 -1 302 42 1 0 0;
#X restore 3 3 graph;
#X obj 4 271 cnv 3 550 3 empty empty inlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 4 306 cnv 3 550 3 empty empty outlets 8 12 0 13 #dcdcdc #000000 0;
#X obj 4 341 cnv 3 550 3 empty empty arguments 8 12 0 13 #dcdcdc #000000 0;
#X obj 4 374 cnv 15 552 21 empty empty empty 20 12 0 14 #e0e0e0 #202020 0;
#X text 243 316 NONE;
#X text 244 284 NONE;
#X text 163 351 1) symbol - source file name (without extension);
#X text 39 150 You can right click the object and ask to open the source file if your system has an application set to handle this extension., f 74;
#X text 260 227 Details on writting luax files ----->, f 20;
#X text 39 95 The [pdluax] object is similar to [pdlua] but used to load .pd_luax files and instantiate objects from them. It is less efficient but more flexible than ordinary Lua objects when developing or live-coding. You also need to load [pdlua] as a library first as with the [declare] object above., f 74;
#X obj 113 191 pdluax pdlua/hello;
#N canvas 613 120 540 414 quickstart 0;
#X obj 36 94 cnv 15 450 100 empty empty pdluax\ HOWTO 20 12 0 14 #dfdfdf #000000 0;
#X obj 36 195 cnv 15 450 140 empty empty Advantages: 20 12 0 14 #cccccc #000000 0;
#X obj 36 336 cnv 15 450 200 empty empty Disadvantages: 20 12 0 14 #dfdfdf #000000 0;
#X obj 36 537 cnv 15 450 470 empty empty How\ To\ Write\ Code\ For\ pdluax: 20 12 0 14 #cccccc #000000 0;
#X text 52 124 The pdluax class allows "volatile" loading of Lua source code files that define Pd object behaviour.;
#X text 52 159 The [pdluax foo] object loads "foo.pd_luax" at object creation time.;
#X text 52 217 + You can edit "foo.pd_luax" and new [pdluax foo] objects will reflect the changes in the file.;
#X text 52 253 + Good for rapid development/testing cycles.;
#X text 52 275 + Good for live coding.;
#X text 52 296 + No need to restart Pd if you made a little mistake.;
#X text 52 359 - Reloading the file each time is slower.;
#X text 52 375 - Syntax is different to the syntax expected by the Lua loader (see below for discussion).;
#X text 52 405 - There is no "reload" functionality \, so you can have multiple objects called [pdluax foo] but that have different behaviours.;
#X text 52 447 - Data shared between objects must be accessible globally.;
#X text 52 465 - The above two points mean some mistakes/changes mean you have to restart Pd anyway.;
#X text 52 496 NOTE: Modern pd-lua versions offer a much more advanced live coding facility -- check out pdx.lua in the tutorial.;
#X text 51 563 The last expression/statement in the file should be of the form:;
#X obj 79 610 cnv 15 300 60 empty empty empty 20 12 0 14 #ffffff #404040 0;
#X text 91 614 return function (self \, sel \, atoms);
#X text 93 631 -- code here;
#X text 92 651 end;
#X text 51 675 This function is executed in the context of the 'initialize' method of the pdluax class \, and has the same arguments:;
#X text 90 718 'self' is the object to be created.;
#X text 89 735 'sel' is the name of the class.;
#X text 89 753 'atoms' are the creation arguments.;
#X obj 79 820 cnv 15 300 20 empty empty empty 20 12 0 14 #ffffff #404040 0;
#X text 94 822 function self:in_1_float(f) ... end;
#X obj 79 870 cnv 15 300 20 empty empty empty 20 12 0 14 #ffffff #404040 0;
#X text 80 846 or:;
#X text 96 872 self.in_1_float = function(self \, f) ... end;
#X text 50 895 If using the second form \, remember the self argument.;
#X text 50 920 If you need a shared state between objects \, you need to use a global name. Try to pick something unique to avoid conflicts with other scripts. You also need to ensure that you don't clobber this state - remember the script can be executed more than once.;
#X text 50 774 To add methods to the new object you need to add code _inside_ the returned function. There are two syntaxes for this:;
#X obj 36 1007 cnv 15 450 20 empty empty empty 20 12 0 14 #dfdfdf #000000 0;
#X text 55 1010 modified from doc/examples/pdlua/luax.txt by mrpeach 2011/10/06, f 65;
#N canvas 0 22 450 278 (subpatch) 0;
#X coords 0 1 100 -1 450 935 1;
#X restore 36 93 graph;
#X text 45 21 Find basic instructions/examples below. For more details \, check 'pd-lua-intro.pdf' in the 'pdlua/tutorial' folder. You can also find this tutorial online at: https://agraef.github.io/pd-lua/tutorial/pd-lua-intro.html, f 66;
#X restore 386 241 pd quickstart;
#X text 233 190 <-- loading "hello.pd_luax" file.;