This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
BigSHinyToys's profile picture

[Splitter] Run Term And Monitor At The Same Time.

Started by BigSHinyToys, 14 November 2012 - 08:04 PM
BigSHinyToys #1
Posted 14 November 2012 - 09:04 PM
This project is no longer supported however a more comprehensive program exists to fill this same gap.
Monitor redirect controll - run many screens at ounce

If you would like to use this code "splitter" in your own branch of this project that is fine.
Splitter splits the output from term to go to a monitor to so you can see the program running even when you press [ESC] and walk around out side.





Download
http://pastebin.com/GcDsj9R1

pastebin get GcDsj9R1 split
Spoiler

--[[
		splitter mk2
		by BigSHinyToys
]]--
local tArgs = {...}
local sSide = {}
for i,v in pairs(rs.getSides()) do
	sSide[v] = true
end
local monSide
local monBig = false
local termX,termY = term.getSize()
local customTerm = {}
local moniter
local oldMon = {}
if #tArgs == 1 then
	if sSide[tArgs[1]] then
		monSide = string.lower(tArgs[1])
		if peripheral.isPresent(monSide) and peripheral.getType(monSide) == "monitor" then
			for size = 1.5,0.5,-0.5 do
				peripheral.call(monSide,"setTextScale",size)
				local monX,monY = peripheral.call(monSide,"getSize")
				if monX >= termX and monY >= termY then
					monBig = true
					break
				end
			end
		end
	elseif string.lower(tArgs[1]) == "restore" then
		term.restore()
		return
	end
else
	print("USAGE: <side> or \"restore\" ")
end
local function wrap( _sFunction )
	return function( ... )
		peripheral.call(monSide,_sFunction,...)
		return oldMon[_sFunction](...)
	end
end
if monBig then
	moniter = peripheral.wrap(monSide)
	for k,v in pairs(term.native) do
		oldMon[k] = v
	end
	for k,v in pairs( term.native ) do
		if type( k ) == "string" and type( v ) == "function" then
			customTerm[k] = wrap(k)
		end
	end
	term.redirect(customTerm)
	term.clear()
	term.setCursorPos(1,1)
	print("Running on monitor")
else
	print("Monitor to small")
end
Sammich Lord #2
Posted 15 November 2012 - 06:36 AM
This is pretty cool. Now I broadcast me playing worm on a huge monitor…
BigSHinyToys #3
Posted 15 November 2012 - 07:47 AM
This is pretty cool. Now I broadcast me playing worm on a huge monitor…
worm is now a spectator sport lolz
Sammich Lord #4
Posted 15 November 2012 - 08:00 AM
This is pretty cool. Now I broadcast me playing worm on a huge monitor…
worm is now a spectator sport lolz
Wait till it becomes a CCMLG(ComputerCraft Major League Gaming) sport. Now, just for somebody to make worm multiplayer…
BigSHinyToys #5
Posted 15 November 2012 - 04:39 PM
Wait till it becomes a CCMLG(ComputerCraft Major League Gaming) sport. Now, just for somebody to make worm multiplayer…
coming up on ESPN worm vs worm in hardcore apple eating action.
funisfun8 #6
Posted 30 November 2012 - 09:16 AM
OMG! Does anyone else realize this could be used to do lessons on servers! IF it can do edit (filename)…
russjr08 #7
Posted 30 November 2012 - 09:34 AM
OMG! Does anyone else realize this could be used to do lessons on servers! IF it can do edit (filename)…
It's basically like a projector, so yes, it can do edit <file> :)/>
funisfun8 #8
Posted 30 November 2012 - 10:36 AM
Yeah… I figured that out when I tested it… XD
Tiin57 #9
Posted 30 November 2012 - 10:42 AM
OMG! Does anyone else realize this could be used to do lessons on servers! IF it can do edit (filename)…
I wrote my own private code back when I used Tekkit to teach my server how to use CC. Don't have it anymore, though.
BigSHinyToys #10
Posted 30 November 2012 - 12:39 PM
OMG! Does anyone else realize this could be used to do lessons on servers! IF it can do edit (filename)…

you can use any program that doesn't redirect terminal so you can use all in built programs other than monitor. I use this to display a shell I'm working on
Spoiler
Runesmacher #11
Posted 02 December 2012 - 01:46 PM
Hi, it works good, but could you pleaseexplain what it all doies (line per line) ?
cous i can't seem to realy figure it out

edit: I took a look at the code still not knowing how it works but i changed stome stuff:
- Detects screen and then attaches it
- when screen is destroyed: no error but just restore to terminal
(take it as your own BigShinyToys if you like)
Spoiler

--[[
  demo
  by BigSHinyToys
]]--
local sides = {
  [1] = "left",
  [2] = "top",
  [3] = "bottom",
  [4] = "right",
  [5] = "back",
  [6] = "front",
  }
local tArgs = {...}
local monSide
local monBig = false
local termX,termY = term.getSize()
local customTerm = {}
local moniter
local oldMon = {}
local attached = false
for i=1,6 do
if peripheral.getType(sides[i]) == "monitor" then
  monSide = string.lower(sides[i])
  if peripheral.isPresent(monSide) and peripheral.getType(monSide) == "monitor" then
   attached = true
   local monX,monY = peripheral.call(monSide,"getSize")
   if monX >= termX and monY >= termY then
    monBig = true
   else
    peripheral.call(monSide,"setTextScale",0.5)
    monX,monY = peripheral.call(monSide,"getSize")
    if monX >= termX and monY >= termY then
	 monBig = true
    else
	 print("Monitor to small")
    end
   end
  end
elseif #tArgs == 1 then
  if string.lower(tArgs[1]) == "restore" then
   term.restore()
  end
end
end
if not attached then
  print("No screen attatched")
end
local function wrap( _sFunction )
return function( ... )
  if peripheral.isPresent(monSide) then
   peripheral.call(monSide,_sFunction,...)
   return oldMon[_sFunction](...)
  else
   term.restore()
   print("Screen restored")
  end
end
end
if monBig then
moniter = peripheral.wrap(monSide)
for k,v in pairs(term.native) do
  oldMon[k] = v
end
for k,v in pairs( term.native ) do
  if type( k ) == "string" and type( v ) == "function" then
   customTerm[k] = wrap(k)
  end
end
term.redirect(customTerm)
term.clear()
term.setCursorPos(1,1)
print("Running on monitor")
end
CodeMachine #12
Posted 27 December 2012 - 09:39 AM
I tried to do something like this using the parallel api, but it would only come out on the monitor….
SO DOWNLOADING
rick3333 #13
Posted 17 January 2013 - 06:41 PM
how big dose the monitor have to be?
theoriginalbit #14
Posted 17 January 2013 - 06:51 PM
how big dose the monitor have to be?
Based off that last image I'd say a minimum of 3x5 blocks…



Btw good job BigSHinyToys! :D/>
BigSHinyToys #15
Posted 17 January 2013 - 10:23 PM
Based off that last image I'd say a minimum of 3x5 blocks…
Btw good job BigSHinyToys! :D/>
well 3X5 is close but a couple of pixels off so 3X6 is the best option
Spoiler
[EDIT]
it will also automatically change the text scale if you want to use a 2X3 monitor
Spoiler
theoriginalbit #16
Posted 17 January 2013 - 10:28 PM
well 3X5 is close but a couple of pixels off so 3X6 is the best option
Damn so close… :P/>
gun and run #17
Posted 27 January 2013 - 09:54 AM
Would it be possible to fill the screen? Like a 6*8 screen?
Lyqyd #18
Posted 27 January 2013 - 10:01 AM
Fill it with what?
Mads #19
Posted 27 January 2013 - 08:48 PM
print("USAGE: <side> or "restore" ")

Should be \"restore\"
BigSHinyToys #20
Posted 28 January 2013 - 12:11 PM
name='mad' timestamp='1359319709' post='81024']
print("USAGE: <side> or "restore" ")

Should be \"restore\"
fixed
gun and run #21
Posted 28 January 2013 - 05:32 PM
Like to fill a 6*8 monitor all the way. Not just 1/4 of the screen?
BigSHinyToys #22
Posted 28 January 2013 - 06:03 PM
Like to fill a 6*8 monitor all the way. Not just 1/4 of the screen?
Sadly 2X scale makes it slightly too large for the largest monitor in CC so no I cant make it do that with out cropping off some of the screen If you would be fine with that i can make modifications for you.
Shnupbups #23
Posted 28 January 2013 - 06:10 PM
Sadly 2X scale makes it slightly too large for the largest monitor in CC so no I cant make it do that with out cropping off some of the screen If you would be fine with that i can make modifications for you.

What about 1.5x scale?
gun and run #24
Posted 28 January 2013 - 06:14 PM
I tired both of those, wish they went in increments of .1, but even then the aspect ratio is off. How does monitor (side) run programs fullscreen? Maybe look into the coding of the monitor program and see? Or is it hard-coded into the mod?
BigSHinyToys #25
Posted 28 January 2013 - 06:32 PM
I tired both of those, wish they went in increments of .1, but even then the aspect ratio is off. How does monitor (side) run programs fullscreen? Maybe look into the coding of the monitor program and see? Or is it hard-coded into the mod?
it runs full screen because it uses the mon = peripheral.wrap("side") mon.getSize() < this is larger when you are using a monitor and functions like print use that My splitter has to run on both so it uses the computers screen size not the monitors.


What about 1.5x scale?

I didn't know 1.5 was possible Thanks i will adapt the program to use best scale possible I will investigate text scale further.

for now alter line 21 to have 1.5 as the scale and it will work
BigSHinyToys #26
Posted 28 January 2013 - 07:12 PM
looks like the increment is 0.5
so | 0.5 | 1 | 1.5 | 2 | 2.5 | 3 | 3.5 | 4 | 4.5 | 5 | are the valid options

0.5 works on a monitor 3 wide 2 hight
1 works on a monitor 6 wide 3 hight (5 would work but you would loose one character on the right)
1.5 works on a monitor 8 wide 5 hight
greater than 1.5 will not fit a full terminal screen

I never knew 1.5 was possible so I will be editing splitter to accommodate that shortly.
Stay tuned for future updates.
BigSHinyToys #27
Posted 28 January 2013 - 08:39 PM
OK triple post sorry but I have modified splitter to select the best scale from 1.5 to 0.5 and cut 3 lines at the same time
use the scale in the above post to choose how many monitors you want to use.
Conan1981m #28
Posted 03 June 2013 - 12:59 PM
Great Job,
Also Clueless did a nice advantege !
I prefer the first code as you can use wired Monitors with it.

Id like to add touchscreen abilities, this would be aesome !!
Ill give it a try …
but im not good with coding ..
BigSHinyToys #29
Posted 03 June 2013 - 01:59 PM
This project is no longer supported however a more comprehensive program exists to fill this same gap.
Monitor redirect controll - run many screens at ounce

If you would like to use this code "splitter" in your own branch of this project that is fine.
ratchetgame98 #30
Posted 27 July 2013 - 06:06 PM
Based off that last image I'd say a minimum of 3x5 blocks…
Btw good job BigSHinyToys! :D/>/>
well 3X5 is close but a couple of pixels off so 3X6 is the best option
Spoiler
[EDIT]
it will also automatically change the text scale if you want to use a 2X3 monitor
Spoiler
But for some reason it isn't compatible with the largest possible monitors you can get
Lyqyd #31
Posted 30 July 2013 - 02:05 PM
Have you tried using the newer version he recommends in the post just above yours?
jesusthekiller #32
Posted 31 July 2013 - 05:02 AM
That's actually really cool! :)/>