Jump to content

Computer Craft error coding


knightofe2

Recommended Posts

I coded a email system for my server for fun but I cant figure out why i keep getting this issue. also I only get this error when I read an email not when I send it out to the server

server:11: Expected string

    print("Running eMail server")

    rednet.open("right")

    while true do

    id, message = rednet.receive()

    if fs.exists(id .. message) then

    mail = fs.open(id .. message, "r")

    print("Computer " .. id .. " read his mail number " .. message)

    readmail = mail.readAll()

    rednet.broadcast(readmail)

    mail.close()

    fs.delete(id)

    else if message == "sendmail" then

    id1, to = rednet.receive()

    a = 1

    while fs.exists(to .. a) do

    a = a + 1

    end

    mail = fs.open(to .. a, "w")

      mail.writeLine("Total Amount of Emails: " .. a)

    if id == 1 then

        mail.writeLine("From: ArestheBloodGod")

        elseif id == 2 then

        mail.writeLine("From: Knightofe2")

        else

    mail.writeLine("From: " .. id)

    end

    if to == "1" then

        mail.writeLine("To: ArestheBloodGod")

        elseif to == "2" then

        mail.writeLine("To: Knightofe2")

    else

        mail.writeLine("To: " .. to)

    end

    id2, tm = rednet.receive()

    mail.write

    mail.close()

    print("Computer " .. id .. " sent Mail to " .. to)

    end

    end

    end

p.s. I do not take credit for this code I edited it from someone else

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...