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

Run monitor and pc at same time

Started by ComputerCraftFan11, 26 March 2012 - 07:33 AM
ComputerCraftFan11 #1
Posted 26 March 2012 - 09:33 AM
Ever wanted to be using your monitor and your pc at the same time? This program does that.

(thanks to
Coryf88

)
local nativeTerm = term.native or term

local function invoke(sMethod, ...)
nativeTerm[sMethod](...)
for k,sSide in pairs(redstone.getSides()) do
  if peripheral.isPresent(sSide) and peripheral.getType(sSide) == "monitor" then
   peripheral.call(sSide, sMethod, ...)
  end
end
end

term.write = function(text) invoke("write", text) end
term.scroll = function(n) invoke("scroll", n) end
term.setCursorPos = function(x, y) invoke("setCursorPos", x, y) end
term.setCursorBlink = function(:o/>/> invoke("setCursorBlink", :o/>/> end
term.clear = function() invoke("clear") end
term.clearLine = function() invoke("clearLine") end

nativeTerm.clear()
nativeTerm.setCursorPos(1, 1)
print(os.version())

If you put a monitor on the right and run this program, you can use the monitor and see it on your computer screen.
Wolvan #2
Posted 26 March 2012 - 06:06 PM
Does this even start programs that have to be started with parameters/arguments?
ComputerCraftFan11 #3
Posted 26 March 2012 - 08:22 PM
Does this even start programs that have to be started with parameters/arguments?

Not yet…
BlackRa1n #4
Posted 26 March 2012 - 09:13 PM
Awesome! Now I can have hundereds of people gather around a giant monitor to watch me play snake and still play it because the terminal will also be running it!
ComputerCraftFan11 #5
Posted 26 March 2012 - 09:15 PM
Awesome! Now I can have hundereds of people gather around a giant monitor to watch me play snake and still play it because the terminal will also be running it!

I haven't tested that but if something happens, please tell me
BlackRa1n #6
Posted 26 March 2012 - 09:35 PM
Nope, it displays on Monitor first, and after that program ends on monitor, it shows up on terminal/computer!
ComputerCraftFan11 #7
Posted 26 March 2012 - 09:39 PM
Nope, it displays on Monitor first, and after that program ends on monitor, it shows up on terminal/computer!

Aww, I'm gonna fix that but in the next fix, it might require 2 computers (1 to handle the terminal and the other to handle the monitor)
BlackRa1n #8
Posted 26 March 2012 - 09:44 PM
And once it terminates on the monitor, the input for the game I was playing (MineDwarf, on RedWorksOS) lagged alot!
Resistance128 #9
Posted 27 March 2012 - 11:03 PM
Sorry for asking, but how do you make a monitor.?
Ps: I seem to have managed to break the underline button, It wouldn't stop until I fixed a spelling error ._.
Wolvan #10
Posted 27 March 2012 - 11:10 PM
hey what about this: try using tomiss' strutils API to seperate commands wit spaces, in program and parameters. and then you should be able to create a program that can run programs with arguments
Alex_ #11
Posted 29 March 2012 - 06:13 PM
you should put it to startup and also have the person on startup type which side is the monitor eg
print("which side is your monitor")
monitorside = read()
monitor = peripheral.wrap(monitorside)
Just a suggestion nothing else
Coryf88 #12
Posted 01 April 2012 - 04:59 AM
Put the following into your terminal's "startup" or run it as a program.


local nativeTerm = term.native or term

local function invoke(sMethod, ...)
nativeTerm[sMethod](...)
for k,sSide in pairs(redstone.getSides()) do
  if peripheral.isPresent(sSide) and peripheral.getType(sSide) == "monitor" then
   peripheral.call(sSide, sMethod, ...)
  end
end
end

term.write = function(text) invoke("write", text) end
term.scroll = function(n) invoke("scroll", n) end
term.setCursorPos = function(x, y) invoke("setCursorPos", x, y) end
term.setCursorBlink = function(:o/>/> invoke("setCursorBlink", :o/>/> end
term.clear = function() invoke("clear") end
term.clearLine = function() invoke("clearLine") end

nativeTerm.clear()
nativeTerm.setCursorPos(1, 1)
print(os.version())
Ivan Uginhigher #13
Posted 03 April 2012 - 01:37 AM
a tuturial on how to connect to tv network computer in minecraft will be a great idea
also the fact a code for each tv channels and dont forget a memory bank which radomize shows
Noodle #14
Posted 03 April 2012 - 03:18 AM
It only loads the monitor once.
You could go into your mods/computercraft folder and add the code to start every thing like hello, snake, etc.
That would be annoying.
Another thing @BlackRa1n
The monitor has a snippet of code with parameters
monitor <side> <application> <forgot this one>
ComputerCraftFan11 #15
Posted 08 April 2012 - 02:45 AM
Thanks Corfy88, i updated the post
ZeePal #16
Posted 01 June 2012 - 08:09 AM
Hey ComputerCraftFan11,

I like this script and I thought I would tweak it a bit as well as thank you:

local nativeTerm = term.native or term

local function invoke(sMethod, ...)
 nativeTerm[sMethod](...)
 for k,sSide in pairs(redstone.getSides()) do
    if peripheral.isPresent(sSide) and peripheral.getType(sSide) == "monitor" then
   peripheral.call(sSide, sMethod, ...)
  end
 end
end

local tArgs = { ... }
if #tArgs > 1 then
 print( "Usage: dual_monitors [-d|--disable]" )
 return
end

if tArgs[1] == "-d" or tArgs[1] == "--disable" then
 os.unloadAPI("/rom/apis/term")
 os.loadAPI("/rom/apis/term")
 term.clear()
 term.setCursorPos(1, 1)
 print(os.version())
else
 term.write = function(text) invoke("write", text) end
 term.scroll = function(n) invoke("scroll", n) end
 term.setCursorPos = function(x, y) invoke("setCursorPos", x, y) end
 term.setCursorBlink = function(:)/>/> invoke("setCursorBlink", :P/>/> end
 term.clear = function() invoke("clear") end
 term.clearLine = function() invoke("clearLine") end

 term.clear()
 term.setCursorPos(1, 1)
 print(os.version())
end

You can turn it off and on and while its on programs will just write to both (unless they access the term api directly).

I tested it on snake :)/>/>
Kikanek #17
Posted 09 June 2012 - 06:24 AM
It only loads the monitor once.
You could go into your mods/computercraft folder and add the code to start every thing like hello, snake, etc.
That would be annoying.
Another thing @BlackRa1n
The monitor has a snippet of code with parameters
monitor <side> <application> <forgot this one>
You forgot one…
You just need to paste it to "shell" program ;)/>/>
Under the line "print( os.version )" or replacing it, it will work anyways…
And it will work always, on any OS, any program, any computer :D/>/>…
And it will just don't work, not make error on computers what don't have monitor :D/>/>
Sorry for bad English, i am from Poland… :)/>/>
Regards,
Czcibor Bohusz-Dobosz a.k.a Kikanek
Po1son #18
Posted 28 June 2012 - 04:53 PM
I seem to have a problem, how could I fix this

Kikanek #19
Posted 30 June 2012 - 12:37 PM
@UP:
Why are You posting this here?
It's topic about running monitor and computer(craft) at the same time, not program named "moncopy".
But, to it not be offtopic… Where You find the program? It could have bug in code.
As i can see… The error is in line 4.
Regards,
Czcibor Bohusz-Dobosz a.k.a Kikanek
Uchiha Madara #20
Posted 30 June 2012 - 11:01 PM
I think Po1son script is the monitor script. by looking at the name and the bit of code i see in the background (Name: Moncopy: Monitor Copy)
But I'm only guessing so don't hate me if I'm wrong…
Po1son #21
Posted 05 July 2012 - 08:30 AM
@UP:
Why are You posting this here?
It's topic about running monitor and computer(craft) at the same time, not program named "moncopy".
But, to it not be offtopic… Where You find the program? It could have bug in code.
As i can see… The error is in line 4.
Regards,
Czcibor Bohusz-Dobosz a.k.a Kikanek
Im posting this here because moncopy is the name of my program running his script and yes I have error on line 4 and I've tryed several different things to fix it but it still does not work that's why I posted it here
ComputerCraftFan11 #22
Posted 05 July 2012 - 09:38 AM
@UP:
Why are You posting this here?
It's topic about running monitor and computer(craft) at the same time, not program named "moncopy".
But, to it not be offtopic… Where You find the program? It could have bug in code.
As i can see… The error is in line 4.
Regards,
Czcibor Bohusz-Dobosz a.k.a Kikanek
Im posting this here because moncopy is the name of my program running his script and yes I have error on line 4 and I've tryed several different things to fix it but it still does not work that's why I posted it here

You copied it wrong.

Can you post the code you used when you copied it? (Or line 4)
Po1son #23
Posted 05 July 2012 - 05:35 PM
@UP:
Why are You posting this here?
It's topic about running monitor and computer(craft) at the same time, not program named "moncopy".
But, to it not be offtopic… Where You find the program? It could have bug in code.
As i can see… The error is in line 4.
Regards,
Czcibor Bohusz-Dobosz a.k.a Kikanek
Im posting this here because moncopy is the name of my program running his script and yes I have error on line 4 and I've tryed several different things to fix it but it still does not work that's why I posted it here

You copied it wrong.

Can you post the code you used when you copied it? (Or line 4)





line 4: local function invoke (sMethod, . . . )
ComputerCraftFan11 #24
Posted 06 July 2012 - 12:45 AM
@UP:
Why are You posting this here?
It's topic about running monitor and computer(craft) at the same time, not program named "moncopy".
But, to it not be offtopic… Where You find the program? It could have bug in code.
As i can see… The error is in line 4.
Regards,
Czcibor Bohusz-Dobosz a.k.a Kikanek
Im posting this here because moncopy is the name of my program running his script and yes I have error on line 4 and I've tryed several different things to fix it but it still does not work that's why I posted it here

You copied it wrong.

Can you post the code you used when you copied it? (Or line 4)





line 4: local function invoke (sMethod, . . . )

You have spaces between the dots, you have to remove that
CptSK #25
Posted 07 July 2012 - 02:17 AM
I need help with this code I,m getting, bios:206: [string "monitorset2"]:12: '<eof>'