[PD] Fwd: Simple tutorial on using Lua with PD

Claude Heiland-Allen claudiusmaximus at goto10.org
Tue Mar 4 02:19:23 CET 2008


Mike McGonagle wrote:
> I guess my troubles seem to stem from "where should everything go, and 
> what is the difference between 'lua' and 'luax'"?

'lua' is a load-once loader, much like C externals - once you load them 
you can't change them easily (but see the mutation examples).

+ it's quicker if you have many instances
+ full class status (no special prefix)
- have to restart Pd for most changes

'luax' is a load-repeatedly loader, much like Pd abstractions - each 
time a [luax mything myargs a b 1 2] is created it reloads the script 
and uses it to create an object.

+ it's quicker for rapid testing/development (no need to restart Pd)
- you need a special prefix, which isn't ideal for help patches, etc
- you still need to delete/recreate each object if you change the code
- the syntax is slightly different (but you can adopt a coding style 
that makes it easier to convert 'luax' to 'lua' once you have something 
working satisfactorily).

Note: the next version of pdlua will change the filename extensions from 
.lua to .pdlua and .luax to .pdluax to avoid polluting Lua's namespace 
with the names of Pd objects written in Lua.

>     svn co https://devel.goto10.org/svn/maximus/pdlua pdlua
> 
> So, is your SVN different from the one that Pure Data is using? I 
> downloaded the latest version this morning at about 11:30am Central time. 

I don't know who/how/why my code is in pd's SVN, but it's fine as long 
as whoever imported it tracks my changes, I guess (which is what the 
special SVN features are designed for).

> Could you explain some things about how Lua uses the search paths? And 
> where we should be putting our files?

Lua uses the Pd search path, so it will look relative to the containing 
patch first, then the other Pd path settings.

> Also, is there some documentation about what things are provided by 
> 'pd.lua'? Or is all that stuff just what is needed to get things loaded 
> and running (ie, no user accessible methods).

It's about 50/50 split between internal stuff (generally prefixed with a 
'_' character) and public stuff, you shouldn't really need to read it if 
the documentation is adequate, but I admit docs are the last thing to 
get done..  The doc/ folder and the examples/ folder are the best place 
to start, I think.

Hope this helps,


Claude
-- 
http://claudiusmaximus.goto10.org





More information about the Pd-list mailing list