Skip to content

Commit

Permalink
control module allows one-line widget + binding (as it says in the pa…
Browse files Browse the repository at this point in the history
…per...)
  • Loading branch information
grrrwaaa committed Feb 3, 2012
1 parent 802ba25 commit c0254b2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions LuaAV/extra/modules/control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ local osc = require "osc"

local format = string.format

local uid = (function()
local id = 0
return function(name)
id = id + 1
return string.format("%s%d", name or "anon", id)
end
end)()


local
function makeJSON(def)
local json = {}
Expand Down Expand Up @@ -126,8 +135,8 @@ end

function M.Widget(def)
assert(def and type(def) == "table", "widget constructor requires a table argument")
local name = def.name or table.remove(def)
assert(name and type(name) == "string", "widget definition requires a name")
local name = def.name or table.remove(def) or uid("control")
assert(name and type(name) == "string", "widget definition requires a name (string)")

local map = def.map or table.remove(def)

Expand Down

0 comments on commit c0254b2

Please sign in to comment.