Posted 28 July 2012 - 03:44 PM
When I run this half-finished server code (half-finished as in all the current features are complete, but some planned features are nonexistent), my console prints the first line as expected, then stops. Do I have too many variables defined? I've looked over it a dozen times and still can't find any errors.
print("Starting server.")
-- Variable defining
local scrap, msg = rednet.receive()
local wpasso = fs.open("passwords", "a")
local rpasso = fs.open("passwords", "r")
local cwpass = wpasso.close()
local crpass = rpasso.close()
local readi = read()
local wpass = wpasso.write(readi)
local rpass = rpasso.readAll()
-- Choosing mode/defining modes
print("Choose a mode: write or read.")
if readi == "write" then
print("Please input the new password.")
wpasso.write(readi)
print(rpass)
print("Rebooting.")
sleep(3.5)
os.reboot()
elseif readi == "read" then
if msg == rpass then
local time = os.time()
local wlog = fs.open("log", "w")
wlog.write(time)
os.reboot()
else
os.reboot()
end
else
print("Invalid option. Rebooting.")
sleep(1.5)
os.reboot()
end
I think I edited this properly. Please point out any formatting errors (and of course, coding errors)!