Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local screenX, screenY = term.getSize()
- local current = { bg = colours.black, txt = colours.white }
- local screen = {}
- for x = 1, screenX do
- screen[x] = {}
- for y = 1, screenY do
- screen[x][y] = {
- char = "",
- bgcolor = colours.black,
- txtcolor = colours.white
- }
- end
- end
- -- Overwrite the globals
- function term.setTextColour( col )
- current.txt = col
- term.native.setTextColour( col )
- end
- function term.setBackgroundColour( col )
- current.bg = col
- term.native.setBackgroundColour( col )
- end
- function term.setTextColor( col )
- current.txt = col
- term.native.setTextColor( col )
- end
- function term.setBackgroundColor( col )
- current.bg = col
- term.native.setBackgroundColor( col )
- end
- function write( ... )
- local x, y = term.getCursorPos()
- local tmp = table.concat( {...}, " " )
- for i = 1, tmp:len() do
- screen[i + x - 1][y].char = tmp:sub( i, i )
- screen[i + x - 1][y].bgcolor = current.bg
- screen[i + x - 1][y].txtcolor = current.txt
- end
- term.native.write( tmp )
- end
- function print( ... )
- write( unpack( {...} ) )
- term.setCursorPos( 1, ({term.getCursorPos()})[2] + 1 )
- end
- local function getValueAt( key, x, y )
- return screen[x][y][key]
- end
- term.setBackgroundColour( colours.blue )
- term.clear()
- term.setCursorPos( 3, 3 )
- term.setTextColor( colors.black )
- write( "hello" )
- term.setCursorPos( 1, 1 )
- print( getValueAt( "char", 3, 3 ) .. " - " .. getValueAt( "txtcolor", 5, 3 ) .. " - " .. getValueAt( "bgcolor", 5, 3 ) )
Advertisement
Add Comment
Please, Sign In to add comment