File: requirer.pd_lua

package info (click to toggle)
pd-lua 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 656 kB
  • ctags: 265
  • sloc: ansic: 1,504; makefile: 314
file content (21 lines) | stat: -rw-r--r-- 608 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local R = pd.Class:new():register("requirer")

function R:initialize(sel, atoms)
  if type(atoms[1]) ~= "string" then 
    pd.post(self._name .. ": Missing module name")
    return false
  end
  pd.post (self._name .. ": Looking for " .. atoms[1])  
  require(atoms[1]) -- load the module
  if _G[atoms[1]] == nil then
      pd.post (self._name .. ": No such module (" .. atoms[1] .. ")")
  else -- print out module contents
      for k,v in pairs(_G[atoms[1]]) do
        pd.post(atoms[1].. "." .. tostring(k) .. " = " .. tostring(v))
      end
  end
  self.inlets = 0
  self.outlets = 0
  return true
end