Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tArg = {...}
- textscale = 0.5
- function displayHelp()
- print("monc <monitor>")
- print("monc <monitor> <program>")
- print("monc <monitor> -s <textscale>")
- print("monc <monitor> -s <textscale> <program>")
- end
- function setMonFuncs()
- if not monIsInUse then
- oldRedirect = term.redirect
- term.redirect = function( object )
- oldRedirect(object)
- oldRedirect(term.native())
- end
- monIsInUse = true
- end
- end
- function setRegFuncs()
- if monIsInUse == true then
- term.redirect = oldRedirect
- monIsInUse = false
- end
- end
- if tArg[1] ~= nil then
- Allsides = peripheral.getNames()
- mon = nil
- monitorName = tArg[1]
- if monitorName == "exit" then
- setRegFuncs()
- return
- end
- if peripheral.getType(monitorName) == "monitor" then
- mon = peripheral.wrap(monitorName)
- mon.setCursorPos(term.getCursorPos())
- else
- error("no such monitor as " .. monitorName)
- end
- if tArg[2] == "-s" then
- if type(tonumber(tArg[3])) == "number" then
- if tonumber(tArg[3]) >= 0.5 and tonumber(tArg[3]) <= 5 then
- progpos = 4
- argpos = 5
- mon.setTextScale(tonumber(tArg[3]))
- else
- error("invalid text scale, use 0.5-5")
- end
- if tArg[4] == nil then
- setMonFuncs()
- return
- end
- else
- progpos = 2
- argpos = 3
- mon.setTextScale(textscale)
- end
- else
- progpos = 2
- argpos = 3
- mon.setTextScale(textscale)
- end
- if tArg[progpos] ~= nil then
- program = tArg[progpos]
- if tArg[progpos] == "exit" then
- setRegFuncs()
- return
- else
- if tArg[argpos] ~= nil then
- arguments = ""
- for a = argpos, #tArg do
- arguments = arguments .. " " .. tArg[a]
- end
- end
- end
- if arguments ~= nil and arguments ~= "" then
- setMonFuncs()
- shell.run(program .. " " .. arguments)
- setRegFuncs()
- else
- setMonFuncs()
- shell.run(program)
- setRegFuncs()
- end
- else
- setMonFuncs()
- end
- else
- error("no monitor given")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement