Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Load layering system with screen system
- local layer = {
- currLayer = 1;
- layers = 0;
- }
- local screen = {}
- setmetatable( screen, {
- __call = function()
- layer[#layer + 1] = {}
- for word in tostring( objects ):gmatch("[^%s]+") do
- layer[#layer][word] = {}
- end
- layer.layers = layer.layers + 1
- screen[layer.layers] = {}
- for x = 1, w do
- for y = 1, h do
- screen[layer.layers][x] = {}
- screen[layer.layers][x][y] = {}
- screen[layer.layers][x][y]["background"] = 32768
- screen[layer.layers][x][y]["text"] = 1
- screen[layer.layers][x][y]["char"] = " "
- end
- end;
- end
- })
- screen()
- -- Screen tracking, partial overwrite term API
- local backgroundColour = colours.black
- local textColour = colours.white
- if not term.native then
- term.native = {}
- term.native.setBackgroundColour = term.setBackgroundColour
- term.native.setTextColour = term.setTextColour
- term.native.write = term.write
- end
- local tbackground = term.setBackgroundColour
- local ttext = term.setTextColour
- local twrite = term.write
- term.setBackgroundColour = function( col )
- term.native.setBackgroundColour( col )
- backgroundColour = col
- end
- term.setTextColour = function( col )
- term.native.setTextColour( col )
- textColour = col
- end
- term.write = function( s )
- if type( s ) ~= "string" then error("term.write no string", 2) end
- local x, y = term.getCursorPos()
- pcall( fs.delete, "error.txt" )
- local file = fs.open( "error.txt", "a")
- for i = 0, ( s:len() > w - x - 1 and w - x - 1 or s:len() ) - 1 do
- --[[screen[layer.currLayer][x + i][y].char = s:sub( i+1, i+1 )
- screen[layer.currLayer][x + i][y].text = textColour
- screen[layer.currLayer][x + i][y].background = backgroundColour]]
- file.writeLine( i..": LAYER "..layer.currLayer.." X "..x + i.." Y "..y)
- file.writeLine( tostring(screen[layer.currLayer]) )
- file.writeLine( tostring(screen[layer.currLayer][x + i]) )
- file.writeLine( tostring(screen[layer.currLayer][x + i][y]) )
- file.writeLine( tostring(screen[layer.currLayer][x + i][y]["background"]) )
- file.writeLine( tostring(screen[layer.currLayer][x + i][y]["char"]) )
- file.writeLine( tostring(screen[layer.currLayer][x + i][y]["text"]) )
- file.writeLine( "\n" )
- end
- file.close()
- term.native.write( s )
- end
Advertisement
Add Comment
Please, Sign In to add comment