Jump to content




Search for a specific word?


  • You cannot reply to this topic
5 replies to this topic

#1 Imprivate

  • Members
  • 42 posts
  • LocationEverywhere

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 :)

#2 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

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


#3 Imprivate

  • Members
  • 42 posts
  • LocationEverywhere

Posted 25 December 2013 - 05:22 PM

View PostHellkid98, on 23 December 2013 - 08:08 PM, said:

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 :)

#4 Inumel

  • Members
  • 120 posts

Posted 25 December 2013 - 09:36 PM

View PostImprivate, on 25 December 2013 - 05:22 PM, said:


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)

#5 Imprivate

  • Members
  • 42 posts
  • LocationEverywhere

Posted 26 December 2013 - 08:15 AM

View PostElgriton, on 25 December 2013 - 09:36 PM, said:

View PostImprivate, on 25 December 2013 - 05:22 PM, said:

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! :)

#6 awsmazinggenius

  • Members
  • 930 posts
  • LocationCanada

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users