Advertisement
DiamondQ2

CC Require

Jun 13th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. -- require() for CC by comp500
  2. -- MIT license - https://github.com/comp500/CCSnippets/
  3. function require(...)
  4.     local c,r = fs.combine,{}
  5.     local function fn(a) return fs.exists(a) and a or false end
  6.     for i,v in ipairs(arg) do
  7.         local file = fn(c('usr/apis',v)) or fn(v) or shell.resolveProgram(v)
  8.         if not file then
  9.             printError("API "..v.." not found")
  10.             table.insert(r,nil)
  11.         else
  12.             os.loadAPI(file)
  13.             local b = _G[v]
  14.             _G[v] = nil
  15.             table.insert(r,b)
  16.         end
  17.     end
  18.     return unpack(r)
  19. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement