help
Started by SpencerBeige, Nov 15 2014 02:27 AM
11 replies to this topic
#1
Posted 15 November 2014 - 02:27 AM
trying to send a table thru rednet...no wurk plz help. i cannot access the file, as i am on a server. so...how do i use rednet.broadcast() and rednet.receive() to send, and receive a table?
#2
Posted 15 November 2014 - 02:33 AM
local tbl = {"I'm a table!"}
rednet.open("left") --#Let's say the modem is on the left
rednet.broadcast(tbl,"Myprotocol")
rednet.open("left")
local senderID, message, protocol = rednet.receive(0,"Myprotocol") --#Only messages with the protocol Myprotocol will allow the program to continue
print(message[1]) --#I'm a table!
Edited by Dragon53535, 15 November 2014 - 02:35 AM.
#3
Posted 15 November 2014 - 02:46 AM
Which version of CC are you using?
#4
Posted 15 November 2014 - 03:05 AM
I'm assuming by his post in LuaLand's topic, he's on 1.65 or 1.63, i think 1.65 i just don't know what version's on the mod pack
#6
Posted 15 November 2014 - 04:36 PM
this is pretty much what im doing, im doing something like this(btw, im making an online bank system, so plz dont question whats inside the table):
m = {"newuser", username, pin}
rednet.broadcast(m, ATM)
----------------------------------------------------------------------------------
m = rednet.receive(ATM)
for i = 1,#m do
print(m[i])
end
-------------------------------------------------------------------------------------
and this is pretty much what i get back:
1279(computer id#)
table:(random nums and letters)
ATM
m = {"newuser", username, pin}
rednet.broadcast(m, ATM)
----------------------------------------------------------------------------------
m = rednet.receive(ATM)
for i = 1,#m do
print(m[i])
end
-------------------------------------------------------------------------------------
and this is pretty much what i get back:
1279(computer id#)
table:(random nums and letters)
ATM
#7
Posted 15 November 2014 - 04:53 PM
slow-coder, on 15 November 2014 - 04:36 PM, said:
this is pretty much what im doing, im doing something like this(btw, im making an online bank system, so plz dont question whats inside the table):
m = {"newuser", username, pin}
rednet.broadcast(m, ATM)
----------------------------------------------------------------------------------
m = rednet.receive(ATM)
for i = 1,#m do
print(m[i])
end
-------------------------------------------------------------------------------------
and this is pretty much what i get back:
1279(computer id#)
table:(random nums and letters)
ATM
m = {"newuser", username, pin}
rednet.broadcast(m, ATM)
----------------------------------------------------------------------------------
m = rednet.receive(ATM)
for i = 1,#m do
print(m[i])
end
-------------------------------------------------------------------------------------
and this is pretty much what i get back:
1279(computer id#)
table:(random nums and letters)
ATM
Put "" around atm. Right now you are setting the protocol to a variable which equals nil, which I would assume would make it assume that there is not a protocol.
edit:
You are probably intercepting someone elses rednet message asusming you are still on a server.
edit2:
Just saw you are getting the protocol back when you receive the msg.
Edited by valithor, 15 November 2014 - 04:58 PM.
#8
Posted 15 November 2014 - 05:14 PM
i tried putting "" around the protocol; still no wurk. also, i do agree that in autumncity, it is a big problem. people are setting up robots that send messages to every computer, it makes me angry since they are effectively making rednet 10x harder to work with
#9
Posted 15 November 2014 - 06:00 PM
slow-coder, on 15 November 2014 - 05:14 PM, said:
i tried putting "" around the protocol; still no wurk. also, i do agree that in autumncity, it is a big problem. people are setting up robots that send messages to every computer, it makes me angry since they are effectively making rednet 10x harder to work with
print(message[1]) --# "newuser" print(message[2]) --# username print(message[3]) --# pin
#10
Posted 15 November 2014 - 08:22 PM
rednet.receive() returns the sender's ID, then the message and then the protocol (if there was one). You are only catching the ID and trying to iterate through that.
#11
Posted 15 November 2014 - 10:40 PM
Given the stated output, I guess he used m = {rednet.receive()}, but didn't reflect that in the code he showed.
#12
Posted 16 November 2014 - 12:11 AM
local message = m[2] --#Turn message into the table held in m[2] print(message[1]) --# Your newuser thing print(message[2]) --# Their username print(message[3]) --# Their pin
3 user(s) are reading this topic
0 members, 3 guests, 0 anonymous users











