Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
--[[ Monc 2.1 - Monitor/Computer mirror program Beta Now with multi-monitor support and safe disabling pastebin get GdscC2Jv monc2b std PB GdscC2Jv monc2b std ld monc2 monc wget http://pastebin.com/raw/GdscC2Jv This is a beta release. You fool! Working on: + implementing settings API for basic options + borders --working on right now + fixing term.redirect --]] local centerMonc = true local getTableSize = function(tbl) local out = 0 if type(tbl) == "table" then for k,v in pairs(tbl) do out = out + 1 end end return out end local copyTable = function(tbl) local output = {} for k,v in pairs(tbl) do output[k] = v end return output end if not monc then monc = {} monc.monitors = (type(monc.monitors) == "table" and #monc.monitors > 0) and monc.monitors or {} if not monc.oldterm then monc.oldterm = copyTable(term) end if not monc.origterm then monc.origterm = term.current() end if monc.active == nil then monc.active = false end monc.addMonitor = function(object,position) local pos = position or (#monc.monitors+1) monc.monitors[pos] = object if object then object.setBackgroundColor(monc.oldterm.getBackgroundColor()) object.setTextColor(monc.oldterm.getTextColor()) object.clear() object.setCursorPos(monc.oldterm.getCursorPos()) end end monc.removeMonitor = function(position) monc.monitors[position] = nil end monc.beforeFunc = function(v) --executed before all functions that alter the screen --screen X, Y sizes local scX,scY = v.getSize() --native terminal X, Y sizes local ntX,ntY = monc.oldterm.getSize() --adjust X, Y local adjX,adjY = (centerMonc and (scX>ntX)) and (math.floor(scX-ntX)/2) or 0,(centerMonc and (scY>ntY)) and (math.floor(scX-ntX)/2) or 0 --native terminal cursor X, Y local ntCX,ntCY = monc.oldterm.getCursorPos() v.setCursorPos(ntCX+adjX,ntCY+adjY) end monc.afterFunc = function(v) --executed after all functions that alter the screen return nil --unused as of now end monc.term = {} monc.term.getSize = function() return monc.oldterm.getSize() end monc.term.getCursorPos = function() return monc.oldterm.getCursorPos() end monc.term.setCursorPos = function(x,y) monc.oldterm.setCursorPos(x,y) for k,v in pairs(monc.monitors) do local scX,scY = v.getSize() local ntX,ntY = monc.oldterm.getSize() local adjX,adjY = (centerMonc and (sxX)) and (scX) or 0 local ntCX,ntCY = monc.oldterm.getCursorPos() if v.getSize() then v.setCursorPos(ntCX+adjX,ntCY+adjY) end end end monc.term.setVisible = function(...) --monitors do not have a setVisible function, for some reason monc.oldterm.setVisible(...) end monc.term.write = function(text) monc.oldterm.write(text) local sx,sy = monc.oldterm.getSize() for k,v in pairs(monc.monitors) do if v.getSize() then local cx,cy = v.getCursorPos() if cy > sy then --v.setCursorPos(cx,sy) break else v.write(tostring(text):sub(1,(sx-cx)+1)) end end end end monc.term.clearLine = function() monc.oldterm.clearLine() local sx,sy = monc.oldterm.getSize() for k,v in pairs(monc.monitors) do if v.getSize() then local cx,cy = v.getCursorPos() if cy > sy then break else v.setCursorPos(1,cy) v.write((" "):rep(sx)) v.setCursorPos(cx,cy) end end end end monc.term.clear = function() monc.oldterm.clear() local sx,sy = monc.oldterm.getSize() for k,v in pairs(monc.monitors) do if v.getSize() then local cx,cy = v.getCursorPos() for y = 1, sy do v.setCursorPos(1,y) v.write((" "):rep(sx)) end v.setCursorPos(cx,cy) end end end monc.term.blit = function(text,tx,bg) monc.oldterm.blit(text,tx,bg) local sx,sy = monc.oldterm.getSize() for k,v in pairs(monc.monitors) do if v.getSize() then local cx,cy = v.getCursorPos() if cy > sy then break else v.blit(tostring(text):sub(1,1+sx-cx), tostring(tx):sub(1,1+sx-cx), tostring(bg):sub(1,1+sx-cx)) end end end end monc.term.setCursorBlink = function(...) monc.oldterm.setCursorBlink(...) for k,v in pairs(monc.monitors) do if v.getSize() then v.setCursorBlink(...) end end end monc.term.isColor = function() for k,v in pairs(monc.monitors) do if v.getSize() then if not v.isColor() then return false end end end return monc.oldterm.isColor() end monc.term.scroll = function(amount) monc.oldterm.scroll(amount) local sx,sy = monc.oldterm.getSize() for k,v in pairs(monc.monitors) do if v.getSize() then local lastbg = monc.oldterm.getBackgroundColor() if amount > 0 then v.setBackgroundColor(colors.black) end v.scroll(amount) v.setBackgroundColor(lastbg) if amount > 0 then local bg = v.getBackgroundColor() local cx,cy = v.getCursorPos() for a = 1, math.abs(amount) do v.setCursorPos(1,sy-(a-1)) v.clearLine() end v.setCursorPos(cx,cy) v.setBackgroundColor(bg) else for a = 1, math.abs(amount) do v.setBackgroundColor(colors.black) v.setCursorPos(1,sy+a) v.clearLine() end end end v.setCursorPos(monc.oldterm.getCursorPos()) end end monc.term.setTextColor = function(...) monc.oldterm.setTextColor(...) for k,v in pairs(monc.monitors) do if v.getSize() then v.setTextColor(...) end end end monc.term.setBackgroundColor = function(...) monc.oldterm.setBackgroundColor(...) for k,v in pairs(monc.monitors) do if v.getSize() then v.setBackgroundColor(...) end end end monc.term.getTextColor = function() return monc.oldterm.getTextColor() end monc.term.getBackgroundColor = function() return monc.oldterm.getBackgroundColor() end monc.term.setTextScale = function(...) for k,v in pairs(monc.monitors) do if v.getSize() then v.setTextScale(...) end end end --[[ monc.term.redirect = function(target) --local old = monc.oldterm --monc.oldterm = target --return old monc.oldterm = term.current() return term.current() -- ehhhh end --]] monc.term.native = function() return monc.origterm end monc.term.setTextColour = monc.term.setTextColor monc.term.setBackgroundColour = monc.term.setBackgroundColor monc.term.getTextColour = monc.term.getTextColor monc.term.getBackgroundColour = monc.term.getBackgroundColor monc.term.isColour = monc.term.isColor end local displayHelp = function() local helpdata = [[ Monc 2.0 - Computer/Monitor mirror [optional argument] <required argument> Monitor list is stored in memory only. >monc add/remove <monitor1> [monitor2] ... >monc list >monc help >monc setsize <size> [monitor] >monc [on/off] >monc ... -p <program> [argument1] ...]] print(helpdata) end local tArg = {...} if tArg[1] == "help" then displayHelp() end local eugh = 4 if tArg[1] == "add" then local newmons = {} for a = 2, #tArg do if tArg[a] == "-p" then break else newmons[#newmons+1] = tArg[a] end end for a = 1, #newmons do monname = newmons[a] newmon = peripheral.wrap(monname) if not newmon then return print("'"..monname.."' doesn't exist.") elseif peripheral.getType(monname) ~= "monitor" then return print("'"..monname.."' is not a monitor.") --idiot end monc.addMonitor(newmon,monname) end write("Monitor") if #newmons ~= 1 then write("s") end print(" added to list.") elseif tArg[1] == "delete" or tArg[1] == "remove" then local delmons = {} for a = 2, #tArg do if tArg[a] == "-p" then break else delmons[#delmons+1] = tArg[a] end end for a = 1, #delmons do local delname = delmons[a] if monc.monitors[delname] then monc.removeMonitor(delname) else print("Skipping nonexistant '"..delname.."'.") end end write("Deleted monitor") if #delmons > 1 then write("s") end print(" from list.") elseif tArg[1] == "list" then local allperiphs = peripheral.getNames() local allmons = {} for a = 1, #allperiphs do if peripheral.getType(allperiphs[a]) == "monitor" then allmons[#allmons+1] = allperiphs[a] end end if #allmons == 0 then print("No monitors found.") else for a = 1, #allmons do if monc.monitors[allmons[a]] then write(" ON ") else write("OFF ") end print("\""..allmons[a].."\"") end end local good = false --checks for any monitors on the list that were disconnected for k,v in pairs(monc.monitors) do for a = 1, #allmons do if allmons[a] == k then good = true break end end if not good then write("DIS ") print("\""..k.."\"") end end elseif tArg[1] == "setsize" then if not tonumber(tArg[2]) then print("Size must be a number.") elseif tonumber(tArg[2]) < 0.5 or tonumber(tArg[2]) > 5 then print("Size must be between 0.5 and 5 inclusive.") end if tArg[3] then if not monc.monitors[tArg[3]] then print("No such monitor.") else monc.monitors[tArg[3]].setTextScale(tonumber(tArg[2]) or 1) end else for k,v in pairs(monc.monitors) do v.setTextScale(tonumber(tArg[2]) or 1) end end write("Resized monitor") if not tArg[3] then if getTableSize(monc.monitors) ~= 1 then write("s") end end print(".") elseif tArg[1] == "on" then if monc.active then eugh = 3 else eugh = 1 end elseif tArg[1] == "off" then if not monc.active then eugh = 3 else eugh = 1 end elseif tArg[1] == "toggle" then eugh = 1 elseif tArg[1] == "moo" then local mooMsgs = { "There are no Easter Eggs in this program.", "There really are no Easter Eggs in this program.", "Didn't I already tell you there are no easter eggs in this program?", "Stop it!", "Okay, okay, if I give you an Easter Egg, will you go away?", [[Alright, you win. /----\ -------/ \ / \ / | -----------------/ --------\ ----------------------------------------------]], "What is it? It's an elephant being eaten by a snake, of course.", } local mooLvl = 1 for a = 1, #tArg do if tArg[a]:sub(1,1) == "-" and tArg[a]:gsub("v","") == "-" then mooLvl = mooLvl + #tArg[a]:sub(2) end end print(mooMsgs[mooLvl < #mooMsgs and mooLvl or #mooMsgs]) elseif not tArg[1] then eugh = 2 end local setTheTerm = function(newterm) for k,v in pairs(newterm) do term[k] = v end end local toggleMonc = function(active) if not monc.active then monc.active = true setTheTerm(monc.term) else monc.active = false setTheTerm(monc.oldterm) end end --time for the craaaaaazy stuff if eugh == 1 then toggleMonc() print("Monc "..(monc.active and "activated!" or "deactivated.")) elseif eugh == 2 then print("Do 'monc toggle/on/off' to use, or 'monc help' for more info.") elseif eugh == 3 then print("It's already in that state.") end for a = 1, #tArg do if tArg[a] == "-p" then local filerunname = {} for b = a+1, #tArg do filerunname[#filerunname+1] = tArg[b] end if shell then shell.run(unpack(filerunname)) else dofile(unpack(filerunname)) end break end end
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
⭐⭐ FREE BTC GUIDE ✅ Working ⭐⭐
JavaScript | 5 sec ago | 0.67 KB
🎯🎯 +50,000$ in 1 month⭐ 🎯🎯
JavaScript | 1 min ago | 0.67 KB
⭐⭐ INSTANT MONEY EXPLOIT ⭐⭐ ✅
JavaScript | 4 min ago | 0.67 KB
⚡ Earn 8,000$ Monthly Leaked Guide 🎯⭐
JavaScript | 6 min ago | 0.67 KB
⭐⭐ Crypto Swap Glitch ✅ Easy money ⭐⭐
JavaScript | 8 min ago | 0.67 KB
💎 2OOO$ 15 MIN INSANE METHOD 💵🚨 ✅✅
JavaScript | 11 min ago | 0.67 KB
💎💎💎 EXPLOIT 2,500$ IN 10 MINUTES
JavaScript | 12 min ago | 0.67 KB
✅ FREE 2,000$ FROM SWAPZONE ✅
JavaScript | 16 min ago | 0.67 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!