41 posts
Location
Everywhere
Posted 23 December 2013 - 07:35 PM
So I'm trying to make a system with 4 computers where there is a sender, two receivers and a 'server'. The sender rednet.send's a string to the 'server' containing one of the receiving computers ID's. Is there a way for the 'server' to check the string for certain text (in this case the receiving computers ID) and, say, store it in a variable(e.g: ReceivingID). Then the server could do: rednet.send(ReceivingID, "String"). This is just a guess, is there any way at all for me to do this? Thanks for reading, Imprivate
I'm new to CC don't hate :)/>
1852 posts
Location
Sweden
Posted 23 December 2013 - 08:08 PM
Well if you're just sending the ID's then it is easy
--# The computer that sends
local id = 101
rednet.send(<serverID>, id)
--# Server Computer
local id, receiverID = rednet.receive()
receiverID = tonumber(receiverID) -- Converts receiverID to a number
41 posts
Location
Everywhere
Posted 25 December 2013 - 05:22 PM
Well if you're just sending the ID's then it is easy
--# The computer that sends
local id = 101
rednet.send(<serverID>, id)
--# Server Computer
local id, receiverID = rednet.receive()
receiverID = tonumber(receiverID) -- Converts receiverID to a number
I wanted the ID in a string but oh well. I can always do read() and save that as the ID, I was just wondering if there was a way to check strings for certain text. Thanks anyway for you reply :)/>
P.S Checked out your Lasers game btw, +1'd :)/>
115 posts
Posted 25 December 2013 - 09:36 PM
I wanted the ID in a string but oh well. I can always do read() and save that as the ID, I was just wondering if there was a way to check strings for certain text. Thanks anyway for you reply :)/>
P.S Checked out your Lasers game btw, +1'd :)/>
id = tostring(id)
41 posts
Location
Everywhere
Posted 26 December 2013 - 08:15 AM
I wanted the ID in a string but oh well. I can always do read() and save that as the ID, I was just wondering if there was a way to check strings for certain text. Thanks anyway for you reply :)/>
P.S Checked out your Lasers game btw, +1'd :)/>
id = tostring(id)
Wouldn't that just check for the word "ID"? Oh well, this is still really useful, thanks! :)/>
995 posts
Location
Canada
Posted 26 December 2013 - 11:05 AM
No, tostring() converts numbers to strings. tonumber() does the opposite, as long as the string represents a valid number.