Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term=term.native
- local screen={}
- screen.__index=term
- setmetatable(screen,screen)
- local w,h=term.getSize()
- local blink=true
- local color={}
- color.text=colors.white
- color.background=colors.black
- color[2^0]="1"
- color[2^1]="2"
- color[2^2]="3"
- color[2^3]="4"
- color[2^4]="5"
- color[2^5]="6"
- color[2^6]="7"
- color[2^7]="8"
- color[2^8]="9"
- color[2^9]="10"
- color[2^10]="11"
- color[2^11]="12"
- color[2^12]="13"
- color[2^13]="14"
- color[2^14]="15"
- color[2^15]="16"
- local vscreen={}
- vscreen.tcolor={}
- vscreen.text={}
- vscreen.bcolor={}
- local function dtcolor() return 1 end
- local function dbcolor() return 32768 end
- local function dtext() return " " end
- for y=0,h+1 do
- vscreen.tcolor[y]={}
- vscreen.text[y]={}
- vscreen.bcolor[y]={}
- vscreen.tcolor[y].__index=dtcolor
- vscreen.text[y].__index=dtext
- vscreen.bcolor[y].__index=dbcolor
- setmetatable(vscreen.tcolor[y],vscreen.tcolor[y])
- setmetatable(vscreen.text[y],vscreen.text[y])
- setmetatable(vscreen.bcolor[y],vscreen.bcolor[y])
- end
- screen.write=function(_sText)
- local x,y=term.getCursorPos()
- for i=1,_sText:len() do
- vscreen.text[y][x+i-1]=_sText:sub(i,i)
- vscreen.tcolor[y][x+i-1]=color.text
- vscreen.bcolor[y][x+i-1]=color.background
- end
- term.write(_sText)
- end
- screen.setTextColor=function(_nColor)
- color.text=_nColor
- term.setTextColor(_nColor)
- end
- screen.setTextColour=function(_nColor)
- color.text=_nColor
- term.setTextColour(_nColor)
- end
- screen.setBackgroundColor=function(_nColor)
- color.background=_nColor
- term.setBackgroundColor(_nColor)
- end
- screen.setBackgroundColour=function(_nColor)
- color.background=_nColor
- term.setBackgroundColour(_nColor)
- end
- screen.clear=function()
- for y=1,h do
- for x=1,w do
- vscreen.text[y][x]=" "
- vscreen.tcolor[y][x]=colors.text
- vscreen.bcolor[y][x]=color.background
- end
- end
- term.clear()
- end
- screen.clearLine=function()
- local x,y=term.getCursorPos()
- for x=1,w do
- vscreen.text[y][x]=" "
- vscreen.tcolor[y][x]=color.text
- vscreen.bcolor[y][x]=color.background
- end
- term.clearLine()
- end
- screen.setCursorBlink=function(_bBlink)
- blink=_bBlink
- term.setCursorBlink(_bBlink)
- end
- screen.scroll=function(n)
- if n > 0 then
- for i=1,n do
- for y=1,h do
- for x=1,w do
- vscreen.tcolor[y][x]=vscreen.tcolor[y+1][x]
- vscreen.bcolor[y][x]=vscreen.bcolor[y+1][x]
- vscreen.text[y][x]=vscreen.text[y+1][x]
- end
- end
- end
- else
- for i=n,-1 do
- for y=h,1,-1 do
- for x=1,w do
- vscreen.tcolor[y][x]=vscreen.tcolor[y-1][x]
- vscreen.bcolor[y][x]=vscreen.bcolor[y-1][x]
- vscreen.text[y][x]=vscreen.text[y-1][x]
- end
- end
- end
- end
- term.scroll(n)
- end
- function get()
- return screen
- end
- function takeScreenshot(_sPath)
- local xp,yp=term.getCursorPos()
- local file=fs.open(_sPath,"w")
- file.write("{\\rtf1{\\fonttbl{\\f0\\fnil\\fcharset0 Courier New;}}{\\colortbl;\\red240\\green240\\blue240;\\red235\\green136\\blue68;\\red195\\green84\\blue205;\\red102\\green137\\blue211;\\red222\\green222\\blue108;\\red65\\green205\\blue52;\\red216\\green129\\blue152;\\red67\\green67\\blue67;\\red153\\green153\\blue153;\\red40\\green118\\blue151;\\red123\\green47\\blue190;\\red37\\green49\\blue146;\\red81\\green48\\blue26;\\red59\\green81\\blue26;\\red179\\green49\\blue44;\\red30\\green27\\blue27;\\red0\\green0\\blue0;}\\sa0")
- local bcolor
- for y=1,h do
- for x=1,w do
- bcolor=color[vscreen.bcolor[y][x]]
- if bcolor=="16" then
- bcolor="17"
- end
- if y==yp and x==xp and blink then
- if vscreen.text[y][x]==" " then
- file.write("\\cf"..color[vscreen.tcolor[y][x]].."\\highlight"..bcolor.." _")
- else
- file.write("\\cf"..color[vscreen.tcolor[y][x]].."\\ul\\highlight"..bcolor.." "..vscreen.text[y][x].."\\ulnone")
- end
- else
- file.write("\\cf"..color[vscreen.tcolor[y][x]].."\\highlight"..bcolor.." "..vscreen.text[y][x])
- end
- end
- file.write("\\highlight0\\par")
- end
- file.write("}")
- file.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement