[PD] Template for pd_lua files
Frank Barknecht
fbar at footils.org
Sun Jul 20 13:11:02 CEST 2008
Hallo,
maybe useful for others, too: attached is a template for a simple
*.pd_lua class, that saves some typing. I configured my Vim to load
this template everytime I create a new, empty *.pd_lua file.
Some methods for bang, float and anythings are predefined, but
commented out with multiline Lua comments. You can activate them
easily by adding a third dash to the comment's start i.e. change this:
--[[
code
--]]
to this:
---[[
code
--]]
to make "code" active. Also don't forget to change the local variable
"pdclassname" to the name of your pd class which normally has to be
the base filename of your *.pd_lua file. This can be automated in
many editors as well by searching for ADD_CLASSNAME_HERE and replacing
it with the filename on load. Consult your editor's documentation for
that.
Ciao
--
Frank Barknecht _ ______footils.org__
-------------- next part --------------
--[[
-- Pd class written in Lua
-- fbar 2008
--]]
-- Change name of Pd class here
-- Use the same name as the filename (minus ".pd_lua")
local pdclassname = "ADD_CLASSNAME_HERE"
----------------------------------------
-- papa's little helpers
----------------------------------------
local function checkfloat(f)
return type(f) == "number"
end
local function checksym(s)
return type(s) == "string"
end
----------------------------------------
----------------------------------------
-- the actual class
----------------------------------------
local M = pd.Class:new():register(pdclassname)
function M:initialize(name, atoms)
self.inlets = 1
self.outlets = 1
--[[ load arg1 into self:
if checkfloat(atoms[1]) then
self.f = atoms[1]
elseif checksym(atoms[1]) then
self.s = atoms[1]
end
--]]
return true
end
----------------------------------------
-- various methods
-- uncomment them by replacing
-- "--[[" with "---[[" (3 dashes)
----------------------------------------
--[[
function M:in_1_bang()
self:outlet(1, "bang", {})
end
--]]
--[[
function M:in_1_float(f)
self:outlet(1, "float", {f})
end
--]]
--[[
function M:in_1_error()
self:error(pdclassname .. " crashed horribly.")
end
--]]
--[[
function M:in_1(sel, atoms)
self:outlet(1, sel, atoms)
end
--]]
More information about the Pd-list
mailing list