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

[Lua] Rednet Movie Message

Started by timyo24, 11 August 2012 - 03:27 AM
timyo24 #1
Posted 11 August 2012 - 05:27 AM
Ok, i know you can ouse modems and send messages to other terminals with Rednet, but i am wondering if it would be possible to have a movie theater with a control room elsewhere and be able to start like the secret StarWars program in the theater by sending it to the computer controlling the monitor. I have the terminal in the theater using a code to sync screens of the terminal and the monitor on start up, so all i would need is a code to send the messages like the movie to it from the control room. Any help is appreciated! ;)/>/> Thanks!
Lyqyd #2
Posted 11 August 2012 - 05:38 AM
You might try using terminal redirection over rednet, something that my LyqydNet API includes.

Edit: While this is a possibility, you're probably better off telling the display computer a program to run and having it run it on the monitor instead.
Edited on 11 August 2012 - 03:42 AM
Pharap #3
Posted 11 August 2012 - 05:46 AM
You could have each screen set up with a computer behind it and the computer could use rednet to relay your instructions from the control terminal to the monitor.
timyo24 #4
Posted 11 August 2012 - 05:55 AM
You could have each screen set up with a computer behind it and the computer could use rednet to relay your instructions from the control terminal to the monitor.

Explain in more detail please.

Actually, give me an example of coding to send instructions to the screen terminal please.
Pharap #5
Posted 11 August 2012 - 06:22 AM
So basically you'd have one computer controlling it all. Say you had a program to play the films, it might look something like this:

—Control Terminal—-

rednet.open("top")
rednet.broadcast("Play")
rednet.close("top")
—-Receiving computer—-

rednet.open("top")
while true do
e, id, msg = os.pullEvent()
if e == "rednet_message" and  id == (id of controlling computer) and msg == "Play"  then
shell.run("monitor","back",(name of film program),(any arguments))
end
end
rednet.close("top")

That's the basic idea, if you want anything more complicated, I'd need more time.
Edited on 11 August 2012 - 05:48 PM
timyo24 #6
Posted 11 August 2012 - 06:28 AM
So basically you'd have one computer controlling it all. Say you had a program to play the films, it might look something like this:

—Control Terminal—-

rednet.broadcast("Play")
—-Receiving computer—-

screen = peripheral.wrap("back")
while true do
e, id, msg = os.pullEvent()
if e == "rednet_message" and  id == (id of controlling computer) and msg == "Play"  then
shell.run("monitor","back",(name of film program),(any arguments))
end
end

That's the basic idea, if you want anything more complicated, I'd need more time.

Alright i get that, so say id want to play the starwars film, id put at the end of the code, shell.run ("monitor", "front", (secret/alongtimeago)
did i get that right?

EDIT: ok, the "Play" program works, but the recieving computer keeps giving me bios:206: [string "movie"] :6: ')' expected error code looks like this,


rednet.open ("back")
screen = peripheral.wrap ("front")
while true do
e, id, msg = os.pullevent
if e == rednet_message and id == (6) and msg == "Play" then
shell.run ("monitor", "front", (secretalongtimeago), ())
end
end
Pharap #7
Posted 11 August 2012 - 06:47 AM
So basically you'd have one computer controlling it all. Say you had a program to play the films, it might look something like this:

—Control Terminal—-

rednet.broadcast("Play")
—-Receiving computer—-

screen = peripheral.wrap("back")
while true do
e, id, msg = os.pullEvent()
if e == "rednet_message" and  id == (id of controlling computer) and msg == "Play"  then
shell.run("monitor","back",(name of film program),(any arguments))
end
end

That's the basic idea, if you want anything more complicated, I'd need more time.

Alright i get that, so say id want to play the starwars film, id put at the end of the code, shell.run ("monitor", "front", (secret/alongtimeago)
did i get that right?
Mostly, just do it with quotes instead of brakcets (I only put those in there to separate it from the rest of the code. )
So it would be: shell.run("monitor", "front", "secret/alongtimeago")
assuming of course that the computer is next to the monitor with the screen against it.
timyo24 #8
Posted 11 August 2012 - 08:37 AM
So basically you'd have one computer controlling it all. Say you had a program to play the films, it might look something like this:

—Control Terminal—-

rednet.broadcast("Play")
—-Receiving computer—-

screen = peripheral.wrap("back")
while true do
e, id, msg = os.pullEvent()
if e == "rednet_message" and  id == (id of controlling computer) and msg == "Play"  then
shell.run("monitor","back",(name of film program),(any arguments))
end
end

That's the basic idea, if you want anything more complicated, I'd need more time.

Alright i get that, so say id want to play the starwars film, id put at the end of the code, shell.run ("monitor", "front", (secret/alongtimeago)
did i get that right?
Mostly, just do it with quotes instead of brakcets (I only put those in there to separate it from the rest of the code. )
So it would be: shell.run("monitor", "front", "secret/alongtimeago")
assuming of course that the computer is next to the monitor with the screen against it.

Omg, now when i run the program it gives me the error attempt to call nil
Cranium #9
Posted 11 August 2012 - 06:16 PM
What's your code right now?
Pharap #10
Posted 11 August 2012 - 07:47 PM
What code have you put, I have a feeling I know what's wrong.
timyo24 #11
Posted 11 August 2012 - 07:53 PM

rednet.open ("back")
screen = peripheral.wrap ("front")
while true do
e, id, msg = os.pullEvent ()
if e == "rednet_message" and id == "6" and msg == "Play" then
shell.run ("monitor", "front", "secret/alongtimeago")
end
end
Pharap #12
Posted 11 August 2012 - 08:05 PM

rednet.open ("back")
screen = peripheral.wrap ("front")
while true do
e, id, msg = os.pullEvent ()
if e == "rednet_message" and id == "6" and msg == "Play" then
shell.run ("monitor", "front", "secret/alongtimeago")
end
end

The id number shouldn't be in quote marks as it's an actual number, not a string. Also you need to close rednet at the end or it will stay open indefinitely, thus when you rerun the open command, it will probably throw an error since rednet is already open.

Also, you don't necessarily need the screen.wrap (that was my fault, I was a bit tired at the time of writing so I wasn't thinking completely straight).

What side of the computer is touching the monitor? If you can see the screen, then it's not the front and you're trying to get the computer to run the program on a monitor that doesn't exist.
timyo24 #13
Posted 11 August 2012 - 08:07 PM

rednet.open ("back")
screen = peripheral.wrap ("front")
while true do
e, id, msg = os.pullEvent ()
if e == "rednet_message" and id == "6" and msg == "Play" then
shell.run ("monitor", "front", "secret/alongtimeago")
end
end

The id number shouldn't be in quote marks as it's an actual number, not a string. Also you need to close rednet at the end or it will stay open indefinitely, thus when you rerun the open command, it will probably throw an error since rednet is already open.

Also, you don't necessarily need the screen.wrap (that was my fault, I was a bit tired at the time of writing so I wasn't thinking completely straight).

What side of the computer is touching the monitor? If you can see the screen, then it's not the front and you're trying to get the computer to run the program on a monitor that doesn't exist.

The screen is touching the monitor, i have it set behind the monitor so the people cant see it.
Pharap #14
Posted 11 August 2012 - 08:21 PM
The id number shouldn't be in quote marks as it's an actual number, not a string. Also you need to close rednet at the end or it will stay open indefinitely, thus when you rerun the open command, it will probably throw an error since rednet is already open.

Also, you don't necessarily need the screen.wrap (that was my fault, I was a bit tired at the time of writing so I wasn't thinking completely straight).

What side of the computer is touching the monitor? If you can see the screen, then it's not the front and you're trying to get the computer to run the program on a monitor that doesn't exist.

The screen is touching the monitor, i have it set behind the monitor so the people cant see it.

In that case, it should be just the number and the not closing issue. Try fixing those and trying it again. If it still doesn't work, post a copy of your changed code and we'll have another look.