Advertisement
Pinkishu

ccc

Aug 12th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. os.run = "fail"
  2. os.shutdown = function()
  3.     function os.version()
  4.         if turtle then
  5.             return "Custom Turtle Shell ver 0.1"
  6.         end
  7.         return "Custom shell ver 0.1"
  8.     end
  9.     os.shutdown = function()
  10.         while true do
  11.             coroutine.yield()
  12.         end
  13.     end
  14.     os.run = function( _tEnv, _sPath, ... )
  15.         local tArgs = { ... }
  16.         local fnFile, err = loadfile( _sPath )
  17.         if fnFile then
  18.             local tEnv = _tEnv
  19.             setmetatable( tEnv, { __index = _G } )
  20.             setfenv( fnFile, tEnv )
  21.             local ok, err = pcall( function()
  22.                 fnFile( unpack( tArgs ) )
  23.             end )
  24.             if not ok then
  25.                 if err and err ~= "" then
  26.                     print( err )
  27.                 end
  28.                 return false
  29.             end
  30.             return true
  31.         end
  32.         if err and err ~= "" then
  33.             print( err )
  34.         end
  35.         return false
  36.     end
  37.    
  38.     term.clear()
  39.     term.setCursorPos(1,1)
  40.     term.write("test")
  41.     coroutine.yield()
  42.     local ProgENV = {}
  43.     if fs.exists("rom/programs/shell") then
  44.         local file = fs.open("cshell", "r" )
  45.         local fFunction = loadstring(file.readAll())
  46.         -- local fFunction = loadstring(file.readAll(),"frandom")
  47.         file.close()
  48.         setmetatable( ProgENV, { __index = _G } ) -- no idear wtf this does but it works
  49.         setfenv(fFunction,ProgENV)
  50.         cProgram = coroutine.create(fFunction)
  51.     end
  52.     term.clear()
  53.     term.setCursorPos(1,1)
  54.     while true do
  55.         local e,e1,e2,e3,e4,e5 = coroutine.yield()
  56.         coroutine.resume(cProgram,e,e1,e2,e3,e4,e5)
  57.     end
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement