12 posts
Location
A place
Posted 04 July 2015 - 03:13 AM
Some may consider this a noob question, but I've only really been using ComputerCraft for a couple months and I've never seen how to send regular data between computers. How would I accomplish this?
7083 posts
Location
Tasmania (AU)
Posted 04 July 2015 - 03:42 AM
Generally with the
rednet API. Slap modems on your computers,
open the relevant sides, then proceed to
send and
receive.
12 posts
Location
A place
Posted 04 July 2015 - 04:12 AM
Nice rhyme :)/>. I now have two questions.
1. How would I specify/find the ID of a computer?
2. Are the rednet.send() protocols user-specified or is there a set list of them?
7083 posts
Location
Tasmania (AU)
Posted 04 July 2015 - 04:57 AM
1. How would I specify/find the ID of a computer?
If you type "id" into a given computer's command line, it'll give you its ID number. If you instead want your two systems to figure it out automagically, incorporate
rednet.lookup() into your scripts.
2. Are the rednet.send() protocols user-specified or is there a set list of them?
They're user-defined, and can be pretty much whatever you want.
However, avoid the string "dns" - that one's used by the rednet lookup system, which'll get confused if you try it.
12 posts
Location
A place
Posted 04 July 2015 - 05:03 AM
Thanks for the help and quick response!
130 posts
Location
Here
Posted 04 July 2015 - 05:17 AM
a slighty easier way to do this in the case that you want to communicate with a select number of devices (multicast) instead of broadcasting to all devices using rednet is if you use the modem api -
http://www.computercraft.info/wiki/Modem_(API) and transmit over a selected channel
sendChan = 100
recvChan = 100
--Send
local data = "Hello"
modem.transmit(sendChan,recvChan,data)
--/Send
--Recv
while true do
event = {os.pullEvent()}
if event and event[2] == "modem_message" and event[4] == recvChan then
return event[6]
end
end
--/Recv
Edited on 04 July 2015 - 11:56 PM