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

DNS server

Started by dexter9, 21 February 2013 - 06:01 AM
dexter9 #1
Posted 21 February 2013 - 07:01 AM
Hi I was wanting to make websites and email programs and other everyday use of internet applications. I went on to realise computer IDS can be hard to remember 123 1 3 which one? So i thought about programming a DNS server, which would receive a message:
Email: rugbyguy99
message: Hi

The Idea would be that the dns server would receive this message and look in its directory for rugbyguy99. It would then say ah rugbyguy99 the id is 5 and then send the message to computer with ID 5. Does this make sense?
Any help would be appreciated
Sammich Lord #2
Posted 21 February 2013 - 07:37 AM
You could of have a table of all ID's that have their index set to the name. So something like this is pretty basic:

for k,v in pairs(rs.getSides()) do
  rednet.open(v)
end

ids = {
  ["helloWorld"] = 1,
  ["bob"] = 3,
  ["mansion"] = 500
}

while true do
  id, msg = rednet.receive()
  for k,v in pairs(ids) do
    if tonumber(msg) == k then
      rednet.send(id, v)
      print("Sent: "..v.." the ID for "..k)
    end
  end
end
It is basic but it works.
remiX #3
Posted 21 February 2013 - 07:37 AM
Can't you use a MySQL database to keep this information. The CC computer can then retrieve information from a website which connects to the database of the information, returning the id
Sammich Lord #4
Posted 21 February 2013 - 07:39 AM
Can't you use a MySQL database to keep this information. The CC computer can then retrieve information from a website which connects to the database of the information, returning the id
I doubt he has a spare web server around. I believe his intent was to do this all in-game.

Also, Ninja'd :ph34r:/>
dexter9 #5
Posted 21 February 2013 - 07:40 AM
Ah perfect. This is exactly what i wanted! I edited the basic roaming profiles password lock posted on the computercraft website though it didnt seem to work. Thanks alot!
remiX #6
Posted 21 February 2013 - 07:41 AM
Can't you use a MySQL database to keep this information. The CC computer can then retrieve information from a website which connects to the database of the information, returning the id
I doubt he has a spare web server around. I believe his intent was to do this all in-game.

Also, Ninja'd :ph34r:/>

He could use a free webhoster, EG 000webhost (supports php, I use it and it's awesome)

You could of have a table of all ID's that have their index set to the name. So something like this is pretty basic:

for k,v in pairs(rs.getSides()) do
  rednet.open(v)
end

ids = {
  ["helloWorld"] = 1,
  ["bob"] = 3,
  ["mansion"] = 500
}

while true do
  id, msg = rednet.receive()
  for k,v in pairs(ids) do
	if tonumber(msg) == k then
	  rednet.send(id, v)
	  print("Sent: "..v.." the ID for "..k)
	end
  end
end
It is basic but it works.

Well hmm please do tell me if it really works - why are you tonumbering msg and then checking if it's equal to a STRING? :P/>
Sammich Lord #7
Posted 21 February 2013 - 07:44 AM
Well hmm please do tell me if it really works - why are you tonumbering msg and then checking if it's equal to a STRING? :P/>
Well I was pretty tired. Don't tonumber the string :P/> I meant to tostring the ID when I sent it back.
remiX #8
Posted 21 February 2013 - 07:46 AM
Yeah common mistake really… it's funny that every time someone makes a mistake their excuse is 'i was tired' xD

But yeah he was talking about DNS servers so I thought of websites ^^
dexter9 #9
Posted 21 February 2013 - 07:53 AM
Thank you! Do any of you know much about GPS?
Sammich Lord #10
Posted 21 February 2013 - 07:55 AM
Thank you! Do any of you know much about GPS?
Check the tutorials section for some tutorials on it.
PixelToast #11
Posted 21 February 2013 - 07:55 AM
i do
dexter9 #12
Posted 21 February 2013 - 07:58 AM
can u look here?
http://www.computercraft.info/forums2/index.php?/topic/10554-automatic-transport/page__fromsearch__1
dexter9 #13
Posted 21 February 2013 - 09:56 AM
Hi only testing it now. I programmed it to say error if it didnt work and it said error 3 times. Whats wrong is it my send/receive program i dont know how to upload it to show. Is there any basics i should be looking at to change to match the dns program?
Sammich Lord #14
Posted 21 February 2013 - 10:01 AM
Hi only testing it now. I programmed it to say error if it didnt work and it said error 3 times. Whats wrong is it my send/receive program i dont know how to upload it to show. Is there any basics i should be looking at to change to match the dns program?
Not sure what you mean.
dexter9 #15
Posted 21 February 2013 - 10:06 AM
Can someone post a compatible email program?
Sammich Lord #16
Posted 21 February 2013 - 10:11 AM
Can someone post a compatible email program?
We are not going to code for you. There are plenty scripts on the forums to do what you want. We are just here to help people.
remiX #17
Posted 21 February 2013 - 05:28 PM
Rednet email program or web-based email program? Maybe try the programs section
dexter9 #18
Posted 22 February 2013 - 06:29 AM
thanks! its a new way of coding for me you know the dns server thing. Are there any main points i should have in my email set-up like different paramentors?
dexter9 #19
Posted 23 February 2013 - 08:21 AM
It says rednet string expected?
<script src="http://pastebin.com/embed_js.php?i=a5ykmER9"></script>

http://pastebin.com/a5ykmER9
PixelToast #20
Posted 23 February 2013 - 08:26 AM
rednet.send(id, v)
sould be
rednet.send(v,k)