Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local serverID = 123
- currentColor = colors.white
- currentBGColor = colors.black
- isBlinking = false
- isRainbow = false
- screenData = {
- ["clearColor"] = colors.black,
- }
- function addScreenData( strr, xx, yy, bg, mc )
- screenData[ #screenData ] = {
- ["text"] = strr,
- ["x"] = xx,
- ["y"] = yy,
- ["bg"] = bg,
- ["cl"] = mc,
- }
- end
- function reloadData()
- oldScreenData = screenData
- screenData = {
- ["clearColor"] = oldScreenData["clearColor"],
- }
- for i=1,#oldScreenData-1 do
- screenData[#screenData] = oldScreenData[i]
- end
- end
- --- Backup Functions ---
- oldBGColor = term.setBackgroundColour
- oldColor = term.setTextColour
- oldClear = term.clear
- oldWrite = term.write
- oldClrLine = term.clearLine
- oldBlink = term.setCursorBlink
- ------------------------
- term.setCursorBlink = function( shouldi )
- isBlinking = shouldi
- return oldBlink( shouldi )
- end
- term.clearLine = function()
- local x,y = term.getCursorPos()
- local shouldReload = false
- for i=1,#screenData-1 do
- if screenData[i]["y"] == y then
- screenData[i] = nil
- shouldReload = true
- end
- end
- if shouldReload then
- reloadData()
- end
- return oldClrLine()
- end
- term.clear = function()
- screenData = {
- ["clearColor"] = currentBGColor
- }
- return oldClear()
- end
- term.setBackgroundColour = function( colz )
- currentBGColor = colz
- return oldBGColor( colz )
- end
- term.setTextColour = function( colz )
- currentColor = colz
- return oldColor( colz )
- end
- addText = function( text )
- local x,y = term.getCursorPos()
- addScreenData( text, x, y, currentBGColor, currentColor )
- return oldWrite( text )
- end
- term.write = function( text )
- if isRainbow then
- for i=1,#text do
- str = string.sub( txt, i, i )
- term.setTextColor(2^math.random(1, 16)/2)
- addText(str)
- end
- else
- return addText( text )
- end
- end
- ------Start Enviroments------
- function runShell()
- term.clear()
- term.setCursorPos(1,1)
- shell.run("shell")
- os.shutdown()
- end
- function waitForMessages()
- for i,v in pairs( rs.getSides() ) do
- rednet.open( v )
- end
- while true do
- id, message = rednet.receive()
- if id == serverID then
- if message == "getColor" then
- rednet.send( serverID, textutils.serialize( currentColor ) )
- elseif message == "getBG" then
- rednet.send( serverID, textutils.serialize( currentBGColor ) )
- elseif message == "setRainbow" then
- if isRainbow then
- isRainbow = false
- else
- isRainbow = true
- end
- elseif message == "getText" then
- rednet.send( serverID, textutils.serialize( screenData ) )
- elseif message == "getBlink" then
- rednet.send( serverID, textutils.serialize( isBlinking ) )
- elseif message == "getX" then
- local xz,yz = term.getCursorPos()
- rednet.send( serverID, texutils.serialize( xz ) )
- elseif message == "getY" then
- local xz,yz = term.getCursorPos()
- rednet.send( serverID, texutils.serialize( yz ) )
- end
- end
- end
- end
- parallel.waitForAny( waitForMessages, runShell )
- ------Stop Enviroments-------
- os.shutdown() --just in case
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement