Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.50 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. -- CC0, see http://creativecommons.org/publicdomain/zero/1.0/ etcetera, etcetera
  2.  
  3. function from(source, which)
  4.         local t = require(source)
  5.         local function import (which)
  6.                 if which == '*' then
  7.                         for k, v in pairs(t) do
  8.                                 if _G[k] == nil then
  9.                                         _G[k] = v
  10.                                 end
  11.                         end
  12.                 else
  13.                         for i, v in ipairs(which) do
  14.                                 _G[v] = t[v]
  15.                         end
  16.                 end
  17.         end
  18.         if which then
  19.                 return import(which)
  20.         else
  21.                 return import
  22.         end
  23. end
  24.  
  25. --[[ usage:
  26.  
  27. from 'lib' '*'
  28. from 'lib2' {'ball', 'rectangle', 'close'}
  29. from ('lib3', '*')
  30. ]]