Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Monitor++ By RamiLego4Game--
- --Boot--
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- local tArgs = { ... }
- if #tArgs < 3 and (not tArgs[2]=="true" or not tArgs[2]=="false") then
- term.setTextColor(colors.red)
- print("Usage: monitor++ <side> <touch> <program> <arguments>")
- return
- end
- local sName = tArgs[1]
- if peripheral.getType( sName ) ~= "monitor" then
- print( "No monitor named ".. sName )
- return
- end
- local sProgram = tArgs[3]
- local sPath = shell.resolveProgram( sProgram )
- if sPath == nil then
- print( "No such program: "..sProgram )
- return
- end
- local monitor = peripheral.wrap(tostring(tArgs[1]))
- local oldterm = term.current()
- local nterm = {}
- --Functions--
- function nterm.write(text)
- oldterm.write(text)
- monitor.write(text)
- return(text)
- end
- function nterm.clear()
- oldterm.clear()
- monitor.clear()
- end
- function nterm.clearLine()
- oldterm.clearLine()
- monitor.clearLine()
- end
- function nterm.getCursorPos()
- return oldterm.getCursorPos()
- end
- function nterm.setCursorPos(x,y)
- oldterm.setCursorPos(x,y)
- monitor.setCursorPos(x,y)
- end
- function nterm.setCursorBlink(bool)
- oldterm.setCursorBlink(bool)
- monitor.setCursorBlink(bool)
- end
- function nterm.isColor()
- if not oldterm.isColor() or not monitor.isColor() then
- return false
- else
- return true
- end
- end
- nterm.isColour = nterm.isColor
- function nterm.getSize()
- return oldterm.getSize()
- end
- function nterm.setTextColor(num)
- oldterm.setTextColor(num)
- monitor.setTextColor(num)
- end
- nterm.setTextColour = nterm.setTextColor
- function nterm.setBackgroundColor(num)
- oldterm.setBackgroundColor(num)
- monitor.setBackgroundColor(num)
- end
- nterm.setBackgroundColour = nterm.setBackgroundColor
- function nterm.setTextScale(num)
- monitor.setTextScale(num)
- end
- --launcher--
- term.redirect(nterm)
- local co = coroutine.create( function()
- shell.run( sProgram, unpack( tArgs, 4 ) )
- end )
- local function resume( ... )
- local ok, param = coroutine.resume( co, ... )
- if not ok then
- printError( param )
- end
- return param
- end
- local ok, param = pcall( function()
- local sFilter = resume()
- while coroutine.status( co ) ~= "dead" do
- local tEvent = { os.pullEventRaw() }
- if sFilter == nil or tEvent[1] == sFilter or tEvent[1] == "terminate" then
- sFilter = resume( unpack( tEvent ) )
- end
- if coroutine.status( co ) ~= "dead" and (sFilter == nil or sFilter == "mouse_click") and tArgs[2]=="true" then
- if tEvent[1] == "monitor_touch" and tEvent[2] == sName then
- sFilter = resume( "mouse_click", 1, unpack( tEvent, 3 ) )
- end
- end
- if coroutine.status( co ) ~= "dead" and (sFilter == nil or sFilter == "term_resize") then
- if tEvent[1] == "monitor_resize" and tEvent[2] == sName then
- sFilter = resume( "term_resize" )
- end
- end
- end
- end )
- term.redirect(term.native())
- if not ok then
- printError( param )
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement