Guest User

Untitled

a guest
Jun 13th, 2013
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.25 KB | None | 0 0
  1. -- Load layering system with screen system
  2. local layer = {
  3.     currLayer = 1;
  4.     layers = 0;
  5. }
  6. local screen = {}
  7. setmetatable( screen, {
  8.     __call = function()
  9.         layer[#layer + 1] = {}
  10.         for word in tostring( objects ):gmatch("[^%s]+") do
  11.             layer[#layer][word] = {}
  12.         end
  13.         layer.layers = layer.layers + 1
  14.        
  15.         screen[layer.layers] = {}
  16.         for x = 1, w do
  17.             for y = 1, h do
  18.                 screen[layer.layers][x] = {}
  19.                 screen[layer.layers][x][y] = {}
  20.                 screen[layer.layers][x][y]["background"] = 32768
  21.                 screen[layer.layers][x][y]["text"] = 1
  22.                 screen[layer.layers][x][y]["char"] = " "
  23.             end
  24.         end;
  25.     end
  26. })
  27. screen()
  28.  
  29.  
  30. -- Screen tracking, partial overwrite term API
  31. local backgroundColour = colours.black
  32. local textColour = colours.white
  33.  
  34. if not term.native then
  35.     term.native = {}
  36.     term.native.setBackgroundColour = term.setBackgroundColour
  37.     term.native.setTextColour = term.setTextColour
  38.     term.native.write = term.write
  39. end
  40.  
  41. local tbackground = term.setBackgroundColour
  42. local ttext = term.setTextColour
  43. local twrite = term.write
  44.  
  45. term.setBackgroundColour = function( col )
  46.     term.native.setBackgroundColour( col )
  47.     backgroundColour = col
  48. end
  49.  
  50. term.setTextColour = function( col )
  51.     term.native.setTextColour( col )
  52.     textColour = col
  53. end
  54.  
  55. term.write = function( s )
  56.     if type( s ) ~= "string" then error("term.write no string", 2) end
  57.     local x, y = term.getCursorPos()
  58.     pcall( fs.delete, "error.txt" )
  59.     local file = fs.open( "error.txt", "a")
  60.     for i = 0, ( s:len() > w - x - 1 and w - x - 1 or s:len() ) - 1 do
  61.         --[[screen[layer.currLayer][x + i][y].char = s:sub( i+1, i+1 )
  62.         screen[layer.currLayer][x + i][y].text = textColour
  63.         screen[layer.currLayer][x + i][y].background = backgroundColour]]
  64.         file.writeLine( i..": LAYER "..layer.currLayer.." X "..x + i.." Y "..y)
  65.         file.writeLine( tostring(screen[layer.currLayer]) )
  66.         file.writeLine( tostring(screen[layer.currLayer][x + i]) )
  67.         file.writeLine( tostring(screen[layer.currLayer][x + i][y]) )
  68.         file.writeLine( tostring(screen[layer.currLayer][x + i][y]["background"]) )
  69.         file.writeLine( tostring(screen[layer.currLayer][x + i][y]["char"]) )
  70.         file.writeLine( tostring(screen[layer.currLayer][x + i][y]["text"]) )
  71.         file.writeLine( "\n" )
  72.     end
  73.     file.close()
  74.     term.native.write( s )
  75. end
Advertisement
Add Comment
Please, Sign In to add comment