6 posts
Posted 25 November 2012 - 08:57 AM
Hello I Want to make Somethig like This
Now When i type a command In the Firs Computer It automaticly Send A Signal To main Computer And He turns On transmitter 2
I want that on Master Computer Is all Automatic.
And Its with Blunded Cable :D/>/>/>
Thanks
209 posts
Location
In your fridge.
Posted 25 November 2012 - 09:22 AM
Well that's the first illustration I've seen, and it's informative, but we need your code to help.
6 posts
Posted 25 November 2012 - 10:28 AM
im thinking Of a Loop and in a loop on master Computer
Startup:
rednet.open("bottom")
Loop:
id,message = rednet.receive()
if message == "Open gate" then
redstone.setBundleOutput("right", shell.run("redpulse", "input", "1"), colors.red) –To transmitter 1
end
145 posts
Location
the vast cosmos of my mind; binary!
Posted 25 November 2012 - 11:13 AM
well you need to provide the code that "YOU"VE" written we can't write it for you you have to make some sort of dedication to this :D/>/>
6 posts
Posted 25 November 2012 - 11:49 AM
So here Is The Code that im attempting to use:
Spoiler
–Startup
rednet.open("bottom")
rednet.receive
–Code For Open Gate
if message=="Open gate" then
rs.setBundledOutput("back",colors.red)
sleep(1)
end
if message="light on"then
rs.serBundledOutput("back",colors.red)
sleep(1)
end The only problem is that there is 15 transmitters :D/>/>
And For every Transmitters Has To be A Command Like
T11 On (transmitter 11 on) and T11 Off(Transmitter 11 off)
180 posts
Posted 25 November 2012 - 12:00 PM
There looks to be two main problems there.
1) rednet.receive
it is missing the () at the end, and that command returns the computer ID sending the message, as well as the message, which you need to put into variables.
The documentation is here:
http://computercraft.info/wiki/index.php?title=Rednet.receiveYou will probably want to replace it with a line such as:
sender, message, distance = rednet.receive()
2) Your program will only run once and then quit. You will probably want it to keep listening for messages after the first one.
Right after rednet.open("bottom") put
while true do
and at the very end of it, add another
end
Then it will keep listening for new messages and acting on it.
Then your master computer can use rednet.send (documentatino here
http://computercraft.info/wiki/index.php?title=Rednet.send )
to send to a specific 'transmitter' computer ID.
6 posts
Posted 25 November 2012 - 12:17 PM
Thanks So much!
2005 posts
Posted 26 November 2012 - 08:08 AM
Also, if you have fifteen possible messages and fifteen possible actions, then make a function table like so:
local t_func = {
funcName1 = function()
--some stuff that does what you want
end,
funcName2 = function()
--some stuff that does what you want
end,
funcName3 = function()
--some stuff that does what you want
end,
--and so on
}
rednet.open("bottom")
repeat id,message = rednet.receive()
if id == 1 and t_func[message] then t_func[message]() --if the sender is the controlling computer (here assumed to be 1) and the message indexes a function in your table, then call that function
end
until id == 1 and message == "terminate remote control" --just so that you have a way to shut this down if you want