This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Noodle's profile picture

New Rednet Server Idea

Started by Noodle, 14 August 2012 - 07:18 PM
Noodle #1
Posted 14 August 2012 - 09:18 PM
100% Configurable
It uses string patterns as separation for the name, cmd, etc.
for k, v in pairs(rs.getSides()) do
rednet.open(v)
end
while true do
id, msg = rednet.receive()
name, cmd, parms = msg:match("^(%S*) (%S*) (.*)") -- Name = Servername, Cmd = Command to server, parms = paramers
if name == "server" then -- server name
  print(name)
  if cmd == "joseph" then
   print(cmd)
  else
   print("Unknown Command")
  end
end
end
I will post a tutorial on how to configure this upon request.
Its not really 100% configurable because you need to know string patterns in order to mess with the parameters.
D3matt #2
Posted 14 August 2012 - 10:19 PM
Could you do those of us less familiar with string patterns a favor and explain what the pattern there does? I think I understand most of it but I want to be sure.
Noodle #3
Posted 14 August 2012 - 10:45 PM
I can make a tutorial if you want
The strings are
S = String
^(%S*) - First string thru the message (whole entire first string) IE: patrick like bubbles - it would take out the patrick
(%S*) same thing as above just not the first letter
(.*) is everything after the first two strings IE: patrick likes bubbles - It would be patrick likes bubbles
Lyqyd #4
Posted 15 August 2012 - 01:09 AM
%S matches all non-space characters, for clarity's sake. See String Matching Patterns.
Noodle #5
Posted 15 August 2012 - 01:51 AM
That's what I was saying but to beginners it basically means all the parts of the string..
chridal #6
Posted 15 August 2012 - 07:50 AM
Hi!

I am currently working on a client-architecture that works in this manner.

It will be highly modular, and by writing your own events.lua file (basically listing the functions it can perform, and defining them) you can take use of it in any project.

I am also coding a debug/report tool deep into it so that it will be a lot easier to debug and maintain client-server architecture software in the future.

Expected to finnish within the next weeks.
Noodle #7
Posted 15 August 2012 - 03:27 PM
Made the code more efficient by changing all rednet.open() to a table sides then opening all in a for loop.