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

Simple E-mail System

Started by tfoote, 14 June 2012 - 06:40 PM
tfoote #1
Posted 14 June 2012 - 08:40 PM
I have created a functional E-mail system that works as so…

1st you enter the e-mail system program – (still to be coded)
2) You type the receiving computer ID – (or look in the address book)
3) Type body of e-mail
4) the computer will send to a server the receiving computer ID
5) in a separate message it will send the body of the e-mail.
6) the server will send the e-mail around until one of the servers finds that the receiving computer is connected to it
7) Receiving computer will save the body of the e-mail as a variable
8) then it displays the e-mail
9) two buttons on the side let you "flip" through your e-mails.
– Can only store 26 e-mails per computer
– Server is more efficient that you think. If one server receives a message from another it will not re-send it to that server. It will send it to the next until it finds the receiving computer.
This system works and is efficient.

If you have any questions let me know.
MysticT #2
Posted 14 June 2012 - 08:59 PM
4) the computer will send to a server the receiving computer ID
5) in a separate message it will send the body of the e-mail.
Wouldn't be better to send both in one message? It's faster and will save some troubles.
tfoote #3
Posted 14 June 2012 - 09:00 PM
Well… I don't know how to read certain parts of 1 message. so it sends 2. .5 sec apart
MysticT #4
Posted 14 June 2012 - 09:10 PM
There's different ways to do it, the simplest is using a table and serialization:
Sender:

local msg = {}
msg.id = senderId
msg.body = "The message to send"
rednet.send(serverID, textutils.serialize(msg))
Receiver:

local id, msg = rednet.receive()
local t = textutils.unserialize(msg)
print("E-Mail sent from ", id, " to ", t.id, ": ")
print(t.body)
tfoote #5
Posted 14 June 2012 - 09:13 PM
Thank you very much. Where is the API that runs that?
MysticT #6
Posted 14 June 2012 - 09:24 PM
textutils? is a defualt CC api, it should be in /rom/apis
tfoote #7
Posted 14 June 2012 - 09:30 PM
ok